Skip to content

Commit 3eacf30

Browse files
committed
test complete
1 parent cdabc90 commit 3eacf30

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

services/storage/tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,5 @@ async def with_random_project_with_files(
846846
],
847847
],
848848
project_params: ProjectWithFilesParams,
849-
faker: Faker,
850849
) -> tuple[dict[str, Any], dict[NodeID, dict[SimcoreS3FileID, FileIDDict]],]:
851850
return await random_project_with_files(project_params)

services/storage/tests/unit/test_handlers_paths.py

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import httpx
1616
import pytest
17-
from faker import Faker
17+
import sqlalchemy as sa
1818
from fastapi import FastAPI, status
1919
from fastapi_pagination.cursor import CursorPage
2020
from models_library.api_schemas_storage.storage_schemas import PathMetaDataGet
@@ -24,6 +24,8 @@
2424
from pytest_simcore.helpers.fastapi import url_from_operation_id
2525
from pytest_simcore.helpers.httpx_assert_checks import assert_status
2626
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
2729

2830
pytest_simcore_core_services_selection = ["postgres"]
2931
pytest_simcore_ops_services_selection = ["adminer"]
@@ -143,7 +145,6 @@ async def test_list_paths_pagination(
143145
dict[str, Any],
144146
dict[NodeID, dict[SimcoreS3FileID, FileIDDict]],
145147
],
146-
faker: Faker,
147148
):
148149
project, list_of_files = with_random_project_with_files
149150
num_nodes = len(list(project["workbench"]))
@@ -361,3 +362,58 @@ async def test_list_paths(
361362
expected_paths=expected_paths,
362363
check_total=False,
363364
)
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

Comments
 (0)