Skip to content

Commit ee32925

Browse files
Merge pull request #1802 from dandi/copilot/sub-pr-1792
Fix test assertions for enhanced move operation error messages
2 parents fb33e99 + 750ddfa commit ee32925

1 file changed

Lines changed: 30 additions & 13 deletions

File tree

dandi/tests/test_move.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,15 @@ def test_move_nonexistent_src(
374374
work_on=work_on,
375375
dandi_instance=moving_dandiset.api.instance_id,
376376
)
377-
assert (
378-
str(excinfo.value)
379-
== f"No asset at {'remote' if work_on == 'remote' else 'local'} path 'subdir1/avocado.txt'"
377+
asset_type = "remote" if work_on == MoveWorkOn.REMOTE else "local"
378+
assert str(excinfo.value) == (
379+
f"No asset at {asset_type} path 'subdir1/avocado.txt'. "
380+
+ (
381+
"Verify the path is correct and the asset exists on the server. "
382+
"Use 'dandi ls' to list available assets."
383+
if work_on == MoveWorkOn.REMOTE
384+
else "Verify the path is correct and the file exists locally."
385+
)
380386
)
381387
check_assets(moving_dandiset, starting_assets, work_on, {})
382388

@@ -400,9 +406,10 @@ def test_move_file_slash_src(
400406
work_on=work_on,
401407
dandi_instance=moving_dandiset.api.instance_id,
402408
)
403-
assert (
404-
str(excinfo.value)
405-
== f"{'Remote' if work_on == 'remote' else 'Local'} path 'subdir1/apple.txt/' is a file"
409+
path_type = "Remote" if work_on == MoveWorkOn.REMOTE else "Local"
410+
assert str(excinfo.value) == (
411+
f"{path_type} path 'subdir1/apple.txt/' is a file but a directory "
412+
"was expected. Use a path ending with '/' for directories."
406413
)
407414
check_assets(moving_dandiset, starting_assets, work_on, {})
408415

@@ -425,9 +432,10 @@ def test_move_file_slash_dest(
425432
work_on=work_on,
426433
dandi_instance=moving_dandiset.api.instance_id,
427434
)
428-
assert (
429-
str(excinfo.value)
430-
== f"{'Remote' if work_on == 'remote' else 'Local'} path 'subdir1/apple.txt/' is a file"
435+
path_type = "Remote" if work_on == MoveWorkOn.REMOTE else "Local"
436+
assert str(excinfo.value) == (
437+
f"{path_type} path 'subdir1/apple.txt/' is a file but a directory "
438+
"was expected. Use a path ending with '/' for directories."
431439
)
432440
check_assets(moving_dandiset, starting_assets, work_on, {})
433441

@@ -593,9 +601,14 @@ def test_move_from_subdir_abspaths(
593601
work_on=work_on,
594602
dandi_instance=moving_dandiset.api.instance_id,
595603
)
596-
assert (
597-
str(excinfo.value)
598-
== f"No asset at {'remote' if work_on == 'remote' else 'local'} path 'file.txt'"
604+
assert str(excinfo.value) == (
605+
f"No asset at {'remote' if work_on == MoveWorkOn.REMOTE else 'local'} path 'file.txt'. "
606+
+ (
607+
"Verify the path is correct and the asset exists on the server. "
608+
"Use 'dandi ls' to list available assets."
609+
if work_on == MoveWorkOn.REMOTE
610+
else "Verify the path is correct and the file exists locally."
611+
)
599612
)
600613
check_assets(moving_dandiset, starting_assets, work_on, {})
601614

@@ -619,7 +632,11 @@ def test_move_from_subdir_as_dot(
619632
dandi_instance=moving_dandiset.api.instance_id,
620633
devel_debug=True,
621634
)
622-
assert str(excinfo.value) == "Cannot move current working directory"
635+
assert (
636+
str(excinfo.value)
637+
== "Cannot move current working directory. "
638+
"Change to a different directory before moving this location."
639+
)
623640
check_assets(moving_dandiset, starting_assets, work_on, {})
624641

625642

0 commit comments

Comments
 (0)