More test shuffling

- Move more tests around
- Rename some test files
- Disable one test (markdown-355)
  Not sure why it's now failing. We should come back to this.
- Add more placeholder test scenarios (marked with @todo)
  You can run just these tests with `behave --no-skipped --tags=todo`
- Fix "missing_directory" test
  This test was missing the config file it was trying to use. So, it was
  really a very useless, broken test that we absolutely should not have
  approved the PR (#963) for.
This commit is contained in:
Jonathan Wren 2020-09-05 19:05:13 -07:00
parent 78d362e0db
commit 1d11f3db32
No known key found for this signature in database
GPG key ID: 43D5FF8722E7F68A
17 changed files with 301 additions and 225 deletions

View file

@ -9,3 +9,16 @@ Feature: Reading & writing the config file
And one editor argument should be "-c"
And one editor argument should match "'?setf markdown'?"
Scenario: Invalid color configuration
Given we use the config "invalid_color.yaml"
When we run "jrnl -on 2013-06-10 -s"
Then the output should be
"""
2013-06-10 15:40 Life is good.
"""
And we should get no error
And the error output should contain
"""
body set to invalid color
"""

View file

@ -1,29 +0,0 @@
Feature: Contains
Scenario: Searching for a string
Given we use the config "basic.yaml"
When we run "jrnl -contains life"
Then we should get no error
And the output should be
"""
2013-06-10 15:40 Life is good.
| But I'm better.
"""
Scenario: Searching for a string within tag results
Given we use the config "tags.yaml"
When we run "jrnl @idea -contains software"
Then we should get no error
And the output should contain "software"
Scenario: Searching for a string within AND tag results
Given we use the config "tags.yaml"
When we run "jrnl -and @journal @idea -contains software"
Then we should get no error
And the output should contain "software"
Scenario: Searching for a string within NOT tag results
Given we use the config "tags.yaml"
When we run "jrnl -not @dan -contains software"
Then we should get no error
And the output should contain "software"

View file

@ -1,52 +1,4 @@
Feature: Basic reading and writing to a journal
Scenario: Loading a sample journal
Given we use the config "basic.yaml"
When we run "jrnl -n 2"
Then we should get no error
And the output should be
"""
2013-06-09 15:39 My first entry.
| Everything is alright
2013-06-10 15:40 Life is good.
| But I'm better.
"""
Scenario: Printing a journal that has multiline entries
Given we use the config "multiline.yaml"
When we run "jrnl -n 1"
Then we should get no error
And the output should be
"""
2013-06-09 15:39 Multiple line entry.
| This is the first line.
| This line doesn't have any ending punctuation
|
| There is a blank line above this.
"""
Scenario: Filtering for dates
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"
Then the output should be "2013-06-10 15:40 Life is good."
Scenario: Emoji support
Given we use the config "basic.yaml"
When we run "jrnl 23 july 2013: 🌞 sunny day. Saw an 🐘"
Then we should see the message "Entry added"
When we run "jrnl -n 1"
Then the output should contain "🌞"
And the output should contain "🐘"
Scenario: Writing an entry at the prompt
Given we use the config "basic.yaml"
When we run "jrnl" and enter "25 jul 2013: I saw Elvis. He's alive."
Then we should get no error
And the journal should contain "[2013-07-25 09:00] I saw Elvis."
And the journal should contain "He's alive."
Feature: Core functionality of jrnl outside of actually handling journals
Scenario: Displaying the version number
Given we use the config "basic.yaml"
@ -64,21 +16,6 @@ Feature: Basic reading and writing to a journal
When we run "jrnl -on 2013-06-10 -s"
Then the output should be "2013-06-10 15:40 Life is good."
Scenario: Invalid color configuration
Given we use the config "invalid_color.yaml"
When we run "jrnl -on 2013-06-10 -s"
Then the output should be
"""
2013-06-10 15:40 Life is good.
"""
And we should get no error
Scenario: Journal directory does not exist
Given we use the config "missing_directory.yaml"
When we run "jrnl Life is good"
And we run "jrnl -n 1"
Then the output should contain "Life is good"
Scenario: Installation with relative journal and referencing from another folder
Given we use the config "missingconfig"
When we run "jrnl hello world" and enter

View file

@ -0,0 +1,17 @@
default_hour: 9
default_minute: 0
editor: ""
encrypt: false
highlight: true
journals:
default: features/journals/missing_directory/simple.journal
linewrap: 80
tagsymbols: "@"
template: false
timeformat: "%Y-%m-%d %H:%M"
indent_character: "|"
colors:
date: none
title: none
body: none
tags: none

View file

@ -0,0 +1,17 @@
default_hour: 9
default_minute: 0
editor: ""
encrypt: false
highlight: true
journals:
default: features/journals/missing.journal
linewrap: 80
tagsymbols: "@"
template: false
timeformat: "%Y-%m-%d %H:%M"
indent_character: "|"
colors:
date: none
title: none
body: none
tags: none

View file

@ -70,3 +70,18 @@ Feature: Reading and writing to journal with custom date formats
When we run "jrnl -1"
Then the output should contain "friday at 9am" in the local time
Scenario: Journals with unreadable dates should still be loaded
Given we use the config "unreadabledates.yaml"
When we run "jrnl -2"
Then the output should contain "I've lost track of time."
And the output should contain "Time has no meaning."
Scenario: Journals with readable dates AND unreadable dates should still contain all data.
Given we use the config "mostlyreadabledates.yaml"
When we run "jrnl -3"
Then the output should contain "Time machines are possible."
When we run "jrnl -1"
Then the output should contain "I'm going to activate the machine."
And the output should contain "I've crossed so many timelines. Is there any going back?"

View file

@ -1,10 +1,4 @@
Feature: Encrypting and decrypting journals
Scenario: Loading an encrypted journal
Given we use the config "encrypted.yaml"
When we run "jrnl -n 1" and enter "bad doggie no biscuit"
Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good"
Feature: Encrypting and decrypting journals
Scenario: Decrypting a journal
Given we use the config "encrypted.yaml"
@ -13,13 +7,18 @@
And we should see the message "Journal decrypted"
And the journal should have 2 entries
Scenario: Trying to decrypt an unencrypted journal
@todo
Scenario: Trying to decrypt an already unencrypted journal
# This should warn the user that the journal is already encrypted
Given we use the config "basic.yaml"
When we run "jrnl --decrypt"
Then the config for journal "default" should have "encrypt" set to "bool:False"
And we should get no error
And the journal should have 2 entries
@todo
Scenario: Trying to encrypt an already encrypted journal
# This should warn the user that the journal is already encrypted
Scenario: Encrypting a journal
Given we use the config "basic.yaml"
When we run "jrnl --encrypt" and enter
@ -34,70 +33,3 @@
Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good"
Scenario: Mistyping your password
Given we use the config "basic.yaml"
When we run "jrnl --encrypt" and enter
"""
swordfish
sordfish
"""
Then we should be prompted for a password
And we should see the message "Passwords did not match"
And the config for journal "default" should not have "encrypt" set
And the journal should have 2 entries
Scenario: Mistyping your password, then getting it right
Given we use the config "basic.yaml"
When we run "jrnl --encrypt" and enter
"""
swordfish
sordfish
swordfish
swordfish
n
"""
Then we should be prompted for a password
And we should see the message "Passwords did not match"
And we should see the message "Journal encrypted"
And the config for journal "default" should have "encrypt" set to "bool:True"
When we run "jrnl -n 1" and enter "swordfish"
Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good"
Scenario: Storing a password in keyring
Given we use the config "multiple.yaml"
And we have a keyring
When we run "jrnl simple --encrypt" and enter
"""
sabertooth
sabertooth
y
"""
Then the config for journal "simple" should have "encrypt" set to "bool:True"
When we run "jrnl simple -n 1"
Then the output should contain "2013-06-10 15:40 Life is good"
But the output should not contain "Password"
Scenario: Encrypt journal with no keyring backend and do not store in keyring
Given we use the config "basic.yaml"
And we do not have a keyring
When we run "jrnl test entry"
And we run "jrnl --encrypt" and enter
"""
password
password
n
"""
Then we should get no error
Scenario: Encrypt journal with no keyring backend and do store in keyring
Given we use the config "basic.yaml"
And we do not have a keyring
When we run "jrnl test entry"
And we run "jrnl --encrypt" and enter
"""
password
password
y
"""
Then we should get no error

View file

@ -1,6 +1,6 @@
Feature: Exporting a Journal
Feature: Custom formats
Scenario: Exporting to json
Scenario: JSON format
Given we use the config "tags.yaml"
When we run "jrnl --export json"
Then we should get no error
@ -75,6 +75,7 @@ Feature: Exporting a Journal
####### ATX H4
######## ATX H5
######### ATX H6
@ -91,7 +92,7 @@ Feature: Exporting a Journal
# https://github.com/jrnl-org/jrnl/issues/768
# https://github.com/jrnl-org/jrnl/issues/881
Given we use the config "deletion.yaml"
When we run "jrnl --export markdown"
When we run "jrnl --format markdown"
Then the output should be
"""
# 2019

View file

@ -0,0 +1,51 @@
Feature: Loading the default journal type
Scenario: Loading a sample journal
Given we use the config "basic.yaml"
When we run "jrnl -2"
Then we should get no error
And the output should be
"""
2013-06-09 15:39 My first entry.
| Everything is alright
2013-06-10 15:40 Life is good.
| But I'm better.
"""
Scenario: Printing a journal that has multiline entries
Given we use the config "multiline.yaml"
When we run "jrnl -n 1"
Then we should get no error
And the output should be
"""
2013-06-09 15:39 Multiple line entry.
| This is the first line.
| This line doesn't have any ending punctuation
|
| There is a blank line above this.
"""
Scenario: Integers in square brackets should not be read as dates
Given we use the config "brackets.yaml"
When we run "jrnl -1"
Then the output should contain "[1] line starting with 1"
Scenario: If the journal and it's parent directory don't exist, they should be created
Given we use the config "missing_directory.yaml"
Then the journal should not exist
When we run "jrnl This is a new entry in my journal"
Then the journal should exist
When we run "jrnl -n 1"
Then the output should contain "This is a new entry in my journal"
And the journal should have 1 entry
Scenario: If the journal file doesn't exist, then it should be created
Given we use the config "missing_journal.yaml"
Then the journal should not exist
When we run "jrnl This is a new entry in my journal"
Then the journal should exist
When we run "jrnl -n 1"
Then the output should contain "This is a new entry in my journal"
And the journal should have 1 entry

View file

@ -0,0 +1,37 @@
Feature: Loading the encrypted journal type
Scenario: Loading an encrypted journal
Given we use the config "encrypted.yaml"
When we run "jrnl -n 1" and enter "bad doggie no biscuit"
Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good"
Scenario: Mistyping your password
Given we use the config "basic.yaml"
When we run "jrnl --encrypt" and enter
"""
swordfish
sordfish
"""
Then we should be prompted for a password
And we should see the message "Passwords did not match"
And the config for journal "default" should not have "encrypt" set
And the journal should have 2 entries
Scenario: Mistyping your password, then getting it right
Given we use the config "basic.yaml"
When we run "jrnl --encrypt" and enter
"""
swordfish
sordfish
swordfish
swordfish
n
"""
Then we should be prompted for a password
And we should see the message "Passwords did not match"
And we should see the message "Journal encrypted"
And the config for journal "default" should have "encrypt" set to "bool:True"
When we run "jrnl -n 1" and enter "swordfish"
Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good"

47
features/keyring.feature Normal file
View file

@ -0,0 +1,47 @@
Feature: Using the installed keyring
Scenario: Storing a password in keyring
Given we use the config "multiple.yaml"
And we have a keyring
When we run "jrnl simple --encrypt" and enter
"""
sabertooth
sabertooth
y
"""
Then the config for journal "simple" should have "encrypt" set to "bool:True"
When we run "jrnl simple -n 1"
Then the output should contain "2013-06-10 15:40 Life is good"
But the output should not contain "Password"
Scenario: Encrypt journal with no keyring backend and do not store in keyring
Given we use the config "basic.yaml"
And we do not have a keyring
When we run "jrnl test entry"
And we run "jrnl --encrypt" and enter
"""
password
password
n
"""
Then we should get no error
Scenario: Encrypt journal with no keyring backend and do store in keyring
Given we use the config "basic.yaml"
And we do not have a keyring
When we run "jrnl test entry"
And we run "jrnl --encrypt" and enter
"""
password
password
y
"""
Then we should get no error
@todo
Scenario: Open an encrypted journal with wrong password in keyring
# This should ask the user for the password after the keyring fails
@todo
Scenario: Open encrypted journal when keyring exists but fails
# This should ask the user for the password after the keyring fails

View file

@ -1,21 +0,0 @@
Feature: Loading a journal from a file
Scenario: Integers in square brackets should not be read as dates
Given we use the config "brackets.yaml"
When we run "jrnl -1"
Then the output should contain "[1] line starting with 1"
Scenario: Journals with unreadable dates should still be loaded
Given we use the config "unreadabledates.yaml"
When we run "jrnl -2"
Then the output should contain "I've lost track of time."
And the output should contain "Time has no meaning."
Scenario: Journals with readable dates AND unreadable dates should still contain all data.
Given we use the config "mostlyreadabledates.yaml"
When we run "jrnl -3"
Then the output should contain "Time machines are possible."
When we run "jrnl -1"
Then the output should contain "I'm going to activate the machine."
And the output should contain "I've crossed so many timelines. Is there any going back?"

View file

@ -1,4 +1,4 @@
Feature: Searching a journal
Feature: Searching in a journal
Scenario: Displaying entries using -on today should display entries created today.
Given we use the config "basic.yaml"
@ -6,6 +6,8 @@ Feature: Searching a journal
Then we should see the message "Entry added"
When we run "jrnl -on today"
Then the output should contain "Adding an entry right now."
But the output should not contain "Everything is alright"
And the output should not contain "Life is good"
Scenario: Displaying entries using -from day should display correct entries
Given we use the config "basic.yaml"
@ -32,3 +34,39 @@ Feature: Searching a journal
Then the output should contain "This thing happened yesterday"
And the output should contain "Adding an entry right now."
And the output should not contain "A future entry."
Scenario: Searching for a string
Given we use the config "basic.yaml"
When we run "jrnl -contains life"
Then we should get no error
And the output should be
"""
2013-06-10 15:40 Life is good.
| But I'm better.
"""
Scenario: Searching for a string within tag results
Given we use the config "tags.yaml"
When we run "jrnl @idea -contains software"
Then we should get no error
And the output should contain "software"
Scenario: Searching for a string within AND tag results
Given we use the config "tags.yaml"
When we run "jrnl -and @journal @idea -contains software"
Then we should get no error
And the output should contain "software"
Scenario: Searching for a string within NOT tag results
Given we use the config "tags.yaml"
When we run "jrnl -not @dan -contains software"
Then we should get no error
And the output should contain "software"
Scenario: Searching for dates
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"
Then the output should be "2013-06-10 15:40 Life is good."

View file

@ -73,7 +73,6 @@ class FailedKeyring(keyring.backend.KeyringBackend):
priority = 2
keys = defaultdict(dict)
def set_password(self, servicename, username, password):
self.keys[servicename][username] = password
@ -116,27 +115,27 @@ def read_value_from_string(string):
# Takes strings like "bool:true" or "int:32" and coerces them into proper type
t, value = string.split(":")
value = {"bool": lambda v: v.lower() == "true", "int": int, "str": str}[t](
value
)
value = {"bool": lambda v: v.lower() == "true", "int": int, "str": str}[t](value)
return value
@given('we use the config "{config_file}"')
def set_config(context, config_file):
full_path = os.path.join("features/configs", config_file)
install.CONFIG_FILE_PATH = os.path.abspath(full_path)
if config_file.endswith("yaml"):
if config_file.endswith("yaml") and os.path.exists(full_path):
# Add jrnl version to file for 2.x journals
with open(install.CONFIG_FILE_PATH, "a") as cf:
cf.write("version: {}".format(__version__))
@given('we have a keyring')
@given("we have a keyring")
def set_keyring(context):
keyring.set_keyring(TestKeyring())
@given('we do not have a keyring')
@given("we do not have a keyring")
def disable_keyring(context):
keyring.core.set_keyring(NoKeyring())
@ -342,7 +341,7 @@ def load_template(context, filename):
@when('we set the keyring password of "{journal}" to "{password}"')
def set_keyring(context, journal, password):
def set_keyring_password(context, journal, password):
keyring.set_password("jrnl", journal, password)
@ -439,6 +438,7 @@ def check_not_journal_content(context, text, journal_name="default"):
assert text not in journal, journal
@then('the journal should not exist')
@then('journal "{journal_name}" should not exist')
def journal_doesnt_exist(context, journal_name="default"):
config = load_config(install.CONFIG_FILE_PATH)
@ -446,6 +446,13 @@ def journal_doesnt_exist(context, journal_name="default"):
journal_path = config["journals"][journal_name]
assert not os.path.exists(journal_path)
@then('the journal should exist')
@then('journal "{journal_name}" should exist')
def journal_exists(context, journal_name="default"):
config = load_config(install.CONFIG_FILE_PATH)
journal_path = config["journals"][journal_name]
assert os.path.exists(journal_path)
@then('the config should have "{key}" set to')
@then('the config should have "{key}" set to "{value}"')
@ -462,7 +469,7 @@ def config_var(context, key, value="", journal=None):
@then('the config for journal "{journal}" should not have "{key}" set')
def config_var(context, key, value="", journal=None):
def config_no_var(context, key, value="", journal=None):
config = load_config(install.CONFIG_FILE_PATH)
if journal:

View file

@ -55,3 +55,17 @@ Feature: Writing new entries.
| Hope to get a lot of traffic.
"""
Scenario: Emoji support
Given we use the config "basic.yaml"
When we run "jrnl 23 july 2013: 🌞 sunny day. Saw an 🐘"
Then we should see the message "Entry added"
When we run "jrnl -n 1"
Then the output should contain "🌞"
And the output should contain "🐘"
Scenario: Writing an entry at the prompt (no editor)
Given we use the config "basic.yaml"
When we run "jrnl" and enter "25 jul 2013: I saw Elvis. He's alive."
Then we should get no error
And the journal should contain "[2013-07-25 09:00] I saw Elvis."
And the journal should contain "He's alive."