Expand date tests

of the 93 tests added, it passes 47
This commit is contained in:
William Minchin 2014-02-08 13:08:38 -07:00
parent 4df237589b
commit 65aae7e0be
6 changed files with 179 additions and 132 deletions

View file

@ -10,7 +10,7 @@ install:
# command to run tests
script:
- python --version
- behave --tages=-wip
- "behave --tages='-wip'"
matrix:
allow_failures: # python 3 support for travis is shaky....
- python: 3.3

View file

@ -0,0 +1,14 @@
{
"default_hour": 9,
"timeformat": "%Y-%m-%d %H:%M",
"linewrap": 80,
"encrypt": false,
"editor": "",
"default_minute": 0,
"highlight": true,
"password": "",
"journals": {
"default": "features/journals/empty.journal"
},
"tagsymbols": "@"
}

View file

View file

@ -1,156 +1,110 @@
@dates @wip
Feature: Processing of dates and times
@dates1 @dates @wip
Feature: Processing of (relative) dates and times
# all these test are 'brittle', in that they depend on the day it is run
# these results assume the test is run on Feb 8, 2014
Scenario Outline: Test all sorts of dates
Scenario Outline: no date
Given we use the config "basic.json"
When we run "jrnl" and enter "<date in> I saw Elvis. <entry no>"
Then we should get no error
and the journal should contain "<date out> I saw Elvis. <entry no>"
When we run "jrnl I saw Elvis <entry no>. He's alive!"
Then we should get no error
Then the journal should contain "<date out> I saw Elvis <entry no>"
Examples: no date
| date in | date out | entry no |
| | | 1 |
| date in | date out | entry no |
| | 2014-02-08 09:00 | 1 |
Scenario Outline: Test all sorts of (non-fixed) dates
Given we use the config "empty.json"
When we run "jrnl <date in>: I saw Elvis <entry no>."
Then we should get no error
Then the journal should contain "<date out> I saw Elvis <entry no>"
Examples: strings
| date in | date out | entry no |
| today | | 2 |
| tomorrow | | 3 |
| yesterday | | 4 |
| date in | date out | entry no |
| today | 2014-02-08 09:00 | 2 |
| tomorrow | 2014-02-09 09:00 | 3 |
| yesterday | 2014-02-07 09:00 | 4 |
Examples: strings with times
| date in | date out | entry no |
| today 2pm | | 5 |
| today at 3pm | | 6 |
| today 8am | | 7 |
| today 16:27 | | 8 |
| today 5:18 | | 9 |
| today 6:47pm | | 10 |
| date in | date out | entry no |
| today 2pm | 2014-02-08 14:00 | 5 |
| today at 3pm | 2014-02-08 15:00 | 6 |
| today 8am | 2014-02-08 08:00 | 7 |
| today 16:27 | 2014-02-08 16:27 | 8 |
| today 5:18 | 2014-02-08 05:18 | 9 |
| today 6:47pm | 2014-02-08 18:47 | 10 |
Examples: days of the week
| date in | date out | entry no |
| monday | | 11 |
| tuesday | | 12 |
| wednesday | | 13 |
| thrusday | | 14 |
| friday | | 15 |
| saturday | | 16 |
| sunday | | 17 |
| date in | date out | entry no |
| monday | 2014-02-10 09:00 | 11 |
| tuesday | 2014-02-11 09:00 | 12 |
| wednesday | 2014-02-12 09:00 | 13 |
| thursday | 2014-02-13 09:00 | 14 |
| friday | 2014-02-14 09:00 | 15 |
| saturday | 2014-02-08 09:00 | 16 |
| sunday | 2014-02-09 09:00 | 17 |
Examples: days of the week
| date in | date out | entry no |
| mon | | 18 |
| tues | | 19 |
| wed | | 20 |
| thrus | | 21 |
| fri | | 22 |
| sat | | 23 |
| sun | | 24 |
| tue | | 25 |
| thr | | 26 |
| date in | date out | entry no |
| mon | 2014-02-10 09:00 | 18 |
| tues | 2014-02-11 09:00 | 19 |
| wed | 2014-02-12 09:00 | 20 |
| thurs | 2014-02-13 09:00 | 21 |
| fri | 2014-02-14 09:00 | 22 |
| sat | 2014-02-08 09:00 | 23 |
| sun | 2014-02-09 09:00 | 24 |
| tue | 2014-02-11 09:00 | 25 |
| thu | 2014-02-13 09:00 | 26 |
Examples: days of the week with a time
| date in | date out | entry no |
| mon at 5am | | 27 |
| date in | date out | entry no |
| mon at 5am | 2014-02-10 05:00 | 27 |
Examples: Qualified days of the week
| date in | date out | entry no |
| last monday | | 28 |
| next monday | | 29 |
| last monday |2014-02-03 09:00 | 28 |
| next monday |2014-02-10 09:00 | 29 |
Examples: Just times
| date in | date out | entry no |
| at 8pm | | 30 |
| noon | | 31 |
| midnight | | 32 |
| at 8pm |2014-02-10 20:00 | 30 |
| noon |2014-02-10 12:00 | 31 |
| midnight |2014-02-10 00:00 | 32 |
Examples: short months
| date in | date out | entry no |
| jan | | 33 |
| feb | | 34 |
| mar | | 35 |
| apr | | 36 |
| may | | 37 |
| jun | | 38 |
| jul | | 39 |
| aug | | 40 |
| sep | | 41 |
| oct | | 42 |
| nov | | 43 |
| dec | | 44 |
| sept | | 45 |
| date in | date out | entry no |
| jan | 2015-01-01 09:00 | 33 |
| feb | 2014-02-01 09:00 | 34 |
| mar | 2014-03-01 09:00 | 35 |
| apr | 2014-04-01 09:00 | 36 |
| may | 2014-05-01 09:00 | 37 |
| jun | 2014-06-01 09:00 | 38 |
| jul | 2014-07-01 09:00 | 39 |
| aug | 2014-08-01 09:00 | 40 |
| sep | 2014-09-01 09:00 | 41 |
| oct | 2014-10-01 09:00 | 42 |
| nov | 2014-11-01 09:00 | 43 |
| dec | 2014-12-01 09:00 | 44 |
| sept | 2014-09-01 09:00 | 45 |
Examples: long months
| date in | date out | entry no |
| january | | 46 |
| february | | 47 |
| march | | 48 |
| april | | 49 |
| june | | 50 |
| july | | 51 |
| august | | 52 |
| september | | 53 |
| october | | 54 |
| november | | 55 |
| december | | 56 |
| date in | date out | entry no |
| january | 2015-01-01 09:00 | 46 |
| february | 2014-02-01 09:00 | 47 |
| march | 2014-03-01 09:00 | 48 |
| april | 2014-04-01 09:00 | 49 |
| june | 2014-06-01 09:00 | 50 |
| july | 2014-07-01 09:00 | 51 |
| august | 2014-08-01 09:00 | 52 |
| september | 2014-09-01 09:00 | 53 |
| october | 2014-10-01 09:00 | 54 |
| november | 2014-11-01 09:00 | 55 |
| december | 2014-12-01 09:00 | 56 |
Examples: month + day (no year)
| date in | date out | entry no |
| 7 apr | | 57 |
| apr 8 | | 58 |
| 9 march | | 59 |
| march 10 | | 60 |
Examples: year
| date in | date out | entry no |
| 1998 | 1998-01-01 9:00 | 61 |
| 2013 | 2013-01-01 9:00 | 62 |
| 2014 | 2014-01-01 9:00 | 63 |
| 2015 | 2015-01-01 9:00 | 64 |
| 2051 | 2051-01-01 9:00 | 65 |
Examples: year + month
| date in | date out | entry no |
| jun 2013 | 2013-06-01 9:00 | 66 |
| 2013 jul | 2013-07-01 9:00 | 67 |
| august 2013 | 2013-08-01 9:00 | 68 |
| 2013 september | 2013-09-01 9:00 | 69 |
Examples: 'YYYY-MM-DD' dates (with and without times)
| date in | date out | entry no |
| 2013-06-07 | 2013-06-07 9:00 | 70 |
| 2013-06-07 8:11 | 2013-06-07 8:11 | 71 |
| 2013-06-07 08:12 | 2013-06-07 8:12 | 72 |
| 2013-06-07 20:13 | 2013-06-07 20:13 | 73 |
Examples: 'YYYY-MMM-DD' dates (with and without times)
| date in | date out | entry no |
| 2013-may-07 | 2013-05-07 9:00 | 74 |
| 2013-may-07 8:11 | 2013-05-07 8:11 | 75 |
| 2013-may-07 08:12 | 2013-05-07 8:12 | 76 |
| 2013-may-07 20:13 | 2013-05-07 20:13 | 77 |
Examples: Full dates, with written montsh
| date in | date out | entry no |
| Feb 5, 2014 | 2014-02-05 9:00 | 78 |
| Feb 06, 2014 | 2014-02-06 9:00 | 79 |
| Feb. 7, 2014 | 2014-02-07 9:00 | 80 |
| Feb. 08, 2014 | 2014-02-08 9:00 | 81 |
| 9 Feb 2014 | 2014-02-09 9:00 | 82 |
| 01 Feb 2014 | 2014-02-01 9:00 | 83 |
| 2 Feb. 2014 | 2014-02-02 9:00 | 84 |
| 03 Feb. 2014 | 2014-02-03 9:00 | 85 |
Examples: 'YYYY/MM/DD' dates (with and without times)
| date in | date out | entry no |
| 2013/06/07 | 2013-06-07 9:00 | 86 |
| 2013/06/07 8:11 | 2013-06-07 8:11 | 87 |
| 2013/06/07 08:12 | 2013-06-07 8:12 | 88 |
| 2013/06/07 20:13 | 2013-06-07 20:13 | 89 |
Examples: 'DD/MM/YYYY' dates (with and without times)
| date in | date out | entry no |
| 13/06/2007 | 2007-06-13 9:00 | 90 |
| 13/06/2007 8:11 | 2007-06-13 8:11 | 91 |
| 13/06/2007 08:12 | 2007-06-13 8:12 | 92 |
| 13/06/2007 20:13 | 2007-06-13 20:13 | 93 |
| 7 apr | 2014-04-07 09:00 | 57 |
| apr 8 | 2014-04-08 09:00 | 58 |
| 9 march | 2014-03-09 09:00 | 59 |
| march 10 | 2014-03-10 09:00 | 60 |

