mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 05:26:13 +02:00
Allow editing of DayOne entries (#1001)
* add test to repro issue #955 * Allow editing of DayOne entries * Add broken test for Dayone Add test for editing Dayone entries (this test currently fails) Co-authored-by: Jonathan Wren <jonathan@nowandwren.com> * Fix editing logic for DayOneJournal DayOneJournal previously reimplemented Journal._parse inside of DayOneJournal.parse_editable_string, and in doing so caused issues between itself and the class it was inheriting from. This commit fixes the issue by moving the UUID to be in the body of the entry, rather than above it. So, then Journal._parse still finds the correct boundaries between entries, and DayOneJournal then parses the UUID afterward. Co-authored-by: MinchinWeb <w_minchin@hotmail.com> Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
4c2f2861db
commit
a11aa24c7e
5 changed files with 85 additions and 82 deletions
|
@ -101,15 +101,24 @@ def move_up_dir(context, path):
|
|||
os.chdir(path)
|
||||
|
||||
|
||||
@when('we open the editor and enter "{text}"')
|
||||
@when("we open the editor and enter nothing")
|
||||
def open_editor_and_enter(context, text=""):
|
||||
@when("we open the editor and {method}")
|
||||
@when('we open the editor and {method} "{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 ""
|
||||
|
||||
if method == "enter":
|
||||
file_method = "w+"
|
||||
elif method == "append":
|
||||
file_method = "a"
|
||||
else:
|
||||
file_method = "r+"
|
||||
|
||||
def _mock_editor_function(command):
|
||||
context.editor_command = command
|
||||
tmpfile = command[-1]
|
||||
with open(tmpfile, "w+") as f:
|
||||
with open(tmpfile, file_method) as f:
|
||||
f.write(text)
|
||||
|
||||
return tmpfile
|
||||
|
@ -120,7 +129,7 @@ def open_editor_and_enter(context, text=""):
|
|||
patch("subprocess.call", side_effect=_mock_editor_function), \
|
||||
patch("sys.stdin.isatty", return_value=True) \
|
||||
:
|
||||
context.execute_steps('when we run "jrnl"')
|
||||
cli.run(["--edit"])
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@ -209,8 +218,13 @@ def run(context, command, cache_dir=None):
|
|||
|
||||
args = ushlex(command)
|
||||
|
||||
def _mock_editor(command):
|
||||
context.editor_command = command
|
||||
|
||||
try:
|
||||
with patch("sys.argv", args):
|
||||
with patch("sys.argv", args), patch(
|
||||
"subprocess.call", side_effect=_mock_editor
|
||||
):
|
||||
cli.run(args[1:])
|
||||
context.exit_status = 0
|
||||
except SystemExit as e:
|
||||
|
@ -282,7 +296,7 @@ def check_output_version_inline(context):
|
|||
def check_output_inline(context, text=None, text2=None):
|
||||
text = text or context.text
|
||||
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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue