From e75e3d73a07e7ba0268b50df21873d82a0610f01 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Fri, 12 Sep 2014 15:28:12 -0700 Subject: [PATCH] Converts tests to YAML --- features/core.feature | 2 +- features/data/configs/bug153.json | 14 -------------- features/data/configs/bug153.yaml | 11 +++++++++++ features/data/configs/dayone.json | 14 -------------- features/data/configs/dayone.yaml | 11 +++++++++++ features/data/configs/empty_folder.json | 14 -------------- features/data/configs/empty_folder.yaml | 11 +++++++++++ features/data/configs/encrypted.json | 14 -------------- features/data/configs/encrypted.yaml | 11 +++++++++++ features/data/configs/encrypted_with_pw.json | 14 -------------- features/data/configs/encrypted_with_pw.yaml | 11 +++++++++++ features/data/configs/multiple.json | 17 ----------------- features/data/configs/multiple.yaml | 14 ++++++++++++++ features/data/configs/tags-216.json | 14 -------------- features/data/configs/tags-216.yaml | 11 +++++++++++ features/data/configs/tags-237.json | 14 -------------- features/data/configs/tags-237.yaml | 11 +++++++++++ features/data/configs/tags.json | 14 -------------- features/data/configs/tags.yaml | 11 +++++++++++ .../data/journals/encrypted_jrnl-1-9-5.journal | Bin 0 -> 128 bytes features/dayone.feature | 12 ++++++------ features/encryption.feature | 6 +++--- features/exporting.feature | 4 ++-- features/multiple_journals.feature | 12 ++++++------ features/regression.feature | 8 ++++---- features/steps/core.py | 7 ++++++- features/tagging.feature | 10 +++++----- jrnl/EncryptedJournal.py | 2 +- 28 files changed, 136 insertions(+), 158 deletions(-) delete mode 100644 features/data/configs/bug153.json create mode 100644 features/data/configs/bug153.yaml delete mode 100644 features/data/configs/dayone.json create mode 100644 features/data/configs/dayone.yaml delete mode 100644 features/data/configs/empty_folder.json create mode 100644 features/data/configs/empty_folder.yaml delete mode 100644 features/data/configs/encrypted.json create mode 100644 features/data/configs/encrypted.yaml delete mode 100644 features/data/configs/encrypted_with_pw.json create mode 100644 features/data/configs/encrypted_with_pw.yaml delete mode 100644 features/data/configs/multiple.json create mode 100644 features/data/configs/multiple.yaml delete mode 100644 features/data/configs/tags-216.json create mode 100644 features/data/configs/tags-216.yaml delete mode 100644 features/data/configs/tags-237.json create mode 100644 features/data/configs/tags-237.yaml delete mode 100644 features/data/configs/tags.json create mode 100644 features/data/configs/tags.yaml create mode 100644 features/data/journals/encrypted_jrnl-1-9-5.journal diff --git a/features/core.feature b/features/core.feature index ecb3df6e..85b13d90 100644 --- a/features/core.feature +++ b/features/core.feature @@ -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." 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" Then the output should be "2013-06-10 15:40 Life is good." When we run "jrnl -on 'june 6 2013' --short" diff --git a/features/data/configs/bug153.json b/features/data/configs/bug153.json deleted file mode 100644 index ad617928..00000000 --- a/features/data/configs/bug153.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/bug153.yaml b/features/data/configs/bug153.yaml new file mode 100644 index 00000000..a89c1965 --- /dev/null +++ b/features/data/configs/bug153.yaml @@ -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' diff --git a/features/data/configs/dayone.json b/features/data/configs/dayone.json deleted file mode 100644 index 2baf0080..00000000 --- a/features/data/configs/dayone.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/dayone.yaml b/features/data/configs/dayone.yaml new file mode 100644 index 00000000..5b06c73a --- /dev/null +++ b/features/data/configs/dayone.yaml @@ -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' diff --git a/features/data/configs/empty_folder.json b/features/data/configs/empty_folder.json deleted file mode 100644 index d270db03..00000000 --- a/features/data/configs/empty_folder.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/empty_folder.yaml b/features/data/configs/empty_folder.yaml new file mode 100644 index 00000000..d773a473 --- /dev/null +++ b/features/data/configs/empty_folder.yaml @@ -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' diff --git a/features/data/configs/encrypted.json b/features/data/configs/encrypted.json deleted file mode 100644 index a498974b..00000000 --- a/features/data/configs/encrypted.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/encrypted.yaml b/features/data/configs/encrypted.yaml new file mode 100644 index 00000000..fb456d28 --- /dev/null +++ b/features/data/configs/encrypted.yaml @@ -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' diff --git a/features/data/configs/encrypted_with_pw.json b/features/data/configs/encrypted_with_pw.json deleted file mode 100644 index 1a277240..00000000 --- a/features/data/configs/encrypted_with_pw.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/encrypted_with_pw.yaml b/features/data/configs/encrypted_with_pw.yaml new file mode 100644 index 00000000..3b4247a9 --- /dev/null +++ b/features/data/configs/encrypted_with_pw.yaml @@ -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' diff --git a/features/data/configs/multiple.json b/features/data/configs/multiple.json deleted file mode 100644 index 980c9353..00000000 --- a/features/data/configs/multiple.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/multiple.yaml b/features/data/configs/multiple.yaml new file mode 100644 index 00000000..8fccc3ba --- /dev/null +++ b/features/data/configs/multiple.yaml @@ -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' diff --git a/features/data/configs/tags-216.json b/features/data/configs/tags-216.json deleted file mode 100644 index 4164d6f5..00000000 --- a/features/data/configs/tags-216.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/tags-216.yaml b/features/data/configs/tags-216.yaml new file mode 100644 index 00000000..49d58e4c --- /dev/null +++ b/features/data/configs/tags-216.yaml @@ -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' diff --git a/features/data/configs/tags-237.json b/features/data/configs/tags-237.json deleted file mode 100644 index 55801a6d..00000000 --- a/features/data/configs/tags-237.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/tags-237.yaml b/features/data/configs/tags-237.yaml new file mode 100644 index 00000000..1e38c9ca --- /dev/null +++ b/features/data/configs/tags-237.yaml @@ -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' diff --git a/features/data/configs/tags.json b/features/data/configs/tags.json deleted file mode 100644 index dc69950c..00000000 --- a/features/data/configs/tags.json +++ /dev/null @@ -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": "@" -} diff --git a/features/data/configs/tags.yaml b/features/data/configs/tags.yaml new file mode 100644 index 00000000..6a00bf30 --- /dev/null +++ b/features/data/configs/tags.yaml @@ -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' diff --git a/features/data/journals/encrypted_jrnl-1-9-5.journal b/features/data/journals/encrypted_jrnl-1-9-5.journal new file mode 100644 index 0000000000000000000000000000000000000000..339b47baf9671f4550efeb9b6a0cfcd5032255d6 GIT binary patch literal 128 zcmV-`0Du3(bJIGVsY(mXmoW-2hF&*L`0NbJTYlTUr8*^Qm97}8E^3^1bZ$P^M literal 0 HcmV?d00001 diff --git a/features/dayone.feature b/features/dayone.feature index 23a3249d..d1e9ee65 100644 --- a/features/dayone.feature +++ b/features/dayone.feature @@ -1,7 +1,7 @@ Feature: DayOne Ingetration 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'" Then we should get no error 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 - Given we use the config "dayone.json" + Given we use the config "dayone.yaml" When we run "jrnl -until 'feb 2013'" Then we should get no error and the output should contain "2013-01-17T18:37Z" in the local time 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." and we run "jrnl -until 1980" Then the output should be @@ -29,7 +29,7 @@ Feature: DayOne Ingetration """ 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" Then the output should be """ @@ -38,7 +38,7 @@ Feature: DayOne Ingetration """ 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" and we run "jrnl --tags" Then the output should be @@ -48,7 +48,7 @@ Feature: DayOne Ingetration """ 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" Then the output should be """ diff --git a/features/encryption.feature b/features/encryption.feature index aa194ee2..cbbf15e5 100644 --- a/features/encryption.feature +++ b/features/encryption.feature @@ -1,13 +1,13 @@ Feature: Encrypted journals 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" Then we should see the message "Password" and the output should contain "2013-06-10 15:40 Life is good" 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" Then the config for journal "default" should have "encrypt" set to "bool:False" 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" 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 set the keychain password of "simple" to "sabertooth" Then the config for journal "simple" should have "encrypt" set to "bool:True" diff --git a/features/exporting.feature b/features/exporting.feature index 405b5496..003801a3 100644 --- a/features/exporting.feature +++ b/features/exporting.feature @@ -1,7 +1,7 @@ Feature: Exporting a Journal Scenario: Exporting to json - Given we use the config "tags.json" + Given we use the config "tags.yaml" When we run "jrnl --export json" Then we should get no error 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" 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" # Then we should get no error Then the output should be parsable as json diff --git a/features/multiple_journals.feature b/features/multiple_journals.feature index 0510209b..e78a7c8c 100644 --- a/features/multiple_journals.feature +++ b/features/multiple_journals.feature @@ -1,36 +1,36 @@ Feature: Multiple 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 and journal "work" should have 0 entries 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" Then journal "default" should have 3 entries and journal "work" should have 0 entries 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" Then journal "default" should have 2 entries and journal "work" should have 1 entry 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" Then we should see the message "Entry added to work journal" 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" Then journal "default" should have 2 entries and journal "work" should have 1 entry and journal "work" should contain "2012-07-23" 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 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 diff --git a/features/regression.feature b/features/regression.feature index 13ef6fcd..9ae04713 100644 --- a/features/regression.feature +++ b/features/regression.feature @@ -9,7 +9,7 @@ Feature: Zapped bugs should stay dead. Then the output should not contain "Life is good" 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" 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" @@ -23,14 +23,14 @@ Feature: Zapped bugs should stay dead. Scenario: Date in the future should be parsed correctly # 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." Then we should see the message "Entry added" and the journal should contain "2019-06-26 09:00 Planet?" Scenario: Loading entry with ambiguous time stamp #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" Then we should get no error and the output should be @@ -50,7 +50,7 @@ Feature: Zapped bugs should stay dead. """ 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." Then we should see the message "Entry added" When we run "jrnl -1" diff --git a/features/steps/core.py b/features/steps/core.py index 762c62e6..8e1e1652 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -1,8 +1,10 @@ from behave import * from jrnl import cli, install, Journal, util +from jrnl import __version__ from dateutil import parser as date_parser import os import json +import yaml import keyring keyring.set_keyring(keyring.backends.file.PlaintextKeyring()) try: @@ -48,6 +50,9 @@ def open_journal(journal_name="default"): def set_config(context, config_file): full_path = os.path.join("features/configs", config_file) 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') @@ -178,7 +183,7 @@ def check_journal_content(context, text, journal_name="default"): @then('journal "{journal_name}" should not exist') def journal_doesnt_exist(context, journal_name="default"): 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] assert not os.path.exists(journal_path) diff --git a/features/tagging.feature b/features/tagging.feature index 4eba8470..cc686673 100644 --- a/features/tagging.feature +++ b/features/tagging.feature @@ -1,7 +1,7 @@ Feature: Tagging Scenario: Displaying tags - Given we use the config "tags.json" + Given we use the config "tags.yaml" When we run "jrnl --tags" Then we should get no error and the output should be @@ -12,7 +12,7 @@ Feature: Tagging """ 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" Then we should get no error and the output should be @@ -22,7 +22,7 @@ Feature: Tagging """ 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" Then we should get no error and the output should be @@ -32,7 +32,7 @@ Feature: Tagging @c# : 1 """ 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" Then we should get no error and the output should be @@ -42,7 +42,7 @@ Feature: Tagging """ 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 --tags" Then the output should be diff --git a/jrnl/EncryptedJournal.py b/jrnl/EncryptedJournal.py index 4d9ce944..c80bcc08 100644 --- a/jrnl/EncryptedJournal.py +++ b/jrnl/EncryptedJournal.py @@ -5,7 +5,7 @@ from passlib.hash import pbkdf2_sha256 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)