63
features/dates2.feature Normal file
View file

@ -0,0 +1,63 @@
@dates2 @dates @wip
Feature: Processing of (fixed) dates and times
Scenario Outline: Test all sorts of (fixed) dates
Given we use the config "empty.json"
When we run "jrnl <date in>: I saw Elvis <entry no>. He's Alive!"
Then we should get no error
Then the journal should contain "<date out> I saw Elvis <entry no>"
Examples: year
| date in | date out | entry no |
| 1998 | 1998-01-01 09:00 | 61 |
| 2013 | 2013-01-01 09:00 | 62 |
| 2014 | 2014-01-01 09:00 | 63 |
| 2015 | 2015-01-01 09:00 | 64 |
| 2051 | 2051-01-01 09:00 | 65 |
Examples: year + month
| date in | date out | entry no |
| jun 2013 | 2013-06-01 09:00 | 66 |
| 2013 jul | 2013-07-01 09:00 | 67 |
| august 2013 | 2013-08-01 09:00 | 68 |
| 2013 september | 2013-09-01 09:00 | 69 |
Examples: 'YYYY-MM-DD' dates (with and without times)
| date in | date out | entry no |
| 2013-06-07 | 2013-06-07 09:00 | 70 |
| 2013-06-07 8:11 | 2013-06-07 08:11 | 71 |
| 2013-06-07 08:12 | 2013-06-07 08:12 | 72 |
| 2013-06-07 20:13 | 2013-06-07 20:13 | 73 |
Examples: 'YYYY-MMM-DD' dates (with and without times)
| date in | date out | entry no |
| 2013-may-07 | 2013-05-07 09:00 | 74 |
| 2013-may-07 8:11 | 2013-05-07 08:11 | 75 |
| 2013-may-07 08:12 | 2013-05-07 08:12 | 76 |
| 2013-may-07 20:13 | 2013-05-07 20:13 | 77 |
Examples: Full dates, with written montsh
| date in | date out | entry no |
| Feb 5, 2014 | 2014-02-05 09:00 | 78 |
| Feb 06, 2014 | 2014-02-06 09:00 | 79 |
| Feb. 7, 2014 | 2014-02-07 09:00 | 80 |
| Feb. 08, 2014 | 2014-02-08 09:00 | 81 |
| 9 Feb 2014 | 2014-02-09 09:00 | 82 |
| 01 Feb 2014 | 2014-02-01 09:00 | 83 |
| 2 Feb. 2014 | 2014-02-02 09:00 | 84 |
| 03 Feb. 2014 | 2014-02-03 09:00 | 85 |
Examples: 'YYYY/MM/DD' dates (with and without times)
| date in | date out | entry no |
| 2013/06/07 | 2013-06-07 09:00 | 86 |
| 2013/06/07 8:11 | 2013-06-07 08:11 | 87 |
| 2013/06/07 08:12 | 2013-06-07 08:12 | 88 |
| 2013/06/07 20:13 | 2013-06-07 20:13 | 89 |
Examples: 'DD/MM/YYYY' dates (with and without times)
| date in | date out | entry no |
| 13/06/2007 | 2007-06-13 09:00 | 90 |
| 13/06/2007 8:11 | 2007-06-13 08:11 | 91 |
| 13/06/2007 08:12 | 2007-06-13 08:12 | 92 |
| 13/06/2007 20:13 | 2007-06-13 20:13 | 93 |

