11"""Steps for the 'dfetch add' feature tests."""
22
3- # pylint: disable=function-redefined, missing-function-docstring, import-error, not-callable
4- # pyright: reportRedeclaration=false, reportAttributeAccessIssue=false, reportCallIssue=false
3+ # pylint: disable=missing-function-docstring, import-error, not-callable
4+ # pyright: reportAttributeAccessIssue=false, reportCallIssue=false
55
66from collections import deque
77from unittest .mock import patch
@@ -17,18 +17,6 @@ def _resolve_url(url: str, context) -> str:
1717 return url .replace ("some-remote-server" , f"file:///{ remote_server_path (context )} " )
1818
1919
20- @when ('I add "{remote_url}"' )
21- def step_impl (context , remote_url ):
22- url = _resolve_url (remote_url , context )
23- call_command (context , ["add" , url ])
24-
25-
26- @when ('I add "{remote_url}" with options "{options}"' )
27- def step_impl (context , remote_url , options ):
28- url = _resolve_url (remote_url , context )
29- call_command (context , ["add" ] + options .split () + [url ])
30-
31-
3220def _run_interactive_add (context , cmd : list [str ]) -> None :
3321 """Run an interactive add command, driving prompts from ``context.table``."""
3422 # Parse the answer table into three buckets:
@@ -70,20 +58,16 @@ def _auto_prompt(_prompt: str, **kwargs) -> str: # type: ignore[return]
7058 call_command (context , cmd )
7159
7260
73- @when ('I interactively add "{remote_url}" with options "{options}" and inputs' )
74- def step_impl (context , remote_url , options ):
75- url = _resolve_url (remote_url , context )
76- _run_interactive_add (context , ["add" , "--interactive" ] + options .split () + [url ])
77-
78-
79- @when ('I interactively add "{remote_url}" with inputs' )
80- def step_impl (context , remote_url ):
81- url = _resolve_url (remote_url , context )
82- _run_interactive_add (context , ["add" , "--interactive" , url ])
61+ @when ('I run "dfetch {add_args}" with inputs' )
62+ def step_interactive_add (context , add_args ):
63+ resolved = add_args .replace (
64+ "some-remote-server" , f"file:///{ remote_server_path (context )} "
65+ )
66+ _run_interactive_add (context , resolved .split ())
8367
8468
8569@then ("the manifest '{name}' contains entry" )
86- def step_impl (context , name ):
70+ def step_manifest_contains_entry (context , name ):
8771 expected = apply_manifest_substitutions (context , context .text )
8872 with open (name , "r" , encoding = "utf-8" ) as fh :
8973 actual = fh .read ()
@@ -105,15 +89,15 @@ def step_impl(context, name):
10589
10690
10791@then ('the command fails with "{message}"' )
108- def step_impl (context , message ):
92+ def step_command_fails_with (context , message ):
10993 assert context .cmd_returncode != 0 , "Expected command to fail, but it succeeded"
11094 assert (
11195 message in context .cmd_output
11296 ), f"Expected error message '{ message } ' not found in output:\n { context .cmd_output } "
11397
11498
11599@then ("the manifest '{name}' does not contain '{text}'" )
116- def step_impl (_ , name , text ):
100+ def step_manifest_not_contain (_ , name , text ):
117101 with open (name , "r" , encoding = "utf-8" ) as fh :
118102 actual = fh .read ()
119103
0 commit comments