From 8e3a616413264aff1ce3a9d7789410707698f3c5 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 30 May 2020 19:14:23 -0400 Subject: [PATCH] json test --- features/exporting.feature | 2 ++ features/steps/export_steps.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/features/exporting.feature b/features/exporting.feature index ec21432d..da6d8ce9 100644 --- a/features/exporting.feature +++ b/features/exporting.feature @@ -9,6 +9,8 @@ Feature: Exporting a Journal And "tags" in the json output should contain "@idea" And "tags" in the json output should contain "@journal" And "tags" in the json output should contain "@dan" + And entry 1 should have an array called "tags" with 2 elements + And entry 2 should have an array called "tags" with 2 elements Scenario: Exporting using filters should only export parts of the journal Given we use the config "tags.yaml" diff --git a/features/steps/export_steps.py b/features/steps/export_steps.py index a6c47177..c200e9ad 100644 --- a/features/steps/export_steps.py +++ b/features/steps/export_steps.py @@ -52,6 +52,12 @@ def check_json_output_path(context, path, value): struct = struct[node] assert struct == value, struct +@then('entry {entry_number:d} should have an array called "{name}" with {items_number:d} elements') +def entry_array_count(context,entry_number,name,items_number): + #note that entry_number is 1-indexed. + out = context.stdout_capture.getvalue() + out_json = json.loads(out) + assert len(out_json["entries"][entry_number-1][name])==items_number @then("the output should be a valid XML string") def assert_valid_xml_string(context):