mirror of
https://github.com/apache/superset.git
synced 2026-04-17 23:25:05 +00:00
feat: new Columnar upload form and API (#28192)
This commit is contained in:
committed by
GitHub
parent
f5843fe588
commit
9a339f08a7
@@ -138,6 +138,38 @@ def test_csv_upload_dataset():
|
||||
assert security_manager.find_user("admin") in dataset.owners
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_csv_upload_with_context")
|
||||
def test_csv_upload_with_index():
|
||||
admin_user = security_manager.find_user(username="admin")
|
||||
upload_database = get_upload_db()
|
||||
|
||||
with override_user(admin_user):
|
||||
UploadCommand(
|
||||
upload_database.id,
|
||||
CSV_UPLOAD_TABLE,
|
||||
create_csv_file(CSV_FILE_1),
|
||||
None,
|
||||
CSVReader({"dataframe_index": True, "index_label": "id"}),
|
||||
).run()
|
||||
with upload_database.get_sqla_engine() as engine:
|
||||
data = engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").fetchall()
|
||||
assert data == [
|
||||
(0, "name1", 30, "city1", "1-1-1980"),
|
||||
(1, "name2", 29, "city2", "1-1-1981"),
|
||||
(2, "name3", 28, "city3", "1-1-1982"),
|
||||
]
|
||||
# assert column names
|
||||
assert [
|
||||
col for col in engine.execute(f"SELECT * from {CSV_UPLOAD_TABLE}").keys()
|
||||
] == [
|
||||
"id",
|
||||
"Name",
|
||||
"Age",
|
||||
"City",
|
||||
"Birth",
|
||||
]
|
||||
|
||||
|
||||
@only_postgresql
|
||||
@pytest.mark.usefixtures("setup_csv_upload_with_context")
|
||||
def test_csv_upload_database_not_found():
|
||||
|
||||
Reference in New Issue
Block a user