Converts tests to YAML

This commit is contained in:
Manuel Ebert 2014-09-12 15:28:12 -07:00
parent 0a19701ae9
commit e75e3d73a0
28 changed files with 136 additions and 158 deletions

View file

@ -21,7 +21,7 @@ Feature: Basic reading and writing to a journal
Then the output should contain "2013-07-23 09:00 A cold and stormy day." Then the output should contain "2013-07-23 09:00 A cold and stormy day."
Scenario: Filtering for dates Scenario: Filtering for dates
Given we use the config "basic.json" Given we use the config "basic.yaml"
When we run "jrnl -on 2013-06-10 --short" When we run "jrnl -on 2013-06-10 --short"
Then the output should be "2013-06-10 15:40 Life is good." Then the output should be "2013-06-10 15:40 Life is good."
When we run "jrnl -on 'june 6 2013' --short" When we run "jrnl -on 'june 6 2013' --short"

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/bug153.dayone"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/bug153.dayone
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/dayone.dayone"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/dayone.dayone
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/empty_folder"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/empty_folder
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": true,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/encrypted.journal"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: true
highlight: true
journals:
default: features/journals/encrypted.journal
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": true,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "bad doggie no biscuit",
"journals": {
"default": "features/journals/encrypted.journal"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: true
highlight: true
journals:
default: features/journals/encrypted.journal
linewrap: 80
password: bad doggie no biscuit
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,17 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/simple.journal",
"simple": "features/journals/simple.journal",
"work": "features/journals/work.journal",
"ideas": "features/journals/nothing.journal"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,14 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/simple.journal
ideas: features/journals/nothing.journal
simple: features/journals/simple.journal
work: features/journals/work.journal
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/tags-216.journal"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/tags-216.journal
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/tags-237.journal"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/tags-237.journal
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

View file

@ -1,14 +0,0 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/tags.journal"
},
"tagsymbols": "@"
}

View file

@ -0,0 +1,11 @@
default_hour: 9
default_minute: 0
editor: ''
encrypt: false
highlight: true
journals:
default: features/journals/tags.journal
linewrap: 80
password: ''
tagsymbols: '@'
timeformat: '%Y-%m-%d %H:%M'

Binary file not shown.

View file

@ -1,7 +1,7 @@
Feature: DayOne Ingetration Feature: DayOne Ingetration
Scenario: Loading a DayOne Journal Scenario: Loading a DayOne Journal
Given we use the config "dayone.json" Given we use the config "dayone.yaml"
When we run "jrnl -from 'feb 2013'" When we run "jrnl -from 'feb 2013'"
Then we should get no error Then we should get no error
and the output should be and the output should be
@ -14,13 +14,13 @@ Feature: DayOne Ingetration
""" """
Scenario: Entries without timezone information will be interpreted as in the current timezone Scenario: Entries without timezone information will be interpreted as in the current timezone
Given we use the config "dayone.json" Given we use the config "dayone.yaml"
When we run "jrnl -until 'feb 2013'" When we run "jrnl -until 'feb 2013'"
Then we should get no error Then we should get no error
and the output should contain "2013-01-17T18:37Z" in the local time and the output should contain "2013-01-17T18:37Z" in the local time
Scenario: Writing into Dayone Scenario: Writing into Dayone
Given we use the config "dayone.json" 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."
and we run "jrnl -until 1980" and we run "jrnl -until 1980"
Then the output should be Then the output should be
@ -29,7 +29,7 @@ Feature: DayOne Ingetration
""" """
Scenario: Loading tags from a DayOne Journal Scenario: Loading tags from a DayOne Journal
Given we use the config "dayone.json" Given we use the config "dayone.yaml"
When we run "jrnl --tags" When we run "jrnl --tags"
Then the output should be Then the output should be
""" """
@ -38,7 +38,7 @@ Feature: DayOne Ingetration
""" """
Scenario: Saving tags from a DayOne Journal Scenario: Saving tags from a DayOne Journal
Given we use the config "dayone.json" Given we use the config "dayone.yaml"
When we run "jrnl A hard day at @work" When we run "jrnl A hard day at @work"
and we run "jrnl --tags" and we run "jrnl --tags"
Then the output should be Then the output should be
@ -48,7 +48,7 @@ Feature: DayOne Ingetration
""" """
Scenario: Filtering by tags from a DayOne Journal Scenario: Filtering by tags from a DayOne Journal
Given we use the config "dayone.json" Given we use the config "dayone.yaml"
When we run "jrnl @work" When we run "jrnl @work"
Then the output should be Then the output should be
""" """

