mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-11 17:46:12 +02:00
Merge branch 'develop' into change-cwd-bug
This commit is contained in:
commit
15ad02dc85
15 changed files with 261 additions and 35 deletions
|
@ -114,6 +114,12 @@ Feature: Basic reading and writing to a journal
|
|||
"""
|
||||
And we should get no error
|
||||
|
||||
Scenario: Journal directory does not exist
|
||||
Given we use the config "missing_directory.yaml"
|
||||
When we run "jrnl Life is good"
|
||||
and we run "jrnl -n 1"
|
||||
Then the output should contain "Life is good"
|
||||
|
||||
Scenario: Installation with relative journal and referencing from another folder
|
||||
Given we use the config "missingconfig"
|
||||
When we run "jrnl hello world" and enter
|
||||
|
|
|
@ -63,3 +63,15 @@ Feature: Dayone specific implementation details.
|
|||
Then we should get no error
|
||||
and the output should be parsable as json
|
||||
and the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1"
|
||||
|
||||
Scenario: Writing into Dayone adds extended metadata
|
||||
Given we use the config "dayone.yaml"
|
||||
When we run "jrnl 01 may 1979: Being born hurts."
|
||||
and we run "jrnl --export json"
|
||||
Then "entries" in the json output should have 5 elements
|
||||
and the json output should contain entries.0.creator.software_agent
|
||||
and the json output should contain entries.0.creator.os_agent
|
||||
and the json output should contain entries.0.creator.host_name
|
||||
and the json output should contain entries.0.creator.generation_date
|
||||
and the json output should contain entries.0.creator.device_agent
|
||||
and "entries.0.creator.software_agent" in the json output should contain "jrnl"
|
||||
|
|
|
@ -55,3 +55,27 @@
|
|||
Then the config for journal "simple" should have "encrypt" set to "bool:True"
|
||||
When we run "jrnl simple -n 1"
|
||||
Then the output should contain "2013-06-10 15:40 Life is good"
|
||||
|
||||
Scenario: Encrypt journal with no keyring backend and do not store in keyring
|
||||
Given we use the config "basic.yaml"
|
||||
When we disable the keychain
|
||||
and we run "jrnl test entry"
|
||||
and we run "jrnl --encrypt" and enter
|
||||
"""
|
||||
password
|
||||
password
|
||||
n
|
||||
"""
|
||||
Then we should get no error
|
||||
|
||||
Scenario: Encrypt journal with no keyring backend and do store in keyring
|
||||
Given we use the config "basic.yaml"
|
||||
When we disable the keychain
|
||||
and we run "jrnl test entry"
|
||||
and we run "jrnl --encrypt" and enter
|
||||
"""
|
||||
password
|
||||
password
|
||||
y
|
||||
"""
|
||||
Then we should get no error
|
||||
|
|
|
@ -41,6 +41,22 @@ class TestKeyring(keyring.backend.KeyringBackend):
|
|||
self.keys[servicename][username] = None
|
||||
|
||||
|
||||
class NoKeyring(keyring.backend.KeyringBackend):
|
||||
"""A keyring that simulated an environment with no keyring backend."""
|
||||
|
||||
priority = 2
|
||||
keys = defaultdict(dict)
|
||||
|
||||
def set_password(self, servicename, username, password):
|
||||
raise keyring.errors.NoKeyringError
|
||||
|
||||
def get_password(self, servicename, username):
|
||||
raise keyring.errors.NoKeyringError
|
||||
|
||||
def delete_password(self, servicename, username):
|
||||
raise keyring.errors.NoKeyringError
|
||||
|
||||
|
||||
# set the keyring for keyring lib
|
||||
keyring.set_keyring(TestKeyring())
|
||||
|
||||
|
@ -213,6 +229,11 @@ def set_keychain(context, journal, password):
|
|||
keyring.set_password("jrnl", journal, password)
|
||||
|
||||
|
||||
@when("we disable the keychain")
|
||||
def disable_keychain(context):
|
||||
keyring.core.set_keyring(NoKeyring())
|
||||
|
||||
|
||||
@then("we should get an error")
|
||||
def has_error(context):
|
||||
assert context.exit_status != 0, context.exit_status
|
||||
|
|
|
@ -32,13 +32,21 @@ def check_output_field_not_key(context, field, key):
|
|||
@then('"{field}" in the json output should contain "{key}"')
|
||||
def check_output_field_key(context, field, key):
|
||||
out = context.stdout_capture.getvalue()
|
||||
out_json = json.loads(out)
|
||||
assert field in out_json
|
||||
assert key in out_json[field]
|
||||
struct = json.loads(out)
|
||||
|
||||
for node in field.split("."):
|
||||
try:
|
||||
struct = struct[int(node)]
|
||||
except ValueError:
|
||||
assert node in struct
|
||||
struct = struct[node]
|
||||
|
||||
assert key in struct
|
||||
|
||||
|
||||
@then("the json output should contain {path}")
|
||||
@then('the json output should contain {path} = "{value}"')
|
||||
def check_json_output_path(context, path, value):
|
||||
def check_json_output_path(context, path, value=None):
|
||||
""" E.g.
|
||||
the json output should contain entries.0.title = "hello"
|
||||
"""
|
||||
|
@ -50,7 +58,11 @@ def check_json_output_path(context, path, value):
|
|||
struct = struct[int(node)]
|
||||
except ValueError:
|
||||
struct = struct[node]
|
||||
assert struct == value, struct
|
||||
|
||||
if value is not None:
|
||||
assert struct == value, struct
|
||||
else:
|
||||
assert struct is not None
|
||||
|
||||
|
||||
@then("the output should be a valid XML string")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue