From 0c6cb58d2504f7e8efd16c0b36c0f9fa3d899dcd Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 25 Sep 2021 17:28:20 -0700 Subject: [PATCH] add 'the editor should not have been called' step --- tests/bdd/features/override.feature | 1 + tests/lib/then_steps.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/bdd/features/override.feature b/tests/bdd/features/override.feature index c41f2225..ca8cb2a4 100644 --- a/tests/bdd/features/override.feature +++ b/tests/bdd/features/override.feature @@ -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 diff --git a/tests/lib/then_steps.py b/tests/lib/then_steps.py index b56c203f..bdda24c7 100644 --- a/tests/lib/then_steps.py +++ b/tests/lib/then_steps.py @@ -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): - assert cli_run["mocks"]["editor"].called +@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)