From 0c8efd5331b0f9d73bb7cee7b44ddc18d76846cb Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 22 May 2021 17:25:40 -0700 Subject: [PATCH] Cleanup last few tests - Misc linting issues - Whitespace cleanup - Entire test suite is now passing - Add misc todo items in comments Co-authored-by: Micah Jerome Ellison --- tests/features/upgrade.feature | 13 ++++++------- tests/step_defs/conftest.py | 8 +++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/features/upgrade.feature b/tests/features/upgrade.feature index bb050fa1..e5714a82 100644 --- a/tests/features/upgrade.feature +++ b/tests/features/upgrade.feature @@ -33,16 +33,15 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x Scenario: Upgrade and parse journals with little endian date format Given we use the config "upgrade_from_195_little_endian_dates.json" - When we run "jrnl -9" and enter "Y" - Then the output should be + When we run "jrnl -9 --short" and enter "Y" + Then the output should contain 10.06.2010 15:00 A life without chocolate is like a bad analogy. 10.06.2013 15:40 He said "[this] is the best time to be alive". Scenario: Upgrade with missing journal Given we use the config "upgrade_from_195_with_missing_journal.json" - When we run "jrnl --list" and enter - Y - Then the error output should contain "Error: features/journals/missing.journal does not exist." + When we run "jrnl --list" and enter "Y" + Then the output should contain "Error: features/journals/missing.journal does not exist." And we should get no error Scenario: Upgrade with missing encrypted journal @@ -50,6 +49,6 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x When we run "jrnl --list" and enter Y bad doggie no biscuit - Then the error output should contain "Error: features/journals/missing.journal does not exist." - And the error output should contain "We're all done" + Then the output should contain "Error: features/journals/missing.journal does not exist." + And the output should contain "We're all done" And we should get no error diff --git a/tests/step_defs/conftest.py b/tests/step_defs/conftest.py index 4f934d31..12eb948c 100644 --- a/tests/step_defs/conftest.py +++ b/tests/step_defs/conftest.py @@ -1,7 +1,6 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -import ast import json import os from datetime import datetime @@ -406,6 +405,7 @@ def we_run( # fmt: off # see: https://github.com/psf/black/issues/664 + # @todo https://docs.python.org/3/library/contextlib.html#contextlib.ExitStack with \ patch("sys.argv", ['jrnl'] + args), \ patch("sys.stdin.read", side_effect=user_input) as mock_stdin, \ @@ -578,7 +578,7 @@ def journal_directory_should_contain(config_data, file_list): @then(parse('journal "{journal_name}" should not exist')) -def journal_directory_should_contain(config_data, journal_name): +def journal_directory_should_not_exist(config_data, journal_name): scoped_config = scope_config(config_data, journal_name) assert not does_directory_contain_files( @@ -723,9 +723,7 @@ def assert_parsed_output_item_count(node_name, number, parsed_output): @then(parse('"{field_name}" in the parsed output should {comparison}\n{expected_keys}')) -def assert_output_field_content( - field_name, comparison, expected_keys, cli_run, parsed_output -): +def assert_output_field_content(field_name, comparison, expected_keys, parsed_output): lang = parsed_output["lang"] obj = parsed_output["obj"] expected_keys = expected_keys.split("\n")