mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-27 21:16:14 +02:00
Improve handling of mocking logic in pytest (#1382)
* WIP * fix handling of user input (stdin, input, getpass) * take out redundant pytest step * fix handling of 'we should' statements * fix test that doesn't use a config file * fix another test that uses stdin Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com> * remove .tool-versions file per PR feedback * add comment to clarify why disembodied variables are here Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
3518e37087
commit
2ab485de8c
16 changed files with 259 additions and 197 deletions
|
@ -29,7 +29,7 @@ Feature: Multiple journals
|
|||
Given the config "multiple.yaml" exists
|
||||
And we use the config "basic_onefile.yaml"
|
||||
When we run "jrnl --cf multiple.yaml work a long day in the office"
|
||||
Then we should see the message "Entry added to work journal"
|
||||
Then the output should contain "Entry added to work journal"
|
||||
|
||||
Scenario: Write to specified journal with a timestamp using an alternate config
|
||||
Given the config "multiple.yaml" exists
|
||||
|
@ -64,7 +64,7 @@ Feature: Multiple journals
|
|||
Given the config "bug343.yaml" exists
|
||||
And we use the config "basic_onefile.yaml"
|
||||
When we run "jrnl --cf bug343.yaml a long day in the office"
|
||||
Then we should see the message "No default journal configured"
|
||||
Then the output should contain "No default journal configured"
|
||||
|
||||
Scenario: Don't crash if no file exists for a configured encrypted journal using an alternate config
|
||||
Given the config "multiple.yaml" exists
|
||||
|
@ -73,7 +73,7 @@ Feature: Multiple journals
|
|||
these three eyes
|
||||
these three eyes
|
||||
n
|
||||
Then we should see the message "Encrypted journal 'new_encrypted' created"
|
||||
Then the output should contain "Encrypted journal 'new_encrypted' created"
|
||||
|
||||
Scenario: Don't overwrite main config when encrypting a journal in an alternate config
|
||||
Given the config "basic_onefile.yaml" exists
|
||||
|
@ -82,11 +82,14 @@ Feature: Multiple journals
|
|||
these three eyes
|
||||
these three eyes
|
||||
n
|
||||
Then we should see the message "Journal encrypted to features/journals/basic_onefile.journal"
|
||||
And the config should contain "encrypt: false" # multiple.yaml remains unchanged
|
||||
Then the output should contain "Journal encrypted to features/journals/basic_onefile.journal"
|
||||
And the config should contain "encrypt: false"
|
||||
|
||||
|
||||
Scenario: Don't overwrite main config when decrypting a journal in an alternate config
|
||||
Given the config "editor_encrypted.yaml" exists
|
||||
And we use the password "bad doggie no biscuit" if prompted
|
||||
And we use the config "basic_encrypted.yaml"
|
||||
When we run "jrnl --cf editor_encrypted.yaml --decrypt"
|
||||
Then the config should contain "encrypt: true" # basic_encrypted remains unchanged
|
||||
Then the config should contain "encrypt: true"
|
||||
And the output should not contain "Wrong password"
|
||||
|
|
|
@ -4,7 +4,7 @@ Feature: Reading and writing to journal with custom date formats
|
|||
# https://github.com/jrnl-org/jrnl/issues/117
|
||||
Given we use the config "simple.yaml"
|
||||
When we run "jrnl 2013-11-30 15:42: Project Started."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -999"
|
||||
Then the output should contain "2013-11-30 15:42 Project Started."
|
||||
|
||||
|
@ -13,7 +13,7 @@ Feature: Reading and writing to journal with custom date formats
|
|||
# https://github.com/jrnl-org/jrnl/issues/185
|
||||
Given we use the config "simple.yaml"
|
||||
When we run "jrnl 26/06/2099: Planet? Earth. Year? 2099."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -999"
|
||||
Then the output should contain "2099-06-26 09:00 Planet?"
|
||||
|
||||
|
@ -34,7 +34,7 @@ Feature: Reading and writing to journal with custom date formats
|
|||
Scenario Outline: Writing an entry from command line with custom date
|
||||
Given we use the config "<config_file>"
|
||||
When we run "jrnl <command>"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -n 1"
|
||||
Then the output should contain "<expected_output>"
|
||||
|
||||
|
@ -87,7 +87,7 @@ Feature: Reading and writing to journal with custom date formats
|
|||
Given we use the config "simple.yaml"
|
||||
And now is "2019-03-12 01:30:32 PM"
|
||||
When we run "jrnl <command>"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should contain "<expected_output>"
|
||||
Then the output should contain the date "<date>"
|
||||
|
@ -109,7 +109,7 @@ Feature: Reading and writing to journal with custom date formats
|
|||
Given we use the config "simple.yaml"
|
||||
And now is "2019-03-12 01:30:32 PM"
|
||||
When we run "jrnl <command>"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should contain "<expected_output>"
|
||||
Then the output should contain the date "<date>"
|
||||
|
|
|
@ -2,8 +2,9 @@ Feature: Encrypting and decrypting journals
|
|||
|
||||
Scenario: Decrypting a journal
|
||||
Given we use the config "encrypted.yaml"
|
||||
# And we use the password "bad doggie no biscuit" if prompted
|
||||
When we run "jrnl --decrypt" and enter "bad doggie no biscuit"
|
||||
Then we should see the message "Journal decrypted"
|
||||
Then the output should contain "Journal decrypted"
|
||||
And the config for journal "default" should contain "encrypt: false"
|
||||
When we run "jrnl -99 --short"
|
||||
Then the output should be
|
||||
|
@ -35,7 +36,7 @@ Feature: Encrypting and decrypting journals
|
|||
swordfish
|
||||
n
|
||||
Then we should get no error
|
||||
And we should see the message "Journal encrypted"
|
||||
And the output should contain "Journal encrypted"
|
||||
And the config for journal "default" should contain "encrypt: true"
|
||||
When we run "jrnl -n 1" and enter "swordfish"
|
||||
Then we should be prompted for a password
|
||||
|
|
|
@ -3,7 +3,7 @@ Feature: Journals iteracting with the file system in a way that users can see
|
|||
Scenario: Adding entries to a Folder journal should generate date files
|
||||
Given we use the config "empty_folder.yaml"
|
||||
When we run "jrnl 23 July 2013: Testing folder journal."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
And the journal directory should contain
|
||||
2013/07/23.txt
|
||||
|
||||
|
@ -11,7 +11,7 @@ Feature: Journals iteracting with the file system in a way that users can see
|
|||
Given we use the config "empty_folder.yaml"
|
||||
When we run "jrnl 23 July 2013: Testing folder journal."
|
||||
And we run "jrnl 3/7/2014: Second entry of journal."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
And the journal directory should contain
|
||||
2013/07/23.txt
|
||||
|
||||
|
@ -32,6 +32,7 @@ Feature: Journals iteracting with the file system in a way that users can see
|
|||
Then the output should contain "This is a new entry in my journal"
|
||||
|
||||
Scenario: Creating journal with relative path should update to absolute path
|
||||
Given we use no config
|
||||
When we run "jrnl hello world" and enter
|
||||
test.txt
|
||||
n
|
||||
|
|
|
@ -34,7 +34,7 @@ Feature: Multiple journals
|
|||
Scenario: Tell user which journal was used
|
||||
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"
|
||||
Then the output should contain "Entry added to work journal"
|
||||
|
||||
Scenario: Write to specified journal with a timestamp
|
||||
Given we use the config "multiple.yaml"
|
||||
|
|
|
@ -3,9 +3,12 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
|
|||
Scenario: Override configured editor with built-in input === editor:''
|
||||
Given we use the config "basic_encrypted.yaml"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl --config-override editor ''"
|
||||
When we run "jrnl --config-override editor ''" and enter
|
||||
This is a journal entry
|
||||
Then the stdin prompt should have been called
|
||||
And the editor should not have been called
|
||||
When we run "jrnl -1"
|
||||
Then the output should contain "This is a journal entry"
|
||||
|
||||
|
||||
Scenario: Postconfig commands with overrides
|
||||
|
@ -61,7 +64,7 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
|
|||
And we use the password "test" if prompted
|
||||
When we run "jrnl --config-override journals.default features/journals/simple.journal 20 Mar 2000: The rain in Spain comes from clouds"
|
||||
Then we should get no error
|
||||
And we should see the message "Entry added"
|
||||
And the output should contain "Entry added"
|
||||
When we run "jrnl -3 --config-override journals.default features/journals/simple.journal"
|
||||
Then the output should be
|
||||
2000-03-20 09:00 The rain in Spain comes from clouds
|
||||
|
@ -78,7 +81,7 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
|
|||
And we use the password "test" if prompted
|
||||
When we run "jrnl --config-override journals.temp features/journals/simple.journal temp Sep 06 1969: @say Ni"
|
||||
Then we should get no error
|
||||
And we should see the message "Entry added"
|
||||
And the output should contain "Entry added"
|
||||
When we run "jrnl --config-override journals.temp features/journals/simple.journal temp -3"
|
||||
Then the output should be
|
||||
1969-09-06 09:00 @say Ni
|
||||
|
|
|
@ -55,7 +55,7 @@ Feature: Using the installed keyring
|
|||
this password will not be saved in keyring
|
||||
this password will not be saved in keyring
|
||||
y
|
||||
Then we should see the message "Failed to retrieve keyring"
|
||||
Then the output should contain "Failed to retrieve keyring"
|
||||
And we should get no error
|
||||
And we should be prompted for a password
|
||||
And the config for journal "default" should contain "encrypt: true"
|
||||
|
@ -69,7 +69,7 @@ Feature: Using the installed keyring
|
|||
Then the error output should contain "Failed to retrieve keyring"
|
||||
And we should get no error
|
||||
And we should be prompted for a password
|
||||
And we should see the message "Journal decrypted"
|
||||
And the output should contain "Journal decrypted"
|
||||
And the config for journal "default" should contain "encrypt: false"
|
||||
When we run "jrnl --short"
|
||||
Then we should not be prompted for a password
|
||||
|
@ -96,7 +96,7 @@ Feature: Using the installed keyring
|
|||
swordfish
|
||||
sordfish
|
||||
Then we should be prompted for a password
|
||||
And we should see the message "Passwords did not match"
|
||||
And the output should contain "Passwords did not match"
|
||||
And the config for journal "default" should not contain "encrypt: true"
|
||||
When we run "jrnl --short"
|
||||
Then the output should be
|
||||
|
@ -113,8 +113,8 @@ Feature: Using the installed keyring
|
|||
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 output should contain "Passwords did not match"
|
||||
And the output should contain "Journal encrypted"
|
||||
And the config for journal "default" should contain "encrypt: true"
|
||||
When we run "jrnl -1" and enter "swordfish"
|
||||
Then we should be prompted for a password
|
||||
|
|
|
@ -3,7 +3,7 @@ Feature: Searching in a journal
|
|||
Scenario Outline: Displaying entries using -on today should display entries created today
|
||||
Given we use the config "<config_file>"
|
||||
When we run "jrnl today: Adding an entry right now."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "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"
|
||||
|
@ -18,11 +18,11 @@ Feature: Searching in a journal
|
|||
Scenario Outline: Displaying entries using -from day should display correct entries
|
||||
Given we use the config "<config_file>"
|
||||
When we run "jrnl yesterday: This thing happened yesterday"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl today at 11:59pm: Adding an entry right now."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl tomorrow: A future entry."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -from today"
|
||||
Then the output should contain "Adding an entry right now."
|
||||
And the output should contain "A future entry."
|
||||
|
@ -37,11 +37,11 @@ Feature: Searching in a journal
|
|||
Scenario Outline: Displaying entries using -from and -to day should display correct entries
|
||||
Given we use the config "<config_file>"
|
||||
When we run "jrnl yesterday: This thing happened yesterday"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl today at 11:59pm: Adding an entry right now."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl tomorrow: A future entry."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -from yesterday -to today"
|
||||
Then the output should contain "This thing happened yesterday"
|
||||
And the output should contain "Adding an entry right now."
|
||||
|
@ -118,9 +118,9 @@ Feature: Searching in a journal
|
|||
Scenario: Out of order entries to a Folder journal should be listed in date order
|
||||
Given we use the config "empty_folder.yaml"
|
||||
When we run "jrnl 3/7/2014 4:37pm: Second entry of journal."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl 23 July 2013: Testing folder journal."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -2"
|
||||
Then the output should be
|
||||
2013-07-23 09:00 Testing folder journal.
|
||||
|
|
|
@ -3,7 +3,7 @@ Feature: Starring entries
|
|||
Scenario Outline: Starring an entry will mark it in the journal file
|
||||
Given we use the config "<config_file>"
|
||||
When we run "jrnl 20 july 2013 *: Best day of my life!"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -on 2013-07-20 -starred"
|
||||
Then the output should contain "2013-07-20 09:00 Best day of my life!"
|
||||
|
||||
|
@ -30,6 +30,6 @@ Feature: Starring entries
|
|||
Scenario: Starring an entry will mark it in an encrypted journal
|
||||
Given we use the config "encrypted.yaml"
|
||||
When we run "jrnl 20 july 2013 *: Best day of my life!" and enter "bad doggie no biscuit"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -on 2013-07-20 -starred" and enter "bad doggie no biscuit"
|
||||
Then the output should contain "2013-07-20 09:00 Best day of my life!"
|
||||
|
|
|
@ -46,7 +46,7 @@ Feature: Writing new entries.
|
|||
Given we use the config "<config_file>"
|
||||
And we use the password "bad doggie no biscuit" if prompted
|
||||
When we run "jrnl 23 july 2013: A cold and stormy day. I ate crisps on the sofa."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -n 1"
|
||||
Then the output should contain "2013-07-23 09:00 A cold and stormy day."
|
||||
|
||||
|
@ -61,7 +61,7 @@ Feature: Writing new entries.
|
|||
Given we use the config "<config_file>"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl this is a partial --edit"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
Then the editor should have been called
|
||||
And the editor file content should be
|
||||
this is a partial
|
||||
|
@ -110,7 +110,7 @@ Feature: Writing new entries.
|
|||
Given we use the config "<config_file>"
|
||||
And we use the password "bad doggie no biscuit" if prompted
|
||||
When we run "jrnl 23 july 2013: A cold and stormy day. I ate crisps on the sofa."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -n 1"
|
||||
Then the output should not contain "Life is good"
|
||||
|
||||
|
@ -125,7 +125,7 @@ Feature: Writing new entries.
|
|||
Given we use the config "<config_file>"
|
||||
And we use the password "bad doggie no biscuit" if prompted
|
||||
When we run "jrnl 04-24-2014: Created a new website - empty.com. Hope to get a lot of traffic."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should be
|
||||
2014-04-24 09:00 Created a new website - empty.com.
|
||||
|
@ -142,7 +142,7 @@ Feature: Writing new entries.
|
|||
Given we use the config "<config_file>"
|
||||
And we use the password "bad doggie no biscuit" if prompted
|
||||
When we run "jrnl 23 july 2013: 🌞 sunny day. Saw an 🐘"
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -n 1"
|
||||
Then the output should contain "🌞"
|
||||
And the output should contain "🐘"
|
||||
|
@ -199,7 +199,7 @@ Feature: Writing new entries.
|
|||
Scenario: Title with an embedded period on DayOne journal
|
||||
Given we use the config "dayone.yaml"
|
||||
When we run "jrnl 04-24-2014: Ran 6.2 miles today in 1:02:03. I am feeling sore because I forgot to stretch."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should be
|
||||
2014-04-24 09:00 Ran 6.2 miles today in 1:02:03.
|
||||
|
@ -208,7 +208,7 @@ Feature: Writing new entries.
|
|||
Scenario: Opening an folder that's not a DayOne folder should treat as folder journal
|
||||
Given we use the config "empty_folder.yaml"
|
||||
When we run "jrnl 23 july 2013: Testing folder journal."
|
||||
Then we should see the message "Entry added"
|
||||
Then the output should contain "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should be "2013-07-23 09:00 Testing folder journal."
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue