diff --git a/tests/data/configs/multiple.yaml b/tests/data/configs/multiple.yaml index 65f2c256..1501b383 100644 --- a/tests/data/configs/multiple.yaml +++ b/tests/data/configs/multiple.yaml @@ -6,7 +6,7 @@ highlight: true template: false journals: default: features/journals/simple.journal - ideas: features/journals/nothing.journal + ideas: features/journals/does-not-exist.journal simple: features/journals/simple.journal work: features/journals/work.journal new_encrypted: diff --git a/tests/features/encrypt.feature b/tests/features/encrypt.feature index b9b9ff5a..daa9f109 100644 --- a/tests/features/encrypt.feature +++ b/tests/features/encrypt.feature @@ -3,8 +3,8 @@ Feature: Encrypting and decrypting journals Scenario: Decrypting a journal Given we use the config "encrypted.yaml" 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" - And we should see the message "Journal decrypted" When we run "jrnl -99 --short" Then the output should be 2013-06-09 15:39 My first entry. diff --git a/tests/features/multiple_journals.feature b/tests/features/multiple_journals.feature index 4be3ab1c..cd531ee2 100644 --- a/tests/features/multiple_journals.feature +++ b/tests/features/multiple_journals.feature @@ -4,30 +4,32 @@ Feature: Multiple journals Given we use the config "multiple.yaml" When we run "jrnl -99 --short" 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" - Then the output should be - @todo something + Then the output should be empty Scenario: Write to default config by default Given we use the config "multiple.yaml" When we run "jrnl this goes to default" When we run "jrnl -99 --short" - Then the output should be - @todo something + Then the output should contain + 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" - Then the output should be - @todo something + Then the output should be empty Scenario: Write to specified journal Given we use the config "multiple.yaml" When we run "jrnl work a long day in the office" When we run "jrnl -99 --short" 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" - Then the output should be - @todo something + Then the output should contain "a long day in the office" Scenario: Tell user which journal was used 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 -99 --short" 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" 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 Given we use the config "multiple.yaml" When we run "jrnl work : a long day in the office" 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" - Then the output should be - @todo something + Then the output should be contain + a long day in the office Scenario: Write to specified journal without a timestamp but with colon Given we use the config "multiple.yaml" When we run "jrnl work: a long day in the office" When we run "jrnl -99 --short" 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" - Then the output should be - @todo something + Then the output should contain + a long day in the office Scenario: Create new journals as required 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 -99 --short" 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 Given we use the config "bug343.yaml" diff --git a/tests/features/search.feature b/tests/features/search.feature index 0bd0fb79..8d951aaf 100644 --- a/tests/features/search.feature +++ b/tests/features/search.feature @@ -267,7 +267,7 @@ Feature: Searching in a journal Scenario Outline: Searching today in history Given we use the config "" 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." And we run "jrnl -today-in-history --short" Then the output should be diff --git a/tests/step_defs/conftest.py b/tests/step_defs/conftest.py index 9e482737..c6d36f89 100644 --- a/tests/step_defs/conftest.py +++ b/tests/step_defs/conftest.py @@ -164,6 +164,7 @@ def password(): def input_method(): return "" + @fixture def now_date(): 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(parsers.re('we run "jrnl (?P[^"]+)" and (?Penter|pipe) "(?P[^"]+)"')) +@when( + parsers.re( + 'we run "jrnl (?P[^"]+)" and (?Penter|pipe) "(?P[^"]+)"' + ) +) @when(parse('we run "jrnl" and {input_method} "{user_input}"')) @when(parse('we run "jrnl {command}"')) @when('we run "jrnl "') @@ -391,8 +396,8 @@ def we_run( keyring, input_method, ): - assert input_method in ['', 'enter', 'pipe'] - is_tty = input_method != 'pipe' + assert input_method in ["", "enter", "pipe"] + is_tty = input_method != "pipe" if cache_dir["exists"]: 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"]) +@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}"')) def when_we_change_directory(directory_name): if not os.path.isdir(directory_name):