mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 05:26:13 +02:00
Move import to be standalone command to reduce clutter in cli.py
This commit is contained in:
parent
1d5c065b1f
commit
41d06bfc65
9 changed files with 113 additions and 84 deletions
|
@ -136,6 +136,40 @@ Feature: Basic reading and writing to a journal
|
|||
Then the output should contain "jrnl"
|
||||
And the output should contain "Python"
|
||||
|
||||
Scenario: Version warning appears for versions below 3.7
|
||||
When we run "jrnl --diagnostic"
|
||||
Then the Python version warning should appear if our version is below 3.7
|
||||
Scenario: --import allows new entry to journal
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl --import" and pipe "[2020-07-05 15:00] Observe and import."
|
||||
And we run "jrnl -1"
|
||||
Then the journal should contain "[2020-07-05 15:00] Observe and import."
|
||||
And the output should contain "Observe and import"
|
||||
|
||||
Scenario: --import allows new large entry to journal
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl --import" and pipe
|
||||
"""
|
||||
[2020-07-05 15:00] Observe and import.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada quis
|
||||
est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus pellentesque augue
|
||||
et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu consequat.
|
||||
Aenean ante ex, elementum ut interdum et, mattis eget lacus. In commodo nulla nec
|
||||
tellus placerat, sed ultricies metus bibendum. Duis eget venenatis erat. In at
|
||||
dolor dui end of entry.
|
||||
"""
|
||||
And we run "jrnl -1"
|
||||
Then the journal should contain "[2020-07-05 15:00] Observe and import."
|
||||
And the output should contain "Observe and import"
|
||||
And the output should contain "Lorem ipsum"
|
||||
And the output should contain "end of entry."
|
||||
|
||||
Scenario: --import allows import of multiple entries to journal
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl --import" and pipe
|
||||
"""
|
||||
[2020-07-05 15:00] Observe and import.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
|
||||
[2020-07-05 15:01] Twice as nice.
|
||||
Sed dignissim sed nisl eu consequat.
|
||||
"""
|
||||
Then the journal should contain "[2020-07-05 15:00] Observe and import."
|
||||
Then the journal should contain "[2020-07-05 15:01] Twice as nice."
|
||||
|
|
|
@ -210,8 +210,12 @@ def run_with_input(context, command, inputs=""):
|
|||
|
||||
|
||||
@when('we run "{command}"')
|
||||
@when('we run "{command}" and pipe')
|
||||
@when('we run "{command}" and pipe "{text}"')
|
||||
@when('we run "{command}" with cache directory "{cache_dir}"')
|
||||
def run(context, command, cache_dir=None):
|
||||
def run(context, command, text="", cache_dir=None):
|
||||
text = text or context.text or ""
|
||||
|
||||
if cache_dir is not None:
|
||||
cache_dir = os.path.join("features", "cache", cache_dir)
|
||||
command = command.format(cache_dir=cache_dir)
|
||||
|
@ -224,7 +228,7 @@ def run(context, command, cache_dir=None):
|
|||
try:
|
||||
with patch("sys.argv", args), patch(
|
||||
"subprocess.call", side_effect=_mock_editor
|
||||
):
|
||||
), patch("sys.stdin.read", side_effect=lambda: text):
|
||||
cli.run(args[1:])
|
||||
context.exit_status = 0
|
||||
except SystemExit as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue