mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Clarify and cleanup tests
- Run formatter - Take out old tags - Use new steps on tests Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
44b1762b7d
commit
b7b7bad2fb
5 changed files with 44 additions and 25 deletions
|
@ -6,7 +6,7 @@ highlight: true
|
||||||
template: false
|
template: false
|
||||||
journals:
|
journals:
|
||||||
default: features/journals/simple.journal
|
default: features/journals/simple.journal
|
||||||
ideas: features/journals/nothing.journal
|
ideas: features/journals/does-not-exist.journal
|
||||||
simple: features/journals/simple.journal
|
simple: features/journals/simple.journal
|
||||||
work: features/journals/work.journal
|
work: features/journals/work.journal
|
||||||
new_encrypted:
|
new_encrypted:
|
||||||
|
|
|
@ -3,8 +3,8 @@ Feature: Encrypting and decrypting journals
|
||||||
Scenario: Decrypting a journal
|
Scenario: Decrypting a journal
|
||||||
Given we use the config "encrypted.yaml"
|
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 we should see the message "Journal decrypted"
|
||||||
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"
|
||||||
And we should see the message "Journal decrypted"
|
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
2013-06-09 15:39 My first entry.
|
2013-06-09 15:39 My first entry.
|
||||||
|
|
|
@ -4,30 +4,32 @@ Feature: Multiple journals
|
||||||
Given we use the config "multiple.yaml"
|
Given we use the config "multiple.yaml"
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
@todo something
|
2013-06-09 15:39 My first entry.
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
When we run "jrnl work -99 --short"
|
When we run "jrnl work -99 --short"
|
||||||
Then the output should be
|
Then the output should be empty
|
||||||
@todo something
|
|
||||||
|
|
||||||
Scenario: Write to default config by default
|
Scenario: Write to default config by default
|
||||||
Given we use the config "multiple.yaml"
|
Given we use the config "multiple.yaml"
|
||||||
When we run "jrnl this goes to default"
|
When we run "jrnl this goes to default"
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should contain
|
||||||
@todo something
|
2013-06-09 15:39 My first entry.
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
|
Then the output should contain
|
||||||
|
this goes to default
|
||||||
When we run "jrnl work -99 --short"
|
When we run "jrnl work -99 --short"
|
||||||
Then the output should be
|
Then the output should be empty
|
||||||
@todo something
|
|
||||||
|
|
||||||
Scenario: Write to specified journal
|
Scenario: Write to specified journal
|
||||||
Given we use the config "multiple.yaml"
|
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"
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
@todo something
|
2013-06-09 15:39 My first entry.
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
When we run "jrnl work -99 --short"
|
When we run "jrnl work -99 --short"
|
||||||
Then the output should be
|
Then the output should contain "a long day in the office"
|
||||||
@todo something
|
|
||||||
|
|
||||||
Scenario: Tell user which journal was used
|
Scenario: Tell user which journal was used
|
||||||
Given we use the config "multiple.yaml"
|
Given we use the config "multiple.yaml"
|
||||||
|
@ -39,29 +41,32 @@ Feature: Multiple journals
|
||||||
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"
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
@todo something
|
2013-06-09 15:39 My first entry.
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
When we run "jrnl work -99 --short"
|
When we run "jrnl work -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
@todo something
|
2012-07-23 09:00 a long day in the office
|
||||||
|
|
||||||
Scenario: Write to specified journal without a timestamp but with colon
|
Scenario: Write to specified journal without a timestamp but with colon
|
||||||
Given we use the config "multiple.yaml"
|
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 the output should be
|
Then the output should be
|
||||||
@todo something
|
2013-06-09 15:39 My first entry.
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
When we run "jrnl work -99 --short"
|
When we run "jrnl work -99 --short"
|
||||||
Then the output should be
|
Then the output should be contain
|
||||||
@todo something
|
a long day in the office
|
||||||
|
|
||||||
Scenario: Write to specified journal without a timestamp but with colon
|
Scenario: Write to specified journal without a timestamp but with colon
|
||||||
Given we use the config "multiple.yaml"
|
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"
|
||||||
When we run "jrnl -99 --short"
|
When we run "jrnl -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
@todo something
|
2013-06-09 15:39 My first entry.
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
When we run "jrnl work -99 --short"
|
When we run "jrnl work -99 --short"
|
||||||
Then the output should be
|
Then the output should contain
|
||||||
@todo something
|
a long day in the office
|
||||||
|
|
||||||
Scenario: Create new journals as required
|
Scenario: Create new journals as required
|
||||||
Given we use the config "multiple.yaml"
|
Given we use the config "multiple.yaml"
|
||||||
|
@ -69,7 +74,7 @@ Feature: Multiple journals
|
||||||
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"
|
||||||
When we run "jrnl ideas -99 --short"
|
When we run "jrnl ideas -99 --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
@todo something
|
2012-07-23 09:00 sell my junk on ebay and make lots of money
|
||||||
|
|
||||||
Scenario: Don't crash if no default journal is specified
|
Scenario: Don't crash if no default journal is specified
|
||||||
Given we use the config "bug343.yaml"
|
Given we use the config "bug343.yaml"
|
||||||
|
|
|
@ -267,7 +267,7 @@ Feature: Searching in a journal
|
||||||
Scenario Outline: Searching today in history
|
Scenario Outline: Searching today in history
|
||||||
Given we use the config "<config_file>"
|
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 set current date and time to "2020-08-31 14:32"
|
And now is "2020-08-31 02:32:00 PM"
|
||||||
When we run "jrnl 2019-08-31 01:01: Hi, from last year."
|
When we run "jrnl 2019-08-31 01:01: Hi, from last year."
|
||||||
And we run "jrnl -today-in-history --short"
|
And we run "jrnl -today-in-history --short"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
|
|
|
@ -164,6 +164,7 @@ def password():
|
||||||
def input_method():
|
def input_method():
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
@fixture
|
@fixture
|
||||||
def now_date():
|
def now_date():
|
||||||
return {"datetime": datetime, "calendar_parse": __get_pdt_calendar()}
|
return {"datetime": datetime, "calendar_parse": __get_pdt_calendar()}
|
||||||
|
@ -373,7 +374,11 @@ def use_password_forever(pw):
|
||||||
|
|
||||||
|
|
||||||
@when(parse('we run "jrnl {command}" and {input_method}\n{user_input}'))
|
@when(parse('we run "jrnl {command}" and {input_method}\n{user_input}'))
|
||||||
@when(parsers.re('we run "jrnl (?P<command>[^"]+)" and (?P<input_method>enter|pipe) "(?P<user_input>[^"]+)"'))
|
@when(
|
||||||
|
parsers.re(
|
||||||
|
'we run "jrnl (?P<command>[^"]+)" and (?P<input_method>enter|pipe) "(?P<user_input>[^"]+)"'
|
||||||
|
)
|
||||||
|
)
|
||||||
@when(parse('we run "jrnl" and {input_method} "{user_input}"'))
|
@when(parse('we run "jrnl" and {input_method} "{user_input}"'))
|
||||||
@when(parse('we run "jrnl {command}"'))
|
@when(parse('we run "jrnl {command}"'))
|
||||||
@when('we run "jrnl <command>"')
|
@when('we run "jrnl <command>"')
|
||||||
|
@ -391,8 +396,8 @@ def we_run(
|
||||||
keyring,
|
keyring,
|
||||||
input_method,
|
input_method,
|
||||||
):
|
):
|
||||||
assert input_method in ['', 'enter', 'pipe']
|
assert input_method in ["", "enter", "pipe"]
|
||||||
is_tty = input_method != 'pipe'
|
is_tty = input_method != "pipe"
|
||||||
|
|
||||||
if cache_dir["exists"]:
|
if cache_dir["exists"]:
|
||||||
command = command.format(cache_dir=cache_dir["path"])
|
command = command.format(cache_dir=cache_dir["path"])
|
||||||
|
@ -573,6 +578,15 @@ def journal_directory_should_contain(config_data, file_list):
|
||||||
assert does_directory_contain_files(file_list, scoped_config["journal"])
|
assert does_directory_contain_files(file_list, scoped_config["journal"])
|
||||||
|
|
||||||
|
|
||||||
|
@then(parse('journal "{journal_name}" should not exist'))
|
||||||
|
def journal_directory_should_contain(config_data, journal_name):
|
||||||
|
scoped_config = scope_config(config_data, journal_name)
|
||||||
|
|
||||||
|
assert not does_directory_contain_files(
|
||||||
|
scoped_config["journal"], "."
|
||||||
|
), f'Journal "{journal_name}" does exist'
|
||||||
|
|
||||||
|
|
||||||
@when(parse('we change directory to "{directory_name}"'))
|
@when(parse('we change directory to "{directory_name}"'))
|
||||||
def when_we_change_directory(directory_name):
|
def when_we_change_directory(directory_name):
|
||||||
if not os.path.isdir(directory_name):
|
if not os.path.isdir(directory_name):
|
||||||
|
|
Loading…
Add table
Reference in a new issue