mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 21:18:32 +02:00
Adding broken test
This commit is contained in:
parent
07bacabe8d
commit
4e8418d578
3 changed files with 27 additions and 9 deletions
|
@ -1,10 +1,9 @@
|
||||||
default_hour: 9
|
default_hour: 9
|
||||||
default_minute: 0
|
default_minute: 0
|
||||||
editor: ''
|
editor: noop
|
||||||
template: false
|
template: false
|
||||||
encrypt: false
|
encrypt: false
|
||||||
highlight: true
|
highlight: true
|
||||||
editor: noop
|
|
||||||
journals:
|
journals:
|
||||||
default: features/journals/dayone.dayone
|
default: features/journals/dayone.dayone
|
||||||
linewrap: 80
|
linewrap: 80
|
||||||
|
|
|
@ -81,3 +81,14 @@ Feature: Dayone specific implementation details.
|
||||||
When we run "jrnl --edit"
|
When we run "jrnl --edit"
|
||||||
Then we should get no error
|
Then we should get no error
|
||||||
|
|
||||||
|
Scenario: Editing Dayone entries
|
||||||
|
Given we use the config "dayone.yaml"
|
||||||
|
When we open the editor and append
|
||||||
|
"""
|
||||||
|
Here is the first line.
|
||||||
|
Here is the second line.
|
||||||
|
"""
|
||||||
|
When we run "jrnl -n 5"
|
||||||
|
Then we should get no error
|
||||||
|
and the output should contain "Here is the first line"
|
||||||
|
and the output should contain "Here is the second line"
|
||||||
|
|
|
@ -101,15 +101,24 @@ def move_up_dir(context, path):
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
|
|
||||||
@when('we open the editor and enter "{text}"')
|
@when('we open the editor and {method}')
|
||||||
@when("we open the editor and enter nothing")
|
@when('we open the editor and {method} "{text}"')
|
||||||
def open_editor_and_enter(context, text=""):
|
@when("we open the editor and {method} nothing")
|
||||||
|
@when("we open the editor and {method} nothing")
|
||||||
|
def open_editor_and_enter(context, method, text=""):
|
||||||
text = text or context.text or ""
|
text = text or context.text or ""
|
||||||
|
|
||||||
|
if method == "enter":
|
||||||
|
file_method = "w+"
|
||||||
|
elif method == "append":
|
||||||
|
file_method = "a"
|
||||||
|
else:
|
||||||
|
file_method = "r+"
|
||||||
|
|
||||||
def _mock_editor_function(command):
|
def _mock_editor_function(command):
|
||||||
context.editor_command = command
|
context.editor_command = command
|
||||||
tmpfile = command[-1]
|
tmpfile = command[-1]
|
||||||
with open(tmpfile, "w+") as f:
|
with open(tmpfile, file_method) as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
return tmpfile
|
return tmpfile
|
||||||
|
@ -120,7 +129,7 @@ def open_editor_and_enter(context, text=""):
|
||||||
patch("subprocess.call", side_effect=_mock_editor_function), \
|
patch("subprocess.call", side_effect=_mock_editor_function), \
|
||||||
patch("sys.stdin.isatty", return_value=True) \
|
patch("sys.stdin.isatty", return_value=True) \
|
||||||
:
|
:
|
||||||
context.execute_steps('when we run "jrnl"')
|
cli.run(["--edit"])
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
|
@ -287,8 +296,7 @@ def check_output_version_inline(context):
|
||||||
def check_output_inline(context, text=None, text2=None):
|
def check_output_inline(context, text=None, text2=None):
|
||||||
text = text or context.text
|
text = text or context.text
|
||||||
out = context.stdout_capture.getvalue()
|
out = context.stdout_capture.getvalue()
|
||||||
assert text in out or text2 in out, text or text2
|
assert (text and text in out) or (text2 and text2 in out)
|
||||||
|
|
||||||
|
|
||||||
@then("the error output should contain")
|
@then("the error output should contain")
|
||||||
@then('the error output should contain "{text}"')
|
@then('the error output should contain "{text}"')
|
||||||
|
|
Loading…
Add table
Reference in a new issue