mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Add some functioning delete tests
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
This commit is contained in:
parent
7ccadebca0
commit
8754837f15
3 changed files with 45 additions and 210 deletions
|
@ -1,229 +1,53 @@
|
||||||
Feature: Delete entries from journal
|
Feature: Delete entries from journal
|
||||||
Scenario Outline: Delete flag allows deletion of single entry
|
Scenario Outline: Delete flag allows deletion of single entry
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl -1"
|
When we run "jrnl -1"
|
||||||
Then the output should contain "2020-09-24 09:14 The third entry finally"
|
Then the output should contain "2020-09-24 09:14 The third entry finally"
|
||||||
When we run "jrnl --delete" and enter
|
When we run "jrnl --delete" and enter
|
||||||
"""
|
N
|
||||||
N
|
N
|
||||||
N
|
Y
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
2020-08-29 11:11 Entry the first.
|
||||||
2020-08-29 11:11 Entry the first.
|
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
||||||
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
Examples: Configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
# | basic_folder | @todo
|
# | basic_folder.yaml | @todo
|
||||||
# | basic_dayone | @todo
|
# | basic_dayone.yaml | @todo
|
||||||
|
|
||||||
Scenario Outline: Backing out of interactive delete does not change journal
|
Scenario Outline: Backing out of interactive delete does not change journal
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
When we run "jrnl --delete -n 1" and enter
|
When we run "jrnl --delete -n 1" and enter
|
||||||
"""
|
N
|
||||||
N
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
2020-08-29 11:11 Entry the first.
|
||||||
2020-08-29 11:11 Entry the first.
|
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
||||||
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
2020-09-24 09:14 The third entry finally after weeks without writing.
|
||||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
Examples: Configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with nonsense input deletes nothing (issue #932)
|
Scenario Outline: Delete flag with nonsense input deletes nothing (issue #932)
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
When we run "jrnl --delete asdfasdf"
|
When we run "jrnl --delete asdfasdf"
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
2020-08-29 11:11 Entry the first.
|
||||||
2020-08-29 11:11 Entry the first.
|
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
||||||
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
2020-09-24 09:14 The third entry finally after weeks without writing.
|
||||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
Examples: Configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
Scenario Outline: Delete flag with tag only deletes tagged entries
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete @ipsum" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
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.
|
|
||||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with multiple tags deletes all entries matching any of the tags
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete @ipsum @tagthree" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with -and deletes boolean AND of tagged entries
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete -and @tagone @tagtwo" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
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.
|
|
||||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with -not does not delete entries from given tag
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete @tagone -not @ipsum" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -99 --short"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
2020-08-29 11:11 Entry the first.
|
|
||||||
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with -from search operator only deletes entries since that date
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete -from 2020-09-01" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -99 --short"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
2020-08-29 11:11 Entry the first.
|
|
||||||
2020-08-31 14:32 A second entry in what I hope to be a long series.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with -to only deletes entries up to specified date
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete -to 2020-08-31" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -99 --short"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with -starred only deletes starred entries
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete -starred" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -99 --short"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
2020-08-29 11:11 Entry the first.
|
|
||||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
Scenario Outline: Delete flag with -contains only entries containing expression
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
When we run "jrnl --delete -contains dignissim" and enter
|
|
||||||
"""
|
|
||||||
Y
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
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.
|
|
||||||
2020-09-24 09:14 The third entry finally after weeks without writing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: Configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
|
@ -46,6 +46,10 @@ def toml_version(working_dir):
|
||||||
pyproject_contents = toml.load(pyproject)
|
pyproject_contents = toml.load(pyproject)
|
||||||
return pyproject_contents["tool"]["poetry"]["version"]
|
return pyproject_contents["tool"]["poetry"]["version"]
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def password():
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@fixture
|
@fixture
|
||||||
def command():
|
def command():
|
||||||
|
@ -56,7 +60,6 @@ def command():
|
||||||
def user_input():
|
def user_input():
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
# ----- STEPS ----- #
|
# ----- STEPS ----- #
|
||||||
@given(parse('we use the config "{config_file}"'), target_fixture="config_path")
|
@given(parse('we use the config "{config_file}"'), target_fixture="config_path")
|
||||||
@given('we use the config "<config_file>"', target_fixture="config_path")
|
@given('we use the config "<config_file>"', target_fixture="config_path")
|
||||||
|
@ -85,11 +88,17 @@ def we_use_the_config(config_file, temp_dir, working_dir):
|
||||||
return config_dest
|
return config_dest
|
||||||
|
|
||||||
|
|
||||||
|
@given(parse('we use the password "{pw}" if prompted'), target_fixture="password")
|
||||||
|
def use_password_forever(pw):
|
||||||
|
return pw
|
||||||
|
|
||||||
|
|
||||||
@when(parse('we run "jrnl {command}"'))
|
@when(parse('we run "jrnl {command}"'))
|
||||||
@when('we run "jrnl <command>"')
|
@when('we run "jrnl <command>"')
|
||||||
@when('we run "jrnl"')
|
@when('we run "jrnl"')
|
||||||
@when(parse('we run "jrnl" and enter "{user_input}"'))
|
@when(parse('we run "jrnl" and enter "{user_input}"'))
|
||||||
def we_run(command, config_path, user_input, cli_run, capsys):
|
@when(parse('we run "jrnl {command}" and enter\n{user_input}'))
|
||||||
|
def we_run(command, config_path, user_input, cli_run, capsys, password):
|
||||||
args = split_args(command)
|
args = split_args(command)
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
|
@ -97,7 +106,9 @@ def we_run(command, config_path, user_input, cli_run, capsys):
|
||||||
# see: https://github.com/psf/black/issues/664
|
# see: https://github.com/psf/black/issues/664
|
||||||
with \
|
with \
|
||||||
patch("sys.argv", ['jrnl'] + args), \
|
patch("sys.argv", ['jrnl'] + args), \
|
||||||
patch("sys.stdin.read", return_value=user_input) as mock_read, \
|
patch("sys.stdin.read", side_effect=user_input.splitlines()) as mock_read, \
|
||||||
|
patch("builtins.input", side_effect=user_input.splitlines()) as mock_read, \
|
||||||
|
patch("getpass.getpass", side_effect=password.splitlines()) as mock_getpass, \
|
||||||
patch("jrnl.install.get_config_path", return_value=config_path), \
|
patch("jrnl.install.get_config_path", return_value=config_path), \
|
||||||
patch("jrnl.config.get_config_path", return_value=config_path) \
|
patch("jrnl.config.get_config_path", return_value=config_path) \
|
||||||
: # @TODO: single point of truth for get_config_path (move from all calls from install to config)
|
: # @TODO: single point of truth for get_config_path (move from all calls from install to config)
|
||||||
|
|
|
@ -3,7 +3,7 @@ from pytest_bdd import scenarios
|
||||||
scenarios("../features/build.feature")
|
scenarios("../features/build.feature")
|
||||||
scenarios("../features/core.feature")
|
scenarios("../features/core.feature")
|
||||||
scenarios("../features/datetime.feature")
|
scenarios("../features/datetime.feature")
|
||||||
# scenarios("../features/delete.feature")
|
scenarios("../features/delete.feature")
|
||||||
# scenarios("../features/encrypt.feature")
|
# scenarios("../features/encrypt.feature")
|
||||||
# scenarios("../features/file_storage.feature")
|
# scenarios("../features/file_storage.feature")
|
||||||
# scenarios("../features/format.feature")
|
# scenarios("../features/format.feature")
|
||||||
|
|
Loading…
Add table
Reference in a new issue