feat: new Columnar upload form and API (#28192)

This commit is contained in:
Daniel Vaz Gaspar
2024-05-06 15:51:42 +01:00
committed by GitHub
parent f5843fe588
commit 9a339f08a7
29 changed files with 2267 additions and 1232 deletions

View File

@@ -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():