mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-21 05:28:31 +02:00
xml test
This commit is contained in:
parent
e134f0161f
commit
951a4a3dbb
2 changed files with 11 additions and 4 deletions
|
@ -89,6 +89,7 @@ Feature: Exporting a Journal
|
||||||
Then the output should be a valid XML string
|
Then the output should be a valid XML string
|
||||||
And "entries" node in the xml output should have 2 elements
|
And "entries" node in the xml output should have 2 elements
|
||||||
And "tags" in the xml output should contain ["@idea", "@journal", "@dan"]
|
And "tags" in the xml output should contain ["@idea", "@journal", "@dan"]
|
||||||
|
And there should be 7 "tag" elements
|
||||||
|
|
||||||
Scenario: Exporting tags
|
Scenario: Exporting tags
|
||||||
Given we use the config "tags.yaml"
|
Given we use the config "tags.yaml"
|
||||||
|
|
|
@ -60,17 +60,23 @@ def assert_valid_xml_string(context):
|
||||||
assert xml_tree, output
|
assert xml_tree, output
|
||||||
|
|
||||||
|
|
||||||
@then('"entries" node in the xml output should have {number:d} elements')
|
@then('"{item}" node in the xml output should have {number:d} elements')
|
||||||
def assert_xml_output_entries_count(context, number):
|
def assert_xml_output_entries_count(context, item, number):
|
||||||
output = context.stdout_capture.getvalue()
|
output = context.stdout_capture.getvalue()
|
||||||
xml_tree = ElementTree.fromstring(output)
|
xml_tree = ElementTree.fromstring(output)
|
||||||
|
|
||||||
xml_tags = (node.tag for node in xml_tree)
|
xml_tags = (node.tag for node in xml_tree)
|
||||||
assert "entries" in xml_tags, str(list(xml_tags))
|
assert item in xml_tags, str(list(xml_tags))
|
||||||
|
|
||||||
actual_entry_count = len(xml_tree.find("entries"))
|
actual_entry_count = len(xml_tree.find(item))
|
||||||
assert actual_entry_count == number, actual_entry_count
|
assert actual_entry_count == number, actual_entry_count
|
||||||
|
|
||||||
|
@then('there should be {number:d} "{item}" elements')
|
||||||
|
def count_elements(context,number,item):
|
||||||
|
output = context.stdout_capture.getvalue()
|
||||||
|
xml_tree = ElementTree.fromstring(output)
|
||||||
|
assert len(xml_tree.findall(".//"+item))==number
|
||||||
|
|
||||||
|
|
||||||
@then('"tags" in the xml output should contain {expected_tags_json_list}')
|
@then('"tags" in the xml output should contain {expected_tags_json_list}')
|
||||||
def assert_xml_output_tags(context, expected_tags_json_list):
|
def assert_xml_output_tags(context, expected_tags_json_list):
|
||||||
|
|
Loading…
Add table
Reference in a new issue