View file

@ -1,13 +1,13 @@
Feature: Encrypted journals Feature: Encrypted journals
Scenario: Loading an encrypted journal Scenario: Loading an encrypted journal
Given we use the config "encrypted.json" Given we use the config "encrypted.yaml"
When we run "jrnl -n 1" and enter "bad doggie no biscuit" When we run "jrnl -n 1" and enter "bad doggie no biscuit"
Then we should see the message "Password" Then we should see the message "Password"
and the output should contain "2013-06-10 15:40 Life is good" and the output should contain "2013-06-10 15:40 Life is good"
Scenario: Decrypting a journal Scenario: Decrypting a journal
Given we use the config "encrypted.json" Given we use the config "encrypted.yaml"
When we run "jrnl --decrypt" and enter "bad doggie no biscuit" When we run "jrnl --decrypt" and enter "bad doggie no biscuit"
Then the config for journal "default" should have "encrypt" set to "bool:False" Then the config for journal "default" should have "encrypt" set to "bool:False"
Then we should see the message "Journal decrypted" Then we should see the message "Journal decrypted"
@ -23,7 +23,7 @@
and the output should contain "2013-06-10 15:40 Life is good" and the output should contain "2013-06-10 15:40 Life is good"
Scenario: Storing a password in Keychain Scenario: Storing a password in Keychain
Given we use the config "multiple.json" Given we use the config "multiple.yaml"
When we run "jrnl simple --encrypt" and enter "sabertooth" When we run "jrnl simple --encrypt" and enter "sabertooth"
When we set the keychain password of "simple" to "sabertooth" When we set the keychain password of "simple" to "sabertooth"
Then the config for journal "simple" should have "encrypt" set to "bool:True" Then the config for journal "simple" should have "encrypt" set to "bool:True"

View file

@ -1,7 +1,7 @@
Feature: Exporting a Journal Feature: Exporting a Journal
Scenario: Exporting to json Scenario: Exporting to json
Given we use the config "tags.json" Given we use the config "tags.yaml"
When we run "jrnl --export json" When we run "jrnl --export json"
Then we should get no error Then we should get no error
and the output should be parsable as json and the output should be parsable as json
@ -11,7 +11,7 @@ Feature: Exporting a Journal
and "tags" in the json output should contain "@dan" and "tags" in the json output should contain "@dan"
Scenario: Exporting using filters should only export parts of the journal Scenario: Exporting using filters should only export parts of the journal
Given we use the config "tags.json" Given we use the config "tags.yaml"
When we run "jrnl -until 'may 2013' --export json" When we run "jrnl -until 'may 2013' --export json"
# Then we should get no error # Then we should get no error
Then the output should be parsable as json Then the output should be parsable as json

View file

