|
14 | 14 |
|
15 | 15 | import httpx |
16 | 16 | import pytest |
17 | | -from faker import Faker |
| 17 | +import sqlalchemy as sa |
18 | 18 | from fastapi import FastAPI, status |
19 | 19 | from fastapi_pagination.cursor import CursorPage |
20 | 20 | from models_library.api_schemas_storage.storage_schemas import PathMetaDataGet |
|
24 | 24 | from pytest_simcore.helpers.fastapi import url_from_operation_id |
25 | 25 | from pytest_simcore.helpers.httpx_assert_checks import assert_status |
26 | 26 | from pytest_simcore.helpers.storage_utils import FileIDDict, ProjectWithFilesParams |
| 27 | +from simcore_postgres_database.models.projects import projects |
| 28 | +from sqlalchemy.ext.asyncio import AsyncEngine |
27 | 29 |
|
28 | 30 | pytest_simcore_core_services_selection = ["postgres"] |
29 | 31 | pytest_simcore_ops_services_selection = ["adminer"] |
@@ -143,7 +145,6 @@ async def test_list_paths_pagination( |
143 | 145 | dict[str, Any], |
144 | 146 | dict[NodeID, dict[SimcoreS3FileID, FileIDDict]], |
145 | 147 | ], |
146 | | - faker: Faker, |
147 | 148 | ): |
148 | 149 | project, list_of_files = with_random_project_with_files |
149 | 150 | num_nodes = len(list(project["workbench"])) |
@@ -361,3 +362,58 @@ async def test_list_paths( |
361 | 362 | expected_paths=expected_paths, |
362 | 363 | check_total=False, |
363 | 364 | ) |
| 365 | + |
| 366 | + |
| 367 | +@pytest.mark.parametrize( |
| 368 | + "project_params", |
| 369 | + [ |
| 370 | + ProjectWithFilesParams( |
| 371 | + num_nodes=1, |
| 372 | + allowed_file_sizes=(TypeAdapter(ByteSize).validate_python("0b"),), |
| 373 | + workspace_files_count=0, |
| 374 | + ) |
| 375 | + ], |
| 376 | + ids=str, |
| 377 | +) |
| 378 | +async def test_list_paths_with_display_name_containing_slashes( |
| 379 | + initialized_app: FastAPI, |
| 380 | + client: httpx.AsyncClient, |
| 381 | + location_id: LocationID, |
| 382 | + user_id: UserID, |
| 383 | + with_random_project_with_files: tuple[ |
| 384 | + dict[str, Any], |
| 385 | + dict[NodeID, dict[SimcoreS3FileID, FileIDDict]], |
| 386 | + ], |
| 387 | + sqlalchemy_async_engine: AsyncEngine, |
| 388 | +): |
| 389 | + project, list_of_files = with_random_project_with_files |
| 390 | + name_with_slashes = "something with/ a slash" |
| 391 | + async with sqlalchemy_async_engine.begin() as conn: |
| 392 | + result = await conn.execute( |
| 393 | + sa.update(projects) |
| 394 | + .where(projects.c.uuid == project["uuid"]) |
| 395 | + .values(name=name_with_slashes) |
| 396 | + .returning(sa.literal_column(f"{projects.c.name}")) |
| 397 | + ) |
| 398 | + row = result.one() |
| 399 | + assert row[0] == name_with_slashes |
| 400 | + # ls the root |
| 401 | + file_filter = None |
| 402 | + expected_paths = [(Path(project["uuid"]), False)] |
| 403 | + |
| 404 | + page_of_paths = await _assert_list_paths( |
| 405 | + initialized_app, |
| 406 | + client, |
| 407 | + location_id, |
| 408 | + user_id, |
| 409 | + file_filter=file_filter, |
| 410 | + expected_paths=expected_paths, |
| 411 | + ) |
| 412 | + |
| 413 | + assert page_of_paths.items[0].display_path == Path(name_with_slashes) |
| 414 | + |
| 415 | + file_filter = Path(project["uuid"]) |
| 416 | + expected_paths = sorted( |
| 417 | + ((file_filter / node_key, False) for node_key in project["workbench"]), |
| 418 | + key=lambda x: x[0], |
| 419 | + ) |
0 commit comments