mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-05 07:56:14 +02:00
Add test for aborting jrnl entry from editor
This commit is contained in:
parent
2890e33cac
commit
7a90f4076d
5 changed files with 44 additions and 1 deletions
|
@ -20,6 +20,11 @@ Feature: Basic reading and writing to a journal
|
|||
When we run "jrnl -n 1"
|
||||
Then the output should contain "2013-07-23 09:00 A cold and stormy day."
|
||||
|
||||
Scenario: Writing an empty entry from the editor
|
||||
Given we use the config "editor.yaml"
|
||||
When we open the editor and exit
|
||||
Then the output should be empty
|
||||
|
||||
Scenario: Filtering for dates
|
||||
Given we use the config "basic.yaml"
|
||||
When we run "jrnl -on 2013-06-10 --short"
|
||||
|
|
12
features/data/configs/editor.yaml
Normal file
12
features/data/configs/editor.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
default_hour: 9
|
||||
default_minute: 0
|
||||
editor: "vim"
|
||||
encrypt: false
|
||||
highlight: true
|
||||
journals:
|
||||
default: features/journals/simple.journal
|
||||
linewrap: 80
|
||||
tagsymbols: "@"
|
||||
template: false
|
||||
timeformat: "%Y-%m-%d %H:%M"
|
||||
indent_character: "|"
|
|
@ -6,6 +6,7 @@ from jrnl import cli, install, Journal, util, plugins
|
|||
from jrnl import __version__
|
||||
from dateutil import parser as date_parser
|
||||
from collections import defaultdict
|
||||
import mock
|
||||
import os
|
||||
import json
|
||||
import yaml
|
||||
|
@ -27,6 +28,7 @@ class TestKeyring(keyring.backend.KeyringBackend):
|
|||
def delete_password(self, servicename, username, password):
|
||||
self.keys[servicename][username] = None
|
||||
|
||||
|
||||
# set the keyring for keyring lib
|
||||
keyring.set_keyring(TestKeyring())
|
||||
|
||||
|
@ -73,6 +75,12 @@ def set_config(context, config_file):
|
|||
cf.write("version: {}".format(__version__))
|
||||
|
||||
|
||||
@when('we open the editor and exit')
|
||||
@mock.patch('jrnl.util.get_text_from_editor', return_value="")
|
||||
def open_editor_and_exit_without_entering_text(context, dead_param_to_satisfy_behave):
|
||||
run(context, "jrnl")
|
||||
|
||||
|
||||
@when('we run "{command}" and enter')
|
||||
@when('we run "{command}" and enter "{inputs}"')
|
||||
def run_with_input(context, command, inputs=None):
|
||||
|
@ -166,6 +174,11 @@ def check_json_output_path(context, path, value):
|
|||
assert struct == value, struct
|
||||
|
||||
|
||||
@then('the output should be empty')
|
||||
def check_empty_output(context, text=None):
|
||||
assert (text or context.text) is None
|
||||
|
||||
|
||||
@then('the output should be')
|
||||
@then('the output should be "{text}"')
|
||||
def check_output(context, text=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue