mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-27 21:16:14 +02:00
Allow combinations of --change-time
, --delete
, and --edit
while correctly counting the number of entries affected (#1669)
* Remove search mode conditional that added explicit tag search behavior * Fix failing change-time test by using same method signature as base journal class * Fix user input mock - was not appropriately checking return value * Clean up controller - streamline `run` function in `controller.py` - add debug logging - fix unnecessary import of Journal class (only needed for typing) - standardize summary display across different actions * Add currently-failing test conditions for count messages when changing time and deleting * Don't show summary if no entries found and prevent extra line break when no entries found by short-circuiting display method * Track found entry count and remove incorrect modified stat logic * Track journal entry deletion consistently * Remove unneeded exception when editor is empty and fix test that was testing incorrect message * Correct entry edit modified count test * Track modification of entries with --change-time * Preserve existing behavior when editor is empty but make the message more clear * Reconcile tests with new error message when clearing editor in edit mode * Add found/modified counts to edit tests * Add tests for found count with -n equivalent argument * Test combinations of found/deleted messages when using --delete * Add tests for counting combinations of action arguments (change-time, edit, delete) and for change-time counts. Some are failing and should be investigated * Remove extraneous comment in test * Track added/deleted counts in a register in the Journal class instead of attempting to infer it via controller counting * Add encrypted to more tests * Fix merge conflict typo * Change 'write mode' -> 'append mode' in more places --------- Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
b3c6f90a35
commit
3c923ae943
18 changed files with 474 additions and 265 deletions
|
@ -18,15 +18,17 @@ def random_string():
|
|||
|
||||
|
||||
@pytest.mark.parametrize("export_format", ["pretty", "short"])
|
||||
@mock.patch("builtins.print")
|
||||
@mock.patch("jrnl.controller.Journal.pprint")
|
||||
def test_display_search_results_pretty_short(mock_pprint, mock_print, export_format):
|
||||
def test_display_search_results_pretty_short(export_format):
|
||||
mock_args = parse_args(["--format", export_format])
|
||||
test_journal = mock.Mock(wraps=jrnl.journals.Journal)
|
||||
|
||||
test_journal = jrnl.journals.Journal()
|
||||
test_journal.new_entry("asdf")
|
||||
|
||||
test_journal.pprint = mock.Mock()
|
||||
|
||||
_display_search_results(mock_args, test_journal)
|
||||
|
||||
mock_print.assert_called_once_with(mock_pprint.return_value)
|
||||
test_journal.pprint.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -40,7 +42,9 @@ def test_display_search_results_builtin_plugins(
|
|||
test_filename = random_string
|
||||
mock_args = parse_args(["--format", export_format, "--file", test_filename])
|
||||
|
||||
test_journal = mock.Mock(wraps=jrnl.journals.Journal)
|
||||
test_journal = jrnl.journals.Journal()
|
||||
test_journal.new_entry("asdf")
|
||||
|
||||
mock_export = mock.Mock()
|
||||
mock_exporter.return_value.export = mock_export
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ def build_card_header(datestr):
|
|||
|
||||
class TestFancy:
|
||||
def test_too_small_linewrap(self, datestr):
|
||||
|
||||
journal = "test_journal"
|
||||
content = build_card_header(datestr)
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ def test_get_kv_from_pair():
|
|||
|
||||
class TestDotNotationToList:
|
||||
def test_unpack_dots_to_list(self):
|
||||
|
||||
keys = "a.b.c.d.e.f"
|
||||
keys_list = _convert_dots_to_list(keys)
|
||||
assert len(keys_list) == 6
|
||||
|
|
|
@ -230,7 +230,6 @@ def test_version_alone():
|
|||
|
||||
|
||||
def test_editor_override():
|
||||
|
||||
parsed_args = cli_as_dict('--config-override editor "nano"')
|
||||
assert parsed_args == expected_args(config_override=[["editor", "nano"]])
|
||||
|
||||
|
@ -294,7 +293,6 @@ class TestDeserialization:
|
|||
],
|
||||
)
|
||||
def test_deserialize_multiword_strings(self, input_str):
|
||||
|
||||
runtime_config = make_yaml_valid_dict(input_str)
|
||||
assert runtime_config.__class__ == dict
|
||||
assert input_str[0] in runtime_config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue