1111from collections .abc import Awaitable , Callable
1212from pathlib import Path
1313from typing import Any , TypeAlias
14+ from urllib .parse import quote
1415
1516import httpx
1617import pytest
@@ -387,16 +388,30 @@ async def test_list_paths_with_display_name_containing_slashes(
387388 sqlalchemy_async_engine : AsyncEngine ,
388389):
389390 project , list_of_files = with_random_project_with_files
390- name_with_slashes = "something with/ a slash"
391+ project_name_with_slashes = "soméà$èq¨thing with/ slas/h/es/"
392+ node_name_with_non_ascii = "my node / is not ascii: éàèù"
393+ # adjust project to contain "difficult" characters
391394 async with sqlalchemy_async_engine .begin () as conn :
392395 result = await conn .execute (
393396 sa .update (projects )
394397 .where (projects .c .uuid == project ["uuid" ])
395- .values (name = name_with_slashes )
396- .returning (sa .literal_column (f"{ projects .c .name } " ))
398+ .values (name = project_name_with_slashes )
399+ .returning (sa .literal_column (f"{ projects .c .name } , { projects . c . workbench } " ))
397400 )
398401 row = result .one ()
399- assert row [0 ] == name_with_slashes
402+ assert row .name == project_name_with_slashes
403+ project_workbench = row .workbench
404+ assert len (project_workbench ) == 1
405+ node = next (iter (project_workbench .values ()))
406+ node ["label" ] = node_name_with_non_ascii
407+ result = await conn .execute (
408+ sa .update (projects )
409+ .where (projects .c .uuid == project ["uuid" ])
410+ .values (workbench = project_workbench )
411+ .returning (sa .literal_column (f"{ projects .c .name } , { projects .c .workbench } " ))
412+ )
413+ row = result .one ()
414+
400415 # ls the root
401416 file_filter = None
402417 expected_paths = [(Path (project ["uuid" ]), False )]
@@ -410,10 +425,27 @@ async def test_list_paths_with_display_name_containing_slashes(
410425 expected_paths = expected_paths ,
411426 )
412427
413- assert page_of_paths .items [0 ].display_path == Path (name_with_slashes )
428+ assert page_of_paths .items [0 ].display_path == Path (
429+ quote (project_name_with_slashes , safe = "" )
430+ ), "display path parts should be url encoded"
414431
432+ # ls the nodes to ensure / is still there between project and node
415433 file_filter = Path (project ["uuid" ])
416434 expected_paths = sorted (
417435 ((file_filter / node_key , False ) for node_key in project ["workbench" ]),
418436 key = lambda x : x [0 ],
419437 )
438+ assert len (expected_paths ) == 1 , "test configuration problem"
439+ page_of_paths = await _assert_list_paths (
440+ initialized_app ,
441+ client ,
442+ location_id ,
443+ user_id ,
444+ file_filter = file_filter ,
445+ expected_paths = expected_paths ,
446+ )
447+ assert page_of_paths .items [0 ].display_path == Path (
448+ quote (project_name_with_slashes , safe = "" )
449+ ) / quote (
450+ node_name_with_non_ascii , safe = ""
451+ ), "display path parts should be url encoded"
0 commit comments