mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
update tests ith better verifications
This commit is contained in:
parent
8ea258c544
commit
3b7e05c69f
1 changed files with 7 additions and 16 deletions
|
@ -71,8 +71,8 @@ def config_override(context, key_as_dots: str, override_value: str):
|
||||||
@then("the editor {editor} should have been called")
|
@then("the editor {editor} should have been called")
|
||||||
def editor_override(context, editor):
|
def editor_override(context, editor):
|
||||||
def _mock_write_in_editor(config):
|
def _mock_write_in_editor(config):
|
||||||
editor = config["editor"]
|
editor = config['editor']
|
||||||
journal = "features/journals/journal.jrnl"
|
journal = 'features/journals/journal.jrnl'
|
||||||
context.tmpfile = journal
|
context.tmpfile = journal
|
||||||
print("%s has been launched" % editor)
|
print("%s has been launched" % editor)
|
||||||
return journal
|
return journal
|
||||||
|
@ -101,20 +101,11 @@ def editor_override(context, editor):
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
@then("the stdin prompt must be launched")
|
try:
|
||||||
def override_editor_to_use_stdin(context):
|
with \
|
||||||
|
mock.patch('sys.stdin.read', return_value='Zwei peanuts walk into a bar und one of zem was a-salted')as mock_stdin_read, \
|
||||||
try:
|
mock.patch("jrnl.install.load_or_install_jrnl", return_value=context.cfg), \
|
||||||
with mock.patch(
|
mock.patch("jrnl.Journal.open_journal", spec=False, return_value='features/journals/journal.jrnl'):
|
||||||
"sys.stdin.read",
|
|
||||||
return_value="Zwei peanuts walk into a bar und one of zem was a-salted",
|
|
||||||
) as mock_stdin_read, mock.patch(
|
|
||||||
"jrnl.install.load_or_install_jrnl", return_value=context.cfg
|
|
||||||
), mock.patch(
|
|
||||||
"jrnl.Journal.open_journal",
|
|
||||||
spec=False,
|
|
||||||
return_value="features/journals/journal.jrnl",
|
|
||||||
):
|
|
||||||
run(context.parser)
|
run(context.parser)
|
||||||
context.exit_status = 0
|
context.exit_status = 0
|
||||||
mock_stdin_read.assert_called_once()
|
mock_stdin_read.assert_called_once()
|
||||||
|
|
Loading…
Add table
Reference in a new issue