mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Add format tests to pytest-bdd
- Implement cache dir fixture and step - Implement various steps to check the cache directory (files contained, etc) Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
e2bb8cf0de
commit
b8c7a7c7e5
3 changed files with 557 additions and 460 deletions
|
@ -1,7 +1,7 @@
|
||||||
Feature: Custom formats
|
Feature: Custom formats
|
||||||
|
|
||||||
Scenario Outline: JSON format
|
Scenario Outline: JSON format
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl --format json"
|
When we run "jrnl --format json"
|
||||||
Then we should get no error
|
Then we should get no error
|
||||||
|
@ -16,11 +16,11 @@ Feature: Custom formats
|
||||||
And entry 3 should have an array "tags" with 2 elements
|
And entry 3 should have an array "tags" with 2 elements
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
Scenario: Exporting dayone to json
|
Scenario: Exporting dayone to json
|
||||||
Given we use the config "dayone.yaml"
|
Given we use the config "dayone.yaml"
|
||||||
|
@ -30,43 +30,41 @@ Feature: Custom formats
|
||||||
And the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1"
|
And the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1"
|
||||||
|
|
||||||
Scenario Outline: Printing a journal that has multiline entries with tags
|
Scenario Outline: Printing a journal that has multiline entries with tags
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl -n 1 @ipsum"
|
When we run "jrnl -n 1 @ipsum"
|
||||||
Then we should get no error
|
Then we should get no error
|
||||||
And the output should be
|
And the output should be
|
||||||
"""
|
2020-08-29 11:11 Entry the first.
|
||||||
2020-08-29 11:11 Entry the first.
|
| Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada
|
||||||
| Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada
|
| quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus
|
||||||
| quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus
|
| pellentesque
|
||||||
| pellentesque
|
| augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu
|
||||||
| augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu
|
| consequat. Aenean ante ex, elementum ut interdum et, mattis eget lacus. In
|
||||||
| consequat. Aenean ante ex, elementum ut interdum et, mattis eget lacus. In
|
| commodo nulla nec tellus placerat, sed ultricies metus bibendum. Duis eget
|
||||||
| commodo nulla nec tellus placerat, sed ultricies metus bibendum. Duis eget
|
| venenatis erat. In at dolor dui. @tagone and maybe also @tagtwo.
|
||||||
| venenatis erat. In at dolor dui. @tagone and maybe also @tagtwo.
|
|
|
||||||
|
|
| Curabitur accumsan nunc ac neque tristique, eleifend faucibus justo
|
||||||
| Curabitur accumsan nunc ac neque tristique, eleifend faucibus justo
|
| ullamcorper. Suspendisse at mattis nunc. Nullam eget lacinia urna. Suspendisse
|
||||||
| ullamcorper. Suspendisse at mattis nunc. Nullam eget lacinia urna. Suspendisse
|
| potenti. Ut urna est, venenatis sed ante in, ultrices congue mi. Maecenas eget
|
||||||
| potenti. Ut urna est, venenatis sed ante in, ultrices congue mi. Maecenas eget
|
| molestie metus. Mauris porttitor dui ornare gravida porta. Quisque sed lectus
|
||||||
| molestie metus. Mauris porttitor dui ornare gravida porta. Quisque sed lectus
|
| hendrerit, lacinia ante eget, vulputate ante. Aliquam vitae erat non felis
|
||||||
| hendrerit, lacinia ante eget, vulputate ante. Aliquam vitae erat non felis
|
| feugiat sagittis. Phasellus quis arcu fringilla, mattis ligula id, vestibulum
|
||||||
| feugiat sagittis. Phasellus quis arcu fringilla, mattis ligula id, vestibulum
|
| urna. Vivamus facilisis leo a mi tincidunt condimentum. Donec eu euismod enim.
|
||||||
| urna. Vivamus facilisis leo a mi tincidunt condimentum. Donec eu euismod enim.
|
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu ligula eget
|
||||||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu ligula eget
|
| velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac
|
||||||
| velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac
|
| porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per
|
||||||
| porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per
|
| conubia nostra, per inceptos himenaeos.
|
||||||
| conubia nostra, per inceptos himenaeos.
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
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_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl -until 'August 2020' --format json"
|
When we run "jrnl -until 'August 2020' --format json"
|
||||||
Then the output should be parsable as json
|
Then the output should be parsable as json
|
||||||
|
@ -80,392 +78,21 @@ Feature: Custom formats
|
||||||
And entry 2 should have an array "tags" with 1 elements
|
And entry 2 should have an array "tags" with 1 elements
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
Scenario Outline: Exporting using custom templates
|
Scenario Outline: Exporting using custom templates
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we load template "sample.template"
|
And we load template "sample.template"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl -1 --format sample"
|
When we run "jrnl -1 --format sample"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
The third entry finally after weeks without writing.
|
||||||
The third entry finally after weeks without writing.
|
----------------------------------------------------
|
||||||
----------------------------------------------------
|
|
||||||
|
|
||||||
I'm so excited about emojis. 💯 🎶 💩
|
|
||||||
|
|
||||||
Donec semper pellentesque iaculis. Nullam cursus et justo sit amet venenatis.
|
|
||||||
Vivamus tempus ex dictum metus vehicula gravida. Aliquam sed sem dolor. Nulla
|
|
||||||
eget ultrices purus. Quisque at nunc at quam pharetra consectetur vitae quis
|
|
||||||
dolor. Fusce ultricies purus eu est feugiat, quis scelerisque nibh malesuada.
|
|
||||||
Quisque egestas semper nibh in hendrerit. Nam finibus ex in mi mattis
|
|
||||||
vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan justo.
|
|
||||||
Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at
|
|
||||||
ante eget fringilla. @tagthree and also @tagone
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
| basic_encrypted |
|
|
||||||
| basic_folder |
|
|
||||||
| basic_dayone |
|
|
||||||
|
|
||||||
Scenario Outline: Increasing Headings on Markdown export
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
When we open the editor and append
|
|
||||||
"""
|
|
||||||
[2020-10-14 13:23] Heading Test
|
|
||||||
|
|
||||||
H1-1
|
|
||||||
=
|
|
||||||
|
|
||||||
H1-2
|
|
||||||
===
|
|
||||||
|
|
||||||
H1-3
|
|
||||||
============================
|
|
||||||
|
|
||||||
H2-1
|
|
||||||
-
|
|
||||||
|
|
||||||
H2-2
|
|
||||||
---
|
|
||||||
|
|
||||||
H2-3
|
|
||||||
----------------------------------
|
|
||||||
|
|
||||||
Horizontal Rules (ignore)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
===
|
|
||||||
|
|
||||||
# ATX H1
|
|
||||||
|
|
||||||
## ATX H2
|
|
||||||
|
|
||||||
### ATX H3
|
|
||||||
|
|
||||||
#### ATX H4
|
|
||||||
|
|
||||||
##### ATX H5
|
|
||||||
|
|
||||||
###### ATX H6
|
|
||||||
|
|
||||||
Stuff
|
|
||||||
|
|
||||||
More stuff
|
|
||||||
more stuff again
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -1 --export markdown"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
# 2020
|
|
||||||
|
|
||||||
## October
|
|
||||||
|
|
||||||
### 2020-10-14 13:23 Heading Test
|
|
||||||
|
|
||||||
#### H1-1
|
|
||||||
|
|
||||||
#### H1-2
|
|
||||||
|
|
||||||
#### H1-3
|
|
||||||
|
|
||||||
##### H2-1
|
|
||||||
|
|
||||||
##### H2-2
|
|
||||||
|
|
||||||
##### H2-3
|
|
||||||
|
|
||||||
Horizontal Rules (ignore)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
===
|
|
||||||
|
|
||||||
#### ATX H1
|
|
||||||
|
|
||||||
##### ATX H2
|
|
||||||
|
|
||||||
###### ATX H3
|
|
||||||
|
|
||||||
####### ATX H4
|
|
||||||
|
|
||||||
######## ATX H5
|
|
||||||
|
|
||||||
######### ATX H6
|
|
||||||
|
|
||||||
Stuff
|
|
||||||
|
|
||||||
More stuff
|
|
||||||
more stuff again
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
| basic_encrypted |
|
|
||||||
| basic_folder |
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
Scenario Outline: Add a blank line to Markdown export if there isn't one already
|
|
||||||
# https://github.com/jrnl-org/jrnl/issues/768
|
|
||||||
# https://github.com/jrnl-org/jrnl/issues/881
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
When we open the editor and append
|
|
||||||
"""
|
|
||||||
[2020-10-29 11:11] First entry.
|
|
||||||
[2020-10-29 11:11] Second entry.
|
|
||||||
[2020-10-29 11:13] Third entry.
|
|
||||||
"""
|
|
||||||
Then we flush the output
|
|
||||||
When we run "jrnl -3 --format markdown"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
# 2020
|
|
||||||
|
|
||||||
## October
|
|
||||||
|
|
||||||
### 2020-10-29 11:11 First entry.
|
|
||||||
|
|
||||||
|
|
||||||
### 2020-10-29 11:11 Second entry.
|
|
||||||
|
|
||||||
|
|
||||||
### 2020-10-29 11:13 Third entry.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
| basic_encrypted |
|
|
||||||
| basic_folder |
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
@skip
|
|
||||||
Scenario Outline: Exporting to XML
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
When we run "jrnl --export xml"
|
|
||||||
Then the output should be a valid XML string
|
|
||||||
And "entries" node in the xml output should have 3 elements
|
|
||||||
And "tags" in the xml output should contain ["@ipsum", "@tagone", "@tagtwo", "@tagthree"]
|
|
||||||
And there should be 10 "tag" elements
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config |
|
|
||||||
# | basic_onefile | @todo
|
|
||||||
# | basic_encrypted | @todo
|
|
||||||
# | basic_folder | @todo
|
|
||||||
# | basic_dayone | @todo
|
|
||||||
|
|
||||||
Scenario: Exporting to XML
|
|
||||||
Given we use the config "tags.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
When we run "jrnl --export xml"
|
|
||||||
Then the output should be a valid XML string
|
|
||||||
And "entries" node in the xml output should have 2 elements
|
|
||||||
And "tags" in the xml output should contain ["@idea", "@journal", "@dan"]
|
|
||||||
And there should be 7 "tag" elements
|
|
||||||
|
|
||||||
Scenario Outline: Exporting tags
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
When we run "jrnl --export tags"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
@tagtwo : 2
|
|
||||||
@tagone : 2
|
|
||||||
@tagthree : 1
|
|
||||||
@ipsum : 1
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
| basic_encrypted |
|
|
||||||
| basic_folder |
|
|
||||||
| basic_dayone |
|
|
||||||
|
|
||||||
@todo
|
|
||||||
Scenario Outline: Exporting fancy
|
|
||||||
# Needs better emoji support
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
When we run "jrnl --export fancy"
|
|
||||||
Then the output should be
|
|
||||||
"""
|
|
||||||
┎──────────────────────────────────────────────────────────────╮2020-08-29 11:11
|
|
||||||
┃ Entry the first. ╘═══════════════╕
|
|
||||||
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
|
||||||
┃ Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada │
|
|
||||||
┃ quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus │
|
|
||||||
┃ pellentesque │
|
|
||||||
┃ augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu │
|
|
||||||
┃ consequat. Aenean ante ex, elementum ut interdum et, mattis eget lacus. In │
|
|
||||||
┃ commodo nulla nec tellus placerat, sed ultricies metus bibendum. Duis eget │
|
|
||||||
┃ venenatis erat. In at dolor dui. @tagone and maybe also @tagtwo. │
|
|
||||||
┃ │
|
|
||||||
┃ Curabitur accumsan nunc ac neque tristique, eleifend faucibus justo │
|
|
||||||
┃ ullamcorper. Suspendisse at mattis nunc. Nullam eget lacinia urna. │
|
|
||||||
┃ Suspendisse │
|
|
||||||
┃ potenti. Ut urna est, venenatis sed ante in, ultrices congue mi. Maecenas │
|
|
||||||
┃ eget │
|
|
||||||
┃ molestie metus. Mauris porttitor dui ornare gravida porta. Quisque sed │
|
|
||||||
┃ lectus │
|
|
||||||
┃ hendrerit, lacinia ante eget, vulputate ante. Aliquam vitae erat non felis │
|
|
||||||
┃ feugiat sagittis. Phasellus quis arcu fringilla, mattis ligula id, │
|
|
||||||
┃ vestibulum │
|
|
||||||
┃ urna. Vivamus facilisis leo a mi tincidunt condimentum. Donec eu euismod │
|
|
||||||
┃ enim. │
|
|
||||||
┃ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu ligula eget │
|
|
||||||
┃ velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac │
|
|
||||||
┃ porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per │
|
|
||||||
┃ conubia nostra, per inceptos himenaeos. │
|
|
||||||
┖──────────────────────────────────────────────────────────────────────────────┘
|
|
||||||
┎──────────────────────────────────────────────────────────────╮2020-08-31 14:32
|
|
||||||
┃ A second entry in what I hope to be a long series. ╘═══════════════╕
|
|
||||||
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
|
||||||
┃ Sed sit amet metus et sapien feugiat elementum. Aliquam bibendum lobortis │
|
|
||||||
┃ leo │
|
|
||||||
┃ vitae tempus. Donec eleifend nec mi non volutpat. Lorem ipsum dolor sit │
|
|
||||||
┃ amet, │
|
|
||||||
┃ consectetur adipiscing elit. Praesent ut sodales libero. Maecenas nisl │
|
|
||||||
┃ lorem, │
|
|
||||||
┃ vestibulum in tempus sit amet, fermentum ut arcu. Donec vel vestibulum │
|
|
||||||
┃ lectus, │
|
|
||||||
┃ eget pretium enim. Maecenas diam nunc, imperdiet vitae pharetra sed, pretium │
|
|
||||||
┃ id │
|
|
||||||
┃ lectus. Donec eu metus et turpis tempor tristique ac non ex. In tellus arcu, │
|
|
||||||
┃ egestas at efficitur et, ultrices vel est. Sed commodo et nibh non │
|
|
||||||
┃ elementum. │
|
|
||||||
┃ Mauris tempus vitae neque vel viverra. @tagtwo all by its lonesome. │
|
|
||||||
┃ │
|
|
||||||
┃ Nulla mattis elementum magna, viverra pretium dui fermentum et. Cras vel │
|
|
||||||
┃ vestibulum odio. Quisque sit amet turpis et urna finibus maximus. Interdum │
|
|
||||||
┃ et │
|
|
||||||
┃ malesuada fames ac ante ipsum primis in faucibus. Fusce porttitor iaculis │
|
|
||||||
┃ sem, │
|
|
||||||
┃ non dictum ipsum varius nec. Nulla eu erat at risus gravida blandit non vel │
|
|
||||||
┃ ante. Nam egestas ipsum leo, eu ultricies ipsum tincidunt vel. Morbi a │
|
|
||||||
┃ commodo │
|
|
||||||
┃ eros. │
|
|
||||||
┃ │
|
|
||||||
┃ Nullam dictum, nisl ac varius tempus, ex tortor fermentum nisl, non │
|
|
||||||
┃ tempus dolor neque a lorem. Suspendisse a faucibus ex, vel ornare tortor. │
|
|
||||||
┃ Maecenas tincidunt id felis quis semper. Pellentesque enim libero, fermentum │
|
|
||||||
┃ quis metus id, rhoncus euismod magna. Nulla finibus velit eu purus bibendum │
|
|
||||||
┃ interdum. Integer id justo dui. Integer eu tellus in turpis bibendum │
|
|
||||||
┃ blandit. │
|
|
||||||
┃ Quisque auctor lacinia consectetur. │
|
|
||||||
┖──────────────────────────────────────────────────────────────────────────────┘
|
|
||||||
┎──────────────────────────────────────────────────────────────╮2020-09-24 09:14
|
|
||||||
┃ The third entry finally after weeks without writing. ╘═══════════════╕
|
|
||||||
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
|
||||||
┃ I'm so excited about emojis. 💯 🎶 💩 │
|
|
||||||
┃ │
|
|
||||||
┃ Donec semper pellentesque iaculis. Nullam cursus et justo sit amet │
|
|
||||||
┃ venenatis. │
|
|
||||||
┃ Vivamus tempus ex dictum metus vehicula gravida. Aliquam sed sem dolor. │
|
|
||||||
┃ Nulla │
|
|
||||||
┃ eget ultrices purus. Quisque at nunc at quam pharetra consectetur vitae quis │
|
|
||||||
┃ dolor. Fusce ultricies purus eu est feugiat, quis scelerisque nibh │
|
|
||||||
┃ malesuada. │
|
|
||||||
┃ Quisque egestas semper nibh in hendrerit. Nam finibus ex in mi mattis │
|
|
||||||
┃ vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan │
|
|
||||||
┃ justo. │
|
|
||||||
┃ Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at │
|
|
||||||
┃ ante eget fringilla. @tagthree and also @tagone │
|
|
||||||
┖──────────────────────────────────────────────────────────────────────────────┘
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
| basic_encrypted |
|
|
||||||
| basic_folder |
|
|
||||||
| basic_dayone |
|
|
||||||
|
|
||||||
@skip_win
|
|
||||||
Scenario Outline: Export to yaml
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
And we create a cache directory
|
|
||||||
When we run "jrnl --export yaml -o {cache_dir}"
|
|
||||||
Then the cache should contain the files
|
|
||||||
"""
|
|
||||||
2020-08-29_entry-the-first.md
|
|
||||||
2020-08-31_a-second-entry-in-what-i-hope-to-be-a-long-series.md
|
|
||||||
2020-09-24_the-third-entry-finally-after-weeks-without-writing.md
|
|
||||||
"""
|
|
||||||
And the content of file "2020-08-29_entry-the-first.md" in the cache should be
|
|
||||||
"""
|
|
||||||
---
|
|
||||||
title: Entry the first.
|
|
||||||
date: 2020-08-29 11:11
|
|
||||||
starred: False
|
|
||||||
tags: tagone, ipsum, tagtwo
|
|
||||||
body: |
|
|
||||||
Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada
|
|
||||||
quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus pellentesque
|
|
||||||
augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu
|
|
||||||
consequat. Aenean ante ex, elementum ut interdum et, mattis eget lacus. In
|
|
||||||
commodo nulla nec tellus placerat, sed ultricies metus bibendum. Duis eget
|
|
||||||
venenatis erat. In at dolor dui. @tagone and maybe also @tagtwo.
|
|
||||||
|
|
||||||
Curabitur accumsan nunc ac neque tristique, eleifend faucibus justo
|
|
||||||
ullamcorper. Suspendisse at mattis nunc. Nullam eget lacinia urna. Suspendisse
|
|
||||||
potenti. Ut urna est, venenatis sed ante in, ultrices congue mi. Maecenas eget
|
|
||||||
molestie metus. Mauris porttitor dui ornare gravida porta. Quisque sed lectus
|
|
||||||
hendrerit, lacinia ante eget, vulputate ante. Aliquam vitae erat non felis
|
|
||||||
feugiat sagittis. Phasellus quis arcu fringilla, mattis ligula id, vestibulum
|
|
||||||
urna. Vivamus facilisis leo a mi tincidunt condimentum. Donec eu euismod enim.
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu ligula eget
|
|
||||||
velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac
|
|
||||||
porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per
|
|
||||||
conubia nostra, per inceptos himenaeos.
|
|
||||||
...
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config |
|
|
||||||
| basic_onefile |
|
|
||||||
| basic_encrypted |
|
|
||||||
| basic_folder |
|
|
||||||
# | basic_dayone |
|
|
||||||
|
|
||||||
@skip_win # @todo YAML exporter does not correctly export emoji on Windows
|
|
||||||
Scenario Outline: Add a blank line to YAML export if there isn't one already
|
|
||||||
# https://github.com/jrnl-org/jrnl/issues/768
|
|
||||||
# https://github.com/jrnl-org/jrnl/issues/881
|
|
||||||
Given we use the config "<config>.yaml"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
And we create a cache directory
|
|
||||||
When we run "jrnl --export yaml -o {cache_dir}"
|
|
||||||
Then the cache should contain the files
|
|
||||||
"""
|
|
||||||
2020-08-29_entry-the-first.md
|
|
||||||
2020-08-31_a-second-entry-in-what-i-hope-to-be-a-long-series.md
|
|
||||||
2020-09-24_the-third-entry-finally-after-weeks-without-writing.md
|
|
||||||
"""
|
|
||||||
And the content of file "2020-09-24_the-third-entry-finally-after-weeks-without-writing.md" in the cache should be
|
|
||||||
"""
|
|
||||||
---
|
|
||||||
title: The third entry finally after weeks without writing.
|
|
||||||
date: 2020-09-24 09:14
|
|
||||||
starred: False
|
|
||||||
tags: tagone, tagthree
|
|
||||||
body: |
|
|
||||||
I'm so excited about emojis. 💯 🎶 💩
|
I'm so excited about emojis. 💯 🎶 💩
|
||||||
|
|
||||||
Donec semper pellentesque iaculis. Nullam cursus et justo sit amet venenatis.
|
Donec semper pellentesque iaculis. Nullam cursus et justo sit amet venenatis.
|
||||||
|
@ -475,16 +102,373 @@ Feature: Custom formats
|
||||||
Quisque egestas semper nibh in hendrerit. Nam finibus ex in mi mattis
|
Quisque egestas semper nibh in hendrerit. Nam finibus ex in mi mattis
|
||||||
vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan justo.
|
vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan justo.
|
||||||
Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at
|
Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at
|
||||||
ante eget fringilla. @tagthree and also @tagone
|
ante eget fringilla. @tagthree and also @tagone
|
||||||
...
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
# | basic_dayone | @todo
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
|
Scenario Outline: Increasing Headings on Markdown export
|
||||||
|
Given we use the config "<config_file>"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
When we open the editor and append
|
||||||
|
[2020-10-14 13:23] Heading Test
|
||||||
|
|
||||||
|
H1-1
|
||||||
|
=
|
||||||
|
|
||||||
|
H1-2
|
||||||
|
===
|
||||||
|
|
||||||
|
H1-3
|
||||||
|
============================
|
||||||
|
|
||||||
|
H2-1
|
||||||
|
-
|
||||||
|
|
||||||
|
H2-2
|
||||||
|
---
|
||||||
|
|
||||||
|
H2-3
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Horizontal Rules (ignore)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
===
|
||||||
|
|
||||||
|
# ATX H1
|
||||||
|
|
||||||
|
## ATX H2
|
||||||
|
|
||||||
|
### ATX H3
|
||||||
|
|
||||||
|
#### ATX H4
|
||||||
|
|
||||||
|
##### ATX H5
|
||||||
|
|
||||||
|
###### ATX H6
|
||||||
|
|
||||||
|
Stuff
|
||||||
|
|
||||||
|
More stuff
|
||||||
|
more stuff again
|
||||||
|
Then we flush the output
|
||||||
|
When we run "jrnl -1 --export markdown"
|
||||||
|
Then the output should be
|
||||||
|
# 2020
|
||||||
|
|
||||||
|
## October
|
||||||
|
|
||||||
|
### 2020-10-14 13:23 Heading Test
|
||||||
|
|
||||||
|
#### H1-1
|
||||||
|
|
||||||
|
#### H1-2
|
||||||
|
|
||||||
|
#### H1-3
|
||||||
|
|
||||||
|
##### H2-1
|
||||||
|
|
||||||
|
##### H2-2
|
||||||
|
|
||||||
|
##### H2-3
|
||||||
|
|
||||||
|
Horizontal Rules (ignore)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
===
|
||||||
|
|
||||||
|
#### ATX H1
|
||||||
|
|
||||||
|
##### ATX H2
|
||||||
|
|
||||||
|
###### ATX H3
|
||||||
|
|
||||||
|
####### ATX H4
|
||||||
|
|
||||||
|
######## ATX H5
|
||||||
|
|
||||||
|
######### ATX H6
|
||||||
|
|
||||||
|
Stuff
|
||||||
|
|
||||||
|
More stuff
|
||||||
|
more stuff again
|
||||||
|
|
||||||
|
Examples: configs
|
||||||
|
| config_file |
|
||||||
|
| basic_onefile.yaml |
|
||||||
|
| basic_encrypted.yaml |
|
||||||
|
| basic_folder.yaml |
|
||||||
|
# | basic_dayone.yaml | @todo
|
||||||
|
|
||||||
|
Scenario Outline: Add a blank line to Markdown export if there isn't one already
|
||||||
|
# https://github.com/jrnl-org/jrnl/issues/768
|
||||||
|
# https://github.com/jrnl-org/jrnl/issues/881
|
||||||
|
Given we use the config "<config_file>"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
When we open the editor and append
|
||||||
|
[2020-10-29 11:11] First entry.
|
||||||
|
[2020-10-29 11:11] Second entry.
|
||||||
|
[2020-10-29 11:13] Third entry.
|
||||||
|
Then we flush the output
|
||||||
|
When we run "jrnl -3 --format markdown"
|
||||||
|
Then the output should be
|
||||||
|
# 2020
|
||||||
|
|
||||||
|
## October
|
||||||
|
|
||||||
|
### 2020-10-29 11:11 First entry.
|
||||||
|
|
||||||
|
|
||||||
|
### 2020-10-29 11:11 Second entry.
|
||||||
|
|
||||||
|
|
||||||
|
### 2020-10-29 11:13 Third entry.
|
||||||
|
|
||||||
|
|
||||||
|
Examples: configs
|
||||||
|
| config_file |
|
||||||
|
| basic_onefile.yaml |
|
||||||
|
| basic_encrypted.yaml |
|
||||||
|
| basic_folder.yaml |
|
||||||
|
# | basic_dayone.yaml | @todo
|
||||||
|
|
||||||
|
@skip
|
||||||
|
Scenario Outline: Exporting to XML
|
||||||
|
Given we use the config "<config_file>"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
When we run "jrnl --export xml"
|
||||||
|
Then the output should be a valid XML string
|
||||||
|
And "entries" node in the xml output should have 3 elements
|
||||||
|
And "tags" in the xml output should contain
|
||||||
|
@ipsum
|
||||||
|
@tagone
|
||||||
|
@tagtwo
|
||||||
|
@tagthree
|
||||||
|
And there should be 10 "tag" elements
|
||||||
|
|
||||||
|
Examples: configs
|
||||||
|
| config_file |
|
||||||
|
# | basic_onefile.yaml | @todo
|
||||||
|
# | basic_encrypted.yaml | @todo
|
||||||
|
# | basic_folder.yaml | @todo
|
||||||
|
# | basic_dayone.yaml | @todo
|
||||||
|
|
||||||
|
Scenario: Exporting to XML
|
||||||
|
Given we use the config "tags.yaml"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
When we run "jrnl --export xml"
|
||||||
|
Then the output should be a valid XML string
|
||||||
|
And "entries" node in the xml output should have 2 elements
|
||||||
|
And "tags" in the xml output should contain
|
||||||
|
@idea
|
||||||
|
@journal
|
||||||
|
@dan
|
||||||
|
And there should be 7 "tag" elements
|
||||||
|
|
||||||
|
Scenario Outline: Exporting tags
|
||||||
|
Given we use the config "<config_file>"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
When we run "jrnl --export tags"
|
||||||
|
Then the output should be
|
||||||
|
@tagtwo : 2
|
||||||
|
@tagone : 2
|
||||||
|
@tagthree : 1
|
||||||
|
@ipsum : 1
|
||||||
|
|
||||||
|
Examples: configs
|
||||||
|
| config_file |
|
||||||
|
| basic_onefile.yaml |
|
||||||
|
| basic_encrypted.yaml |
|
||||||
|
| basic_folder.yaml |
|
||||||
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
|
@todo
|
||||||
|
Scenario Outline: Exporting fancy
|
||||||
|
# Needs better emoji support
|
||||||
|
Given we use the config "<config_file>"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
When we run "jrnl --export fancy"
|
||||||
|
Then the output should be
|
||||||
|
┎──────────────────────────────────────────────────────────────╮2020-08-29 11:11
|
||||||
|
┃ Entry the first. ╘═══════════════╕
|
||||||
|
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
||||||
|
┃ Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada │
|
||||||
|
┃ quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus │
|
||||||
|
┃ pellentesque │
|
||||||
|
┃ augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu │
|
||||||
|
┃ consequat. Aenean ante ex, elementum ut interdum et, mattis eget lacus. In │
|
||||||
|
┃ commodo nulla nec tellus placerat, sed ultricies metus bibendum. Duis eget │
|
||||||
|
┃ venenatis erat. In at dolor dui. @tagone and maybe also @tagtwo. │
|
||||||
|
┃ │
|
||||||
|
┃ Curabitur accumsan nunc ac neque tristique, eleifend faucibus justo │
|
||||||
|
┃ ullamcorper. Suspendisse at mattis nunc. Nullam eget lacinia urna. │
|
||||||
|
┃ Suspendisse │
|
||||||
|
┃ potenti. Ut urna est, venenatis sed ante in, ultrices congue mi. Maecenas │
|
||||||
|
┃ eget │
|
||||||
|
┃ molestie metus. Mauris porttitor dui ornare gravida porta. Quisque sed │
|
||||||
|
┃ lectus │
|
||||||
|
┃ hendrerit, lacinia ante eget, vulputate ante. Aliquam vitae erat non felis │
|
||||||
|
┃ feugiat sagittis. Phasellus quis arcu fringilla, mattis ligula id, │
|
||||||
|
┃ vestibulum │
|
||||||
|
┃ urna. Vivamus facilisis leo a mi tincidunt condimentum. Donec eu euismod │
|
||||||
|
┃ enim. │
|
||||||
|
┃ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu ligula eget │
|
||||||
|
┃ velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac │
|
||||||
|
┃ porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per │
|
||||||
|
┃ conubia nostra, per inceptos himenaeos. │
|
||||||
|
┖──────────────────────────────────────────────────────────────────────────────┘
|
||||||
|
┎──────────────────────────────────────────────────────────────╮2020-08-31 14:32
|
||||||
|
┃ A second entry in what I hope to be a long series. ╘═══════════════╕
|
||||||
|
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
||||||
|
┃ Sed sit amet metus et sapien feugiat elementum. Aliquam bibendum lobortis │
|
||||||
|
┃ leo │
|
||||||
|
┃ vitae tempus. Donec eleifend nec mi non volutpat. Lorem ipsum dolor sit │
|
||||||
|
┃ amet, │
|
||||||
|
┃ consectetur adipiscing elit. Praesent ut sodales libero. Maecenas nisl │
|
||||||
|
┃ lorem, │
|
||||||
|
┃ vestibulum in tempus sit amet, fermentum ut arcu. Donec vel vestibulum │
|
||||||
|
┃ lectus, │
|
||||||
|
┃ eget pretium enim. Maecenas diam nunc, imperdiet vitae pharetra sed, pretium │
|
||||||
|
┃ id │
|
||||||
|
┃ lectus. Donec eu metus et turpis tempor tristique ac non ex. In tellus arcu, │
|
||||||
|
┃ egestas at efficitur et, ultrices vel est. Sed commodo et nibh non │
|
||||||
|
┃ elementum. │
|
||||||
|
┃ Mauris tempus vitae neque vel viverra. @tagtwo all by its lonesome. │
|
||||||
|
┃ │
|
||||||
|
┃ Nulla mattis elementum magna, viverra pretium dui fermentum et. Cras vel │
|
||||||
|
┃ vestibulum odio. Quisque sit amet turpis et urna finibus maximus. Interdum │
|
||||||
|
┃ et │
|
||||||
|
┃ malesuada fames ac ante ipsum primis in faucibus. Fusce porttitor iaculis │
|
||||||
|
┃ sem, │
|
||||||
|
┃ non dictum ipsum varius nec. Nulla eu erat at risus gravida blandit non vel │
|
||||||
|
┃ ante. Nam egestas ipsum leo, eu ultricies ipsum tincidunt vel. Morbi a │
|
||||||
|
┃ commodo │
|
||||||
|
┃ eros. │
|
||||||
|
┃ │
|
||||||
|
┃ Nullam dictum, nisl ac varius tempus, ex tortor fermentum nisl, non │
|
||||||
|
┃ tempus dolor neque a lorem. Suspendisse a faucibus ex, vel ornare tortor. │
|
||||||
|
┃ Maecenas tincidunt id felis quis semper. Pellentesque enim libero, fermentum │
|
||||||
|
┃ quis metus id, rhoncus euismod magna. Nulla finibus velit eu purus bibendum │
|
||||||
|
┃ interdum. Integer id justo dui. Integer eu tellus in turpis bibendum │
|
||||||
|
┃ blandit. │
|
||||||
|
┃ Quisque auctor lacinia consectetur. │
|
||||||
|
┖──────────────────────────────────────────────────────────────────────────────┘
|
||||||
|
┎──────────────────────────────────────────────────────────────╮2020-09-24 09:14
|
||||||
|
┃ The third entry finally after weeks without writing. ╘═══════════════╕
|
||||||
|
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
||||||
|
┃ I'm so excited about emojis. 💯 🎶 💩 │
|
||||||
|
┃ │
|
||||||
|
┃ Donec semper pellentesque iaculis. Nullam cursus et justo sit amet │
|
||||||
|
┃ venenatis. │
|
||||||
|
┃ Vivamus tempus ex dictum metus vehicula gravida. Aliquam sed sem dolor. │
|
||||||
|
┃ Nulla │
|
||||||
|
┃ eget ultrices purus. Quisque at nunc at quam pharetra consectetur vitae quis │
|
||||||
|
┃ dolor. Fusce ultricies purus eu est feugiat, quis scelerisque nibh │
|
||||||
|
┃ malesuada. │
|
||||||
|
┃ Quisque egestas semper nibh in hendrerit. Nam finibus ex in mi mattis │
|
||||||
|
┃ vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan │
|
||||||
|
┃ justo. │
|
||||||
|
┃ Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at │
|
||||||
|
┃ ante eget fringilla. @tagthree and also @tagone │
|
||||||
|
┖──────────────────────────────────────────────────────────────────────────────┘
|
||||||
|
|
||||||
|
Examples: configs
|
||||||
|
| config_file |
|
||||||
|
| basic_onefile.yaml |
|
||||||
|
| basic_encrypted.yaml |
|
||||||
|
| basic_folder.yaml |
|
||||||
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
|
@skip_win
|
||||||
|
Scenario Outline: Export to yaml
|
||||||
|
Given we use the config "<config_file>"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
And we create a cache directory
|
||||||
|
When we run "jrnl --format yaml --file {cache_dir}"
|
||||||
|
Then the cache directory should contain the files
|
||||||
|
2020-08-29_entry-the-first.md
|
||||||
|
2020-08-31_a-second-entry-in-what-i-hope-to-be-a-long-series.md
|
||||||
|
2020-09-24_the-third-entry-finally-after-weeks-without-writing.md
|
||||||
|
|
||||||
|
And the content of file "2020-08-29_entry-the-first.md" in the cache should be
|
||||||
|
---
|
||||||
|
title: Entry the first.
|
||||||
|
date: 2020-08-29 11:11
|
||||||
|
starred: False
|
||||||
|
tags: tagone, ipsum, tagtwo
|
||||||
|
body: |
|
||||||
|
Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada
|
||||||
|
quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus pellentesque
|
||||||
|
augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu
|
||||||
|
consequat. Aenean ante ex, elementum ut interdum et, mattis eget lacus. In
|
||||||
|
commodo nulla nec tellus placerat, sed ultricies metus bibendum. Duis eget
|
||||||
|
venenatis erat. In at dolor dui. @tagone and maybe also @tagtwo.
|
||||||
|
|
||||||
|
Curabitur accumsan nunc ac neque tristique, eleifend faucibus justo
|
||||||
|
ullamcorper. Suspendisse at mattis nunc. Nullam eget lacinia urna. Suspendisse
|
||||||
|
potenti. Ut urna est, venenatis sed ante in, ultrices congue mi. Maecenas eget
|
||||||
|
molestie metus. Mauris porttitor dui ornare gravida porta. Quisque sed lectus
|
||||||
|
hendrerit, lacinia ante eget, vulputate ante. Aliquam vitae erat non felis
|
||||||
|
feugiat sagittis. Phasellus quis arcu fringilla, mattis ligula id, vestibulum
|
||||||
|
urna. Vivamus facilisis leo a mi tincidunt condimentum. Donec eu euismod enim.
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu ligula eget
|
||||||
|
velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac
|
||||||
|
porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per
|
||||||
|
conubia nostra, per inceptos himenaeos.
|
||||||
|
...
|
||||||
|
|
||||||
|
Examples: configs
|
||||||
|
| config_file |
|
||||||
|
| basic_onefile.yaml |
|
||||||
|
| basic_encrypted.yaml |
|
||||||
|
| basic_folder.yaml |
|
||||||
|
# | basic_dayone.yaml |
|
||||||
|
|
||||||
|
@skip_win # @todo YAML exporter does not correctly export emoji on Windows
|
||||||
|
Scenario Outline: Add a blank line to YAML export if there isn't one already
|
||||||
|
# https://github.com/jrnl-org/jrnl/issues/768
|
||||||
|
# https://github.com/jrnl-org/jrnl/issues/881
|
||||||
|
Given we use the config "<config_file>"
|
||||||
|
And we use the password "test" if prompted
|
||||||
|
And we create a cache directory
|
||||||
|
When we run "jrnl --export yaml -o {cache_dir}"
|
||||||
|
Then the cache should contain the files
|
||||||
|
2020-08-29_entry-the-first.md
|
||||||
|
2020-08-31_a-second-entry-in-what-i-hope-to-be-a-long-series.md
|
||||||
|
2020-09-24_the-third-entry-finally-after-weeks-without-writing.md
|
||||||
|
And the content of file "2020-09-24_the-third-entry-finally-after-weeks-without-writing.md" in the cache should be
|
||||||
|
---
|
||||||
|
title: The third entry finally after weeks without writing.
|
||||||
|
date: 2020-09-24 09:14
|
||||||
|
starred: False
|
||||||
|
tags: tagone, tagthree
|
||||||
|
body: |
|
||||||
|
I'm so excited about emojis. 💯 🎶 💩
|
||||||
|
|
||||||
|
Donec semper pellentesque iaculis. Nullam cursus et justo sit amet venenatis.
|
||||||
|
Vivamus tempus ex dictum metus vehicula gravida. Aliquam sed sem dolor. Nulla
|
||||||
|
eget ultrices purus. Quisque at nunc at quam pharetra consectetur vitae quis
|
||||||
|
dolor. Fusce ultricies purus eu est feugiat, quis scelerisque nibh malesuada.
|
||||||
|
Quisque egestas semper nibh in hendrerit. Nam finibus ex in mi mattis
|
||||||
|
vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan justo.
|
||||||
|
Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at
|
||||||
|
ante eget fringilla. @tagthree and also @tagone
|
||||||
|
...
|
||||||
|
|
||||||
|
Examples: configs
|
||||||
|
| config_file |
|
||||||
|
| basic_onefile.yaml |
|
||||||
|
| basic_encrypted.yaml |
|
||||||
|
| basic_folder.yaml |
|
||||||
|
# | basic_dayone.yaml | @todo
|
||||||
|
|
||||||
Scenario: Empty DayOne entry bodies should not error
|
Scenario: Empty DayOne entry bodies should not error
|
||||||
# https://github.com/jrnl-org/jrnl/issues/780
|
# https://github.com/jrnl-org/jrnl/issues/780
|
||||||
|
@ -493,36 +477,35 @@ Feature: Custom formats
|
||||||
Then we should get no error
|
Then we should get no error
|
||||||
|
|
||||||
Scenario Outline: --short displays the short version of entries (only the title)
|
Scenario Outline: --short displays the short version of entries (only the title)
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl -on 2020-08-31 --short"
|
When we run "jrnl -on 2020-08-31 --short"
|
||||||
Then the output should be "2020-08-31 14:32 A second entry in what I hope to be a long series."
|
Then the output should be "2020-08-31 14:32 A second entry in what I hope to be a long series."
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
Scenario Outline: -s displays the short version of entries (only the title)
|
Scenario Outline: -s displays the short version of entries (only the title)
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl -on 2020-08-31 -s"
|
When we run "jrnl -on 2020-08-31 -s"
|
||||||
Then the output should be "2020-08-31 14:32 A second entry in what I hope to be a long series."
|
Then the output should be "2020-08-31 14:32 A second entry in what I hope to be a long series."
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
Scenario: Markdown Support from config file
|
Scenario: Markdown Support from config file
|
||||||
Given we use the config "format_md.yaml"
|
Given we use the config "format_md.yaml"
|
||||||
When we run "jrnl -n 1"
|
When we run "jrnl -n 1"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
|
||||||
# 2013
|
# 2013
|
||||||
|
|
||||||
## June
|
## June
|
||||||
|
@ -530,50 +513,43 @@ Feature: Custom formats
|
||||||
### 2013-06-10 15:40 Life is good.
|
### 2013-06-10 15:40 Life is good.
|
||||||
|
|
||||||
But I'm better.
|
But I'm better.
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Text Formatter from config file
|
Scenario: Text Formatter from config file
|
||||||
Given we use the config "format_text.yaml"
|
Given we use the config "format_text.yaml"
|
||||||
When we run "jrnl -n 1"
|
When we run "jrnl -n 1"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
|
||||||
[2013-06-10 15:40] Life is good.
|
[2013-06-10 15:40] Life is good.
|
||||||
But I'm better.
|
But I'm better.
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario Outline: Exporting entries with Cyrillic characters to directory should not fail
|
Scenario Outline: Exporting entries with Cyrillic characters to directory should not fail
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
And we create a cache directory
|
And we create a cache directory
|
||||||
When we run "jrnl 2020-11-21: Первая"
|
When we run "jrnl 2020-11-21: Первая"
|
||||||
When we run "jrnl --format md --file {cache_dir} -on 2020-11-21"
|
When we run "jrnl --format md --file {cache_dir} -on 2020-11-21"
|
||||||
Then the cache should contain the files
|
Then the cache should contain the files
|
||||||
"""
|
2020-11-21_первая.md
|
||||||
2020-11-21_первая.md
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
Scenario Outline: Export date counts
|
Scenario Outline: Export date counts
|
||||||
Given we use the config "<config>.yaml"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl 2020-08-31 01:01: Hi."
|
When we run "jrnl 2020-08-31 01:01: Hi."
|
||||||
And we run "jrnl --format dates"
|
And we run "jrnl --format dates"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
"""
|
2020-08-29, 1
|
||||||
2020-08-29, 1
|
2020-08-31, 2
|
||||||
2020-08-31, 2
|
2020-09-24, 1
|
||||||
2020-09-24, 1
|
|
||||||
"""
|
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config |
|
| config_file |
|
||||||
| basic_onefile |
|
| basic_onefile.yaml |
|
||||||
| basic_encrypted |
|
| basic_encrypted.yaml |
|
||||||
| basic_folder |
|
| basic_folder.yaml |
|
||||||
| basic_dayone |
|
| basic_dayone.yaml |
|
||||||
|
|
|
@ -7,10 +7,13 @@ from collections import defaultdict
|
||||||
from keyring import backend
|
from keyring import backend
|
||||||
from keyring import set_keyring
|
from keyring import set_keyring
|
||||||
from keyring import errors
|
from keyring import errors
|
||||||
|
import random
|
||||||
|
import string
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
from xml.etree import ElementTree
|
||||||
|
|
||||||
from pytest_bdd import given
|
from pytest_bdd import given
|
||||||
from pytest_bdd import then
|
from pytest_bdd import then
|
||||||
|
@ -119,6 +122,11 @@ def password():
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def cache_dir():
|
||||||
|
return {"exists": False, "path": ""}
|
||||||
|
|
||||||
|
|
||||||
@fixture
|
@fixture
|
||||||
def str_value():
|
def str_value():
|
||||||
return ""
|
return ""
|
||||||
|
@ -212,7 +220,12 @@ def use_password_forever(pw):
|
||||||
@when(parse('we run "jrnl" and enter "{user_input}"'))
|
@when(parse('we run "jrnl" and enter "{user_input}"'))
|
||||||
@when('we run "jrnl <command>"')
|
@when('we run "jrnl <command>"')
|
||||||
@when('we run "jrnl"')
|
@when('we run "jrnl"')
|
||||||
def we_run(command, config_path, user_input, cli_run, capsys, password, keyring):
|
def we_run(
|
||||||
|
command, config_path, user_input, cli_run, capsys, password, keyring, cache_dir
|
||||||
|
):
|
||||||
|
if cache_dir["exists"]:
|
||||||
|
command = command.format(cache_dir=cache_dir["path"])
|
||||||
|
|
||||||
args = split_args(command)
|
args = split_args(command)
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
|
@ -364,3 +377,111 @@ def password_was_called(cli_run):
|
||||||
@then("we should not be prompted for a password")
|
@then("we should not be prompted for a password")
|
||||||
def password_was_not_called(cli_run):
|
def password_was_not_called(cli_run):
|
||||||
assert not cli_run["mocks"]["getpass"].called
|
assert not cli_run["mocks"]["getpass"].called
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse("the cache directory should contain the files\n{file_list}"))
|
||||||
|
def assert_dir_contains_files(file_list, cache_dir):
|
||||||
|
actual_files = os.listdir(cache_dir["path"])
|
||||||
|
expected_files = file_list.split("\n")
|
||||||
|
|
||||||
|
# sort to deal with inconsistent default file ordering on different OS's
|
||||||
|
actual_files.sort()
|
||||||
|
expected_files.sort()
|
||||||
|
|
||||||
|
assert actual_files == expected_files, [actual_files, expected_files]
|
||||||
|
|
||||||
|
|
||||||
|
@given("we create a cache directory", target_fixture="cache_dir")
|
||||||
|
def create_cache_dir(temp_dir):
|
||||||
|
random_str = "".join(random.choices(string.ascii_uppercase + string.digits, k=20))
|
||||||
|
|
||||||
|
dir_path = os.path.join(temp_dir.name, "cache_" + random_str)
|
||||||
|
os.mkdir(dir_path)
|
||||||
|
return {"exists": True, "path": dir_path}
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse('the content of file "{file_path}" in the cache should be\n{file_content}'))
|
||||||
|
def content_of_file_should_be(file_path, file_content, cache_dir):
|
||||||
|
assert cache_dir["exists"]
|
||||||
|
expected_content = file_content.strip().splitlines()
|
||||||
|
|
||||||
|
with open(os.path.join(cache_dir["path"], file_path), "r") as f:
|
||||||
|
actual_content = f.read().strip().splitlines()
|
||||||
|
|
||||||
|
for actual_line, expected_line in zip(actual_content, expected_content):
|
||||||
|
if actual_line.startswith("tags: ") and expected_line.startswith("tags: "):
|
||||||
|
assert_equal_tags_ignoring_order(
|
||||||
|
actual_line, expected_line, actual_content, expected_content
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
assert actual_line.strip() == expected_line.strip(), [
|
||||||
|
[actual_line.strip(), expected_line.strip()],
|
||||||
|
[actual_content, expected_content],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def assert_equal_tags_ignoring_order(
|
||||||
|
actual_line, expected_line, actual_content, expected_content
|
||||||
|
):
|
||||||
|
actual_tags = set(tag.strip() for tag in actual_line[len("tags: ") :].split(","))
|
||||||
|
expected_tags = set(
|
||||||
|
tag.strip() for tag in expected_line[len("tags: ") :].split(",")
|
||||||
|
)
|
||||||
|
assert actual_tags == expected_tags, [
|
||||||
|
[actual_tags, expected_tags],
|
||||||
|
[expected_content, actual_content],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse("the cache should contain the files\n{file_list}"))
|
||||||
|
def cache_dir_contains_files(file_list, cache_dir):
|
||||||
|
assert cache_dir["exists"]
|
||||||
|
|
||||||
|
actual_files = os.listdir(cache_dir["path"])
|
||||||
|
expected_files = file_list.split("\n")
|
||||||
|
|
||||||
|
# sort to deal with inconsistent default file ordering on different OS's
|
||||||
|
actual_files.sort()
|
||||||
|
expected_files.sort()
|
||||||
|
|
||||||
|
assert actual_files == expected_files, [actual_files, expected_files]
|
||||||
|
|
||||||
|
|
||||||
|
@then("the output should be a valid XML string")
|
||||||
|
def assert_valid_xml_string(cli_run):
|
||||||
|
output = cli_run["stdout"]
|
||||||
|
xml_tree = ElementTree.fromstring(output)
|
||||||
|
assert xml_tree, output
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse('"{item}" node in the xml output should have {number:d} elements'))
|
||||||
|
def assert_xml_output_entries_count(item, number, cli_run):
|
||||||
|
output = cli_run["stdout"]
|
||||||
|
xml_tree = ElementTree.fromstring(output)
|
||||||
|
|
||||||
|
xml_tags = (node.tag for node in xml_tree)
|
||||||
|
assert item in xml_tags, str(list(xml_tags))
|
||||||
|
|
||||||
|
actual_entry_count = len(xml_tree.find(item))
|
||||||
|
assert actual_entry_count == number, actual_entry_count
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse('"tags" in the xml output should contain\n{expected_tags}'))
|
||||||
|
def assert_xml_output_tags(expected_tags, cli_run):
|
||||||
|
output = cli_run["stdout"]
|
||||||
|
expected_tags = expected_tags.split("\n")
|
||||||
|
|
||||||
|
xml_tree = ElementTree.fromstring(output)
|
||||||
|
|
||||||
|
xml_tags = (node.tag for node in xml_tree)
|
||||||
|
assert "tags" in xml_tags, str(list(xml_tags))
|
||||||
|
|
||||||
|
actual_tags = set(t.attrib["name"] for t in xml_tree.find("tags"))
|
||||||
|
assert actual_tags == set(expected_tags), [actual_tags, set(expected_tags)]
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse('there should be {number:d} "{item}" elements'))
|
||||||
|
def count_elements(number, item, cli_run):
|
||||||
|
output = cli_run["stdout"]
|
||||||
|
xml_tree = ElementTree.fromstring(output)
|
||||||
|
assert len(xml_tree.findall(".//" + item)) == number
|
||||||
|
|
|
@ -6,7 +6,7 @@ scenarios("../features/datetime.feature")
|
||||||
scenarios("../features/delete.feature")
|
scenarios("../features/delete.feature")
|
||||||
scenarios("../features/encrypt.feature")
|
scenarios("../features/encrypt.feature")
|
||||||
# scenarios("../features/file_storage.feature")
|
# scenarios("../features/file_storage.feature")
|
||||||
# scenarios("../features/format.feature")
|
scenarios("../features/format.feature")
|
||||||
# scenarios("../features/import.feature")
|
# scenarios("../features/import.feature")
|
||||||
# scenarios("../features/multiple_journals.feature")
|
# scenarios("../features/multiple_journals.feature")
|
||||||
scenarios("../features/password.feature")
|
scenarios("../features/password.feature")
|
||||||
|
|
Loading…
Add table
Reference in a new issue