@ -1,36 +1,36 @@
Feature: Multiple journals Feature: Multiple journals
Scenario: Loading a config with two journals Scenario: Loading a config with two journals
Given we use the config "multiple.json" Given we use the config "multiple.yaml"
Then journal "default" should have 2 entries Then journal "default" should have 2 entries
and journal "work" should have 0 entries and journal "work" should have 0 entries
Scenario: Write to default config by default Scenario: Write to default config by default
Given we use the config "multiple.json" Given we use the config "multiple.yaml"
When we run "jrnl this goes to default" When we run "jrnl this goes to default"
Then journal "default" should have 3 entries Then journal "default" should have 3 entries
and journal "work" should have 0 entries and journal "work" should have 0 entries
Scenario: Write to specified journal Scenario: Write to specified journal
Given we use the config "multiple.json" Given we use the config "multiple.yaml"
When we run "jrnl work a long day in the office" When we run "jrnl work a long day in the office"
Then journal "default" should have 2 entries Then journal "default" should have 2 entries
and journal "work" should have 1 entry and journal "work" should have 1 entry
Scenario: Tell user which journal was used Scenario: Tell user which journal was used
Given we use the config "multiple.json" Given we use the config "multiple.yaml"
When we run "jrnl work a long day in the office" When we run "jrnl work a long day in the office"
Then we should see the message "Entry added to work journal" Then we should see the message "Entry added to work journal"
Scenario: Write to specified journal with a timestamp Scenario: Write to specified journal with a timestamp
Given we use the config "multiple.json" Given we use the config "multiple.yaml"
When we run "jrnl work 23 july 2012: a long day in the office" When we run "jrnl work 23 july 2012: a long day in the office"
Then journal "default" should have 2 entries Then journal "default" should have 2 entries
and journal "work" should have 1 entry and journal "work" should have 1 entry
and journal "work" should contain "2012-07-23" and journal "work" should contain "2012-07-23"
Scenario: Create new journals as required Scenario: Create new journals as required
Given we use the config "multiple.json" Given we use the config "multiple.yaml"
Then journal "ideas" should not exist Then journal "ideas" should not exist
When we run "jrnl ideas 23 july 2012: sell my junk on ebay and make lots of money" When we run "jrnl ideas 23 july 2012: sell my junk on ebay and make lots of money"
Then journal "ideas" should have 1 entry Then journal "ideas" should have 1 entry

View file

@ -9,7 +9,7 @@ Feature: Zapped bugs should stay dead.
Then the output should not contain "Life is good" Then the output should not contain "Life is good"
Scenario: Opening an folder that's not a DayOne folder gives a nice error message Scenario: Opening an folder that's not a DayOne folder gives a nice error message
Given we use the config "empty_folder.json" Given we use the config "empty_folder.yaml"
When we run "jrnl Herro" When we run "jrnl Herro"
Then we should get an error Then we should get an error
Then we should see the message "is a directory, but doesn't seem to be a DayOne journal either" Then we should see the message "is a directory, but doesn't seem to be a DayOne journal either"
@ -23,14 +23,14 @@ Feature: Zapped bugs should stay dead.
Scenario: Date in the future should be parsed correctly Scenario: Date in the future should be parsed correctly
# https://github.com/maebert/jrnl/issues/185 # https://github.com/maebert/jrnl/issues/185
Given we use the config "basic.json" Given we use the config "basic.yaml"
When we run "jrnl 26/06/2019: Planet? Earth. Year? 2019." When we run "jrnl 26/06/2019: Planet? Earth. Year? 2019."
Then we should see the message "Entry added" Then we should see the message "Entry added"
and the journal should contain "2019-06-26 09:00 Planet?" and the journal should contain "2019-06-26 09:00 Planet?"
Scenario: Loading entry with ambiguous time stamp Scenario: Loading entry with ambiguous time stamp
#https://github.com/maebert/jrnl/issues/153 #https://github.com/maebert/jrnl/issues/153
Given we use the config "bug153.json" Given we use the config "bug153.yaml"
When we run "jrnl -1" When we run "jrnl -1"
Then we should get no error Then we should get no error
and the output should be and the output should be
@ -50,7 +50,7 @@ Feature: Zapped bugs should stay dead.
""" """
Scenario: Title with an embedded period on DayOne journal Scenario: Title with an embedded period on DayOne journal
Given we use the config "dayone.json" Given we use the config "dayone.yaml"
When we run "jrnl 04-24-2014: Ran 6.2 miles today in 1:02:03. I'm feeling sore because I forgot to stretch." When we run "jrnl 04-24-2014: Ran 6.2 miles today in 1:02:03. I'm feeling sore because I forgot to stretch."
Then we should see the message "Entry added" Then we should see the message "Entry added"
When we run "jrnl -1" When we run "jrnl -1"

View file

