diff --git a/tests/features/password.feature b/tests/features/password.feature index a5cbb0e1..23287b7c 100644 --- a/tests/features/password.feature +++ b/tests/features/password.feature @@ -77,3 +77,15 @@ Feature: Using the installed keyring 2013-06-09 15:39 My first entry. 2013-06-10 15:40 Life is good. + + Scenario: Open encrypted journal when keyring exists but fails + # This should ask the user for the password after the keyring fails + Given we use the config "encrypted.yaml" + And we have a failed keyring + And we use the password "bad doggie no biscuit" if prompted + When we run "jrnl -n 1" + Then we should get no error + And we should be prompted for a password + And the output should contain "Failed to retrieve keyring" + And the output should contain "2013-06-10 15:40 Life is good" + diff --git a/tests/step_defs/conftest.py b/tests/step_defs/conftest.py index c1046ef3..e15f265f 100644 --- a/tests/step_defs/conftest.py +++ b/tests/step_defs/conftest.py @@ -149,8 +149,8 @@ def journal_name(): @fixture -def output_to_error(): - return False +def which_output_stream(): + return None # ----- STEPS ----- # @@ -256,13 +256,21 @@ def output_should_match(regex, cli_run): @then(parse("the output should contain\n{output}")) @then(parse('the output should contain "{output}"')) @then('the output should contain ""') -@then(parse("the {output_to_error} output should contain\n{output}")) -@then(parse('the {output_to_error} output should contain "{output}"')) -def output_should_contain(output, output_to_error, cli_run): - assert output and ( - (output_to_error and output in cli_run["stderr"]) - or (not output_to_error and output in cli_run["stdout"]) - ) +@then(parse("the {which_output_stream} output should contain\n{output}")) +@then(parse('the {which_output_stream} output should contain "{output}"')) +def output_should_contain(output, which_output_stream, cli_run): + assert output + if which_output_stream is None: + assert (output in cli_run["stdout"]) or (output in cli_run["stderr"]) + + elif which_output_stream == "standard": + assert output in cli_run["stdout"] + + elif which_output_stream == "error": + assert output in cli_run["stderr"] + + else: + assert output in cli_run[which_output_stream] @then(parse("the output should not contain\n{output}"))