mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Tests for #333
This commit is contained in:
parent
aae0fc21b6
commit
6e52b5eb70
3 changed files with 27 additions and 0 deletions
5
features/data/journals/simple.journal
Normal file
5
features/data/journals/simple.journal
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[2013-06-09 15:39] My first entry.
|
||||||
|
Everything is alright
|
||||||
|
|
||||||
|
[2013-06-10 15:40] Life is good.
|
||||||
|
But I'm better.
|
|
@ -20,3 +20,9 @@ Feature: Exporting a Journal
|
||||||
and "tags" in the json output should contain "@journal"
|
and "tags" in the json output should contain "@journal"
|
||||||
and "tags" in the json output should not contain "@dan"
|
and "tags" in the json output should not contain "@dan"
|
||||||
|
|
||||||
|
Scenario: Exporting dayone to json
|
||||||
|
Given we use the config "dayone.yaml"
|
||||||
|
When we run "jrnl --export json"
|
||||||
|
Then we should get no error
|
||||||
|
and the output should be parsable as json
|
||||||
|
and the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1"
|
||||||
|
|
|
@ -126,6 +126,22 @@ def check_output_field_key(context, field, key):
|
||||||
assert key in out_json[field]
|
assert key in out_json[field]
|
||||||
|
|
||||||
|
|
||||||
|
@then('the json output should contain {path} = "{value}"')
|
||||||
|
def check_json_output_path(context, path, value):
|
||||||
|
""" E.g.
|
||||||
|
the json output should contain entries.0.title = "hello"
|
||||||
|
"""
|
||||||
|
out = context.stdout_capture.getvalue()
|
||||||
|
struct = json.loads(out)
|
||||||
|
|
||||||
|
for node in path.split('.'):
|
||||||
|
try:
|
||||||
|
struct = struct[int(node)]
|
||||||
|
except ValueError:
|
||||||
|
struct = struct[node]
|
||||||
|
assert struct == value, struct
|
||||||
|
|
||||||
|
|
||||||
@then('the output should be')
|
@then('the output should be')
|
||||||
@then('the output should be "{text}"')
|
@then('the output should be "{text}"')
|
||||||
def check_output(context, text=None):
|
def check_output(context, text=None):
|
||||||
|
|
Loading…
Add table
Reference in a new issue