[Test] behave tests pass locally

This commit is contained in:
MinchinWeb 2021-05-16 21:14:45 -06:00
parent 9888d98860
commit e64ca2d5b7
4 changed files with 35 additions and 0 deletions

View file

@ -26,6 +26,7 @@ Feature: Custom formats
| basic_folder | | basic_folder |
| basic_dayone | | basic_dayone |
@skip_no_external_plugins
Scenario Outline: JSON format Scenario Outline: JSON format
Given we use the config "<config>.yaml" Given we use the config "<config>.yaml"
And we use the password "test" if prompted And we use the password "test" if prompted
@ -48,6 +49,7 @@ Feature: Custom formats
| basic_folder | | basic_folder |
| basic_dayone | | basic_dayone |
@skip_no_external_plugins
Scenario: Exporting dayone to json Scenario: Exporting dayone to json
Given we use the config "dayone.yaml" Given we use the config "dayone.yaml"
When we run "jrnl --export json" When we run "jrnl --export json"
@ -91,6 +93,7 @@ Feature: Custom formats
| basic_folder | | basic_folder |
| basic_dayone | | basic_dayone |
@skip_no_external_plugins
Scenario Outline: Exporting using filters should only export parts of the journal Scenario Outline: Exporting using filters should only export parts of the journal
Given we use the config "<config>.yaml" Given we use the config "<config>.yaml"
And we use the password "test" if prompted And we use the password "test" if prompted

View file

@ -64,3 +64,23 @@ Feature: Functionality of Importer and Exporter Plugins
| plugin_name | version | source | type | filename | | plugin_name | version | source | type | filename |
| json | <pyproject.toml version> | plugins | exporter | json | | json | <pyproject.toml version> | plugins | exporter | json |
| txt | <pyproject.toml version> | plugins | exporter | text | | txt | <pyproject.toml version> | plugins | exporter | text |
@skip_only_with_external_plugins
Scenario Outline: JSON format
Given we use the config "<config>.yaml"
And we use the password "test" if prompted
When we run "jrnl --format json"
Then we should get no error
And the output should be parsable as json
And "entries" in the json output should have 3 elements
And entry 1 should not have an array "tags"
And entry 2 should not have an array "tags"
And entry 3 should not have an array "tags"
Examples: configs
| config |
| basic_onefile |
| basic_encrypted |
| basic_folder |
| basic_dayone |

View file

@ -89,6 +89,16 @@ def entry_array_count(context, entry_number, name, items_number):
assert len(out_json["entries"][entry_number - 1][name]) == items_number assert len(out_json["entries"][entry_number - 1][name]) == items_number
@then(
'entry {entry_number:d} should not have an array "{name}"'
)
def entry_not_array_item(context, entry_number, name):
# note that entry_number is 1-indexed.
out = context.stdout_capture.getvalue()
out_json = json.loads(out)
assert (name not in out_json["entries"][entry_number - 1])
@then("the output should be a valid XML string") @then("the output should be a valid XML string")
def assert_valid_xml_string(context): def assert_valid_xml_string(context):
output = context.stdout_capture.getvalue() output = context.stdout_capture.getvalue()

View file

@ -183,6 +183,8 @@ Feature: Writing new entries.
And we run "jrnl -until 1980" And we run "jrnl -until 1980"
Then the output should be "1979-05-01 09:00 Being born hurts." Then the output should be "1979-05-01 09:00 Being born hurts."
# the testing plugins override the JSON exporter
@skip_no_external_plugins
Scenario: Writing into Dayone adds extended metadata Scenario: Writing into Dayone adds extended metadata
Given we use the config "dayone.yaml" Given we use the config "dayone.yaml"
When we run "jrnl 01 may 1979: Being born hurts." When we run "jrnl 01 may 1979: Being born hurts."