From f9692b1f8dff120be63c2f85280a52160951d735 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Wed, 13 Nov 2019 18:10:57 -0700 Subject: [PATCH] [Dayone] re-add tests c.f. commit 7cbca9f60f1fb5cc9b8d075f9b101d29d9656936 c.f. commit 398283a8db3177b1ae122e5b9d6a9d623cf9106f [Dayone] Skip failing tests on Travis Travis sets the timezone to UTC, which causes many tests to fail --- features/dayone.feature | 76 +++++++++++++++++++++++++++++ features/dayone_regressions.feature | 31 ++++++++++++ features/environment.py | 14 ++++++ 3 files changed, 121 insertions(+) create mode 100644 features/dayone.feature create mode 100644 features/dayone_regressions.feature diff --git a/features/dayone.feature b/features/dayone.feature new file mode 100644 index 00000000..51aa2033 --- /dev/null +++ b/features/dayone.feature @@ -0,0 +1,76 @@ +Feature: Dayone specific implementation details. + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: Loading a DayOne Journal + 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 + """ + 2013-05-17 11:39 This entry has tags! + + 2013-06-17 20:38 This entry has a location. + + 2013-07-17 11:38 This entry is starred! + """ + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: Entries without timezone information will be interpreted as in the current timezone + 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 + + @skip + Scenario: Writing into Dayone + 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 + """ + 1979-05-01 09:00 Being born hurts. + """ + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: Loading tags from a DayOne Journal + Given we use the config "dayone.yaml" + When we run "jrnl --tags" + Then the output should be + """ + @work : 1 + @play : 1 + """ + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: Saving tags from a DayOne Journal + 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 + """ + @work : 2 + @play : 1 + """ + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: Filtering by tags from a DayOne Journal + Given we use the config "dayone.yaml" + When we run "jrnl @work" + Then the output should be + """ + 2013-05-17 11:39 This entry has tags! + """ + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: Exporting dayone to json + Given we use the config "dayone.yaml" + When we run "jrnl --export json" + Then we should get no error + and the output should be parsable as json + and the json output should contain entries.0.uuid = "4BB1F46946AD439996C9B59DE7C4DDC1" diff --git a/features/dayone_regressions.feature b/features/dayone_regressions.feature new file mode 100644 index 00000000..c3b700b9 --- /dev/null +++ b/features/dayone_regressions.feature @@ -0,0 +1,31 @@ +Feature: Zapped Dayone bugs stay dead! + + # fails when system time is UTC (as on Travis-CI) + @skip + Scenario: DayOne tag searching should work with tags containing a mixture of upper and lower case. + # https://github.com/jrnl-org/jrnl/issues/354 + Given we use the config "dayone.yaml" + When we run "jrnl @plAy" + Then the output should contain + """ + 2013-05-17 11:39 This entry has tags! + """ + + # fails when system time is UTC (as on Travis-CI) + @skip + 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'm feeling sore because I forgot to stretch."" + Then we should see the message "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. + | I'm feeling sore because I forgot to stretch. + """ + + Scenario: Opening an folder that's not a DayOne folder gives a nice error message + 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" diff --git a/features/environment.py b/features/environment.py index 7a918feb..8ba781ac 100644 --- a/features/environment.py +++ b/features/environment.py @@ -2,6 +2,14 @@ import shutil import os +def before_feature(context, feature): + # add "skip" tag + # https://stackoverflow.com/a/42721605/4276230 + if "skip" in feature.tags: + feature.skip("Marked with @skip") + return + + def before_scenario(context, scenario): """Before each scenario, backup all config and journal test data.""" # Clean up in case something went wrong @@ -22,6 +30,12 @@ def before_scenario(context, scenario): else: shutil.copy2(source, working_dir) + # add "skip" tag + # https://stackoverflow.com/a/42721605/4276230 + if "skip" in scenario.effective_tags: + scenario.skip("Marked with @skip") + return + def after_scenario(context, scenario): """After each scenario, restore all test data and remove working_dirs."""