@ -1,8 +1,10 @@
from behave import * from behave import *
from jrnl import cli, install, Journal, util from jrnl import cli, install, Journal, util
from jrnl import __version__
from dateutil import parser as date_parser from dateutil import parser as date_parser
import os import os
import json import json
import yaml
import keyring import keyring
keyring.set_keyring(keyring.backends.file.PlaintextKeyring()) keyring.set_keyring(keyring.backends.file.PlaintextKeyring())
try: try:
@ -48,6 +50,9 @@ def open_journal(journal_name="default"):
def set_config(context, config_file): def set_config(context, config_file):
full_path = os.path.join("features/configs", config_file) full_path = os.path.join("features/configs", config_file)
install.CONFIG_FILE_PATH = os.path.abspath(full_path) install.CONFIG_FILE_PATH = os.path.abspath(full_path)
# Add jrnl version to file
with open(install.CONFIG_FILE_PATH, 'a') as cf:
cf.write("version: {}".format(__version__))
@when('we run "{command}" and enter') @when('we run "{command}" and enter')
@ -178,7 +183,7 @@ def check_journal_content(context, text, journal_name="default"):
@then('journal "{journal_name}" should not exist') @then('journal "{journal_name}" should not exist')
def journal_doesnt_exist(context, journal_name="default"): def journal_doesnt_exist(context, journal_name="default"):
with open(install.CONFIG_FILE_PATH) as config_file: with open(install.CONFIG_FILE_PATH) as config_file:
config = json.load(config_file) config = yaml.load(config_file)
journal_path = config['journals'][journal_name] journal_path = config['journals'][journal_name]
assert not os.path.exists(journal_path) assert not os.path.exists(journal_path)

View file

@ -1,7 +1,7 @@
Feature: Tagging Feature: Tagging
Scenario: Displaying tags Scenario: Displaying tags
Given we use the config "tags.json" Given we use the config "tags.yaml"
When we run "jrnl --tags" When we run "jrnl --tags"
Then we should get no error Then we should get no error
and the output should be and the output should be
@ -12,7 +12,7 @@ Feature: Tagging
""" """
Scenario: Filtering journals should also filter tags Scenario: Filtering journals should also filter tags
Given we use the config "tags.json" Given we use the config "tags.yaml"
When we run "jrnl -from 'may 2013' --tags" When we run "jrnl -from 'may 2013' --tags"
Then we should get no error Then we should get no error
and the output should be and the output should be
@ -22,7 +22,7 @@ Feature: Tagging
""" """
Scenario: Tags should allow certain special characters Scenario: Tags should allow certain special characters
Given we use the config "tags-216.json" Given we use the config "tags-216.yaml"
When we run "jrnl --tags" When we run "jrnl --tags"
Then we should get no error Then we should get no error
and the output should be and the output should be
@ -32,7 +32,7 @@ Feature: Tagging
@c# : 1 @c# : 1
""" """
Scenario: An email should not be a tag Scenario: An email should not be a tag
Given we use the config "tags-237.json" Given we use the config "tags-237.yaml"
When we run "jrnl --tags" When we run "jrnl --tags"
Then we should get no error Then we should get no error
and the output should be and the output should be
@ -42,7 +42,7 @@ Feature: Tagging
""" """
Scenario: Entry cans start and end with tags Scenario: Entry cans start and end with tags
Given we use the config "basic.json" Given we use the config "basic.yaml"
When we run "jrnl today: @foo came over, we went to a @bar" When we run "jrnl today: @foo came over, we went to a @bar"
When we run "jrnl --tags" When we run "jrnl --tags"
Then the output should be Then the output should be

View file

@ -5,7 +5,7 @@ from passlib.hash import pbkdf2_sha256
def make_key(password): def make_key(password):
derived_key = pbkdf2_sha256.encrypt(password.encode("utf-8"), rounds=10000, salt_size=16) derived_key = pbkdf2_sha256.encrypt(password.encode("utf-8"), rounds=10000, salt_size=32)
return base64.urlsafe_b64encode(derived_key) return base64.urlsafe_b64encode(derived_key)