add 'the editor should not have been called' step

This commit is contained in:
Jonathan Wren 2021-09-25 17:28:20 -07:00
parent 76840b4d2c
commit 0c6cb58d25
2 changed files with 14 additions and 4 deletions

View file

@ -5,6 +5,7 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
And we use the password "test" if prompted
When we run "jrnl --config-override editor ''"
Then the stdin prompt should have been called
And the editor should not have been called
Scenario: Postconfig commands with overrides

View file

@ -301,10 +301,19 @@ def count_elements(number, item, cli_run):
assert len(xml_tree.findall(".//" + item)) == number
@then(parse("the editor should have been called"))
@then(parse("the editor should have been called with {num_args} arguments"))
def count_editor_args(num_args, cli_run, editor_state):
@then(parse("the editor {should_or_should_not} have been called"))
@then(
parse(
"the editor {should_or_should_not} have been called with {num_args} arguments"
)
)
def count_editor_args(num_args, cli_run, editor_state, should_or_should_not):
we_should = parse_should_or_should_not(should_or_should_not)
if we_should:
assert cli_run["mocks"]["editor"].called
else:
assert not cli_run["mocks"]["editor"].called
if isinstance(num_args, int):
assert len(editor_state["command"]) == int(num_args)