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:
Jonathan Wren 2023-03-25 12:32:25 -07:00 committed by GitHub
parent b3c6f90a35
commit 3c923ae943
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 474 additions and 265 deletions

View file

@ -11,6 +11,8 @@ Feature: Delete entries from journal
N
N
Y
Then the error output should contain "3 entries found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-29 11:11 Entry the first.
@ -28,6 +30,7 @@ Feature: Delete entries from journal
Given we use the config "<config_file>"
When we run "jrnl --delete -n 1" and enter
N
Then the error output should not contain "deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-29 11:11 Entry the first.
@ -44,7 +47,7 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with nonsense input deletes nothing (issue #932)
Given we use the config "<config_file>"
When we run "jrnl --delete asdfasdf"
Then the output should contain "No entries to delete"
Then the error output should contain "No entries to delete"
When we run "jrnl -99 --short"
Then the output should be
2020-08-29 11:11 Entry the first.
@ -62,6 +65,8 @@ Feature: Delete entries from journal
Given we use the config "<config_file>"
When we run "jrnl --delete @ipsum" and enter
Y
Then the error output should contain "1 entry found"
Then the error output should contain "1 entry deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-31 14:32 A second entry in what I hope to be a long series.
@ -79,6 +84,8 @@ Feature: Delete entries from journal
When we run "jrnl --delete @ipsum @tagthree" and enter
Y
Y
Then the error output should contain "2 entries found"
And the error output should contain "2 entries deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-31 14:32 A second entry in what I hope to be a long series.
@ -94,6 +101,8 @@ Feature: Delete entries from journal
Given we use the config "<config_file>"
When we run "jrnl --delete -and @tagone @tagtwo" and enter
Y
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-31 14:32 A second entry in what I hope to be a long series.
@ -110,6 +119,8 @@ Feature: Delete entries from journal
Given we use the config "<config_file>"
When we run "jrnl --delete @tagone -not @ipsum" and enter
Y
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-29 11:11 Entry the first.
@ -126,6 +137,8 @@ Feature: Delete entries from journal
Given we use the config "<config_file>"
When we run "jrnl --delete -from 2020-09-01" and enter
Y
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-29 11:11 Entry the first.
@ -143,6 +156,8 @@ Feature: Delete entries from journal
When we run "jrnl --delete -to 2020-08-31" and enter
Y
Y
Then the error output should contain "2 entries found"
And the error output should contain "2 entries deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-09-24 09:14 The third entry finally after weeks without writing.
@ -158,6 +173,7 @@ Feature: Delete entries from journal
Given we use the config "<config_file>"
When we run "jrnl --delete -starred" and enter
Y
Then the error output should contain "1 entry deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-29 11:11 Entry the first.
@ -174,6 +190,8 @@ Feature: Delete entries from journal
Given we use the config "<config_file>"
When we run "jrnl --delete -contains dignissim" and enter
Y
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short"
Then the output should be
2020-08-31 14:32 A second entry in what I hope to be a long series.