View file

@ -1,6 +1,7 @@
from behave import *
import shutil
import os
import time
import jrnl
try:
from io import StringIO
@ -17,14 +18,24 @@ def before_scenario(context, scenario):
for folder in ("configs", "journals"):
working_dir = os.path.join("features", folder)
if os.path.exists(working_dir):
shutil.rmtree(working_dir)
try:
shutil.rmtree(working_dir)
except:
# give it a second go at it...
time.sleep(0.5)
shutil.rmtree(working_dir)
for folder in ("configs", "journals"):
original = os.path.join("features", "data", folder)
working_dir = os.path.join("features", folder)
if not os.path.exists(working_dir):
os.mkdir(working_dir)
try:
os.mkdir(working_dir)
except:
# give it a second go at it...
time.sleep(0.5)
os.mkdir(working_dir)
for filename in os.listdir(original):
source = os.path.join(original, filename)
if os.path.isdir(source):
@ -39,4 +50,9 @@ def after_scenario(context, scenario):
for folder in ("configs", "journals"):
working_dir = os.path.join("features", folder)
if os.path.exists(working_dir):
shutil.rmtree(working_dir)
try:
shutil.rmtree(working_dir)
except:
# give it a second go at it...
time.sleep(0.5)
shutil.rmtree(working_dir)