1.1 --- a/tests/test_recurrence.py Sat Jul 13 01:33:22 2013 +0200
1.2 +++ b/tests/test_recurrence.py Sat Jul 13 23:53:29 2013 +0200
1.3 @@ -1,12 +1,91 @@
1.4 #!/usr/bin/env python
1.5
1.6 -from RecurrenceSupport import getRecurrence
1.7 +from RecurrenceSupport import getRecurrence, ParseError
1.8 +
1.9 +# Good recurrences.
1.10 +
1.11 +s = "every single day of the second month"
1.12 +print s
1.13 +print "->", getRecurrence(s)
1.14 +s = "every single day of the second month of every year"
1.15 +print s
1.16 +print "->", getRecurrence(s)
1.17 +s = "every other day from the first day of every other month from the third month of every year"
1.18 +print s
1.19 +print "->", getRecurrence(s)
1.20 +s = "the second day of every other month from the first month"
1.21 +print s
1.22 +print "->", getRecurrence(s)
1.23 +s = "the second hour in the second day in the second month of every year"
1.24 +print s
1.25 +print "->", getRecurrence(s)
1.26 +s = "every day from the second day until the 10th day of every other month until the fifth month"
1.27 +print s
1.28 +print "->", getRecurrence(s)
1.29 +s = "every day from the 10th day in the second month until the 10th day in the 10th month of every third month from the first month"
1.30 +print s
1.31 +print "->", getRecurrence(s)
1.32 +s = "every day of every third month from the 10th day in the second month until the 10th day in the 10th month"
1.33 +print s
1.34 +print "->", getRecurrence(s)
1.35 +
1.36 +# Bad recurrences.
1.37 +
1.38 +print
1.39 +
1.40 +# No start or end points.
1.41 +
1.42 +s = "every other day of every other month"
1.43 +print s
1.44 +try:
1.45 + print "->", getRecurrence(s)
1.46 +except ParseError, exc:
1.47 + print exc
1.48
1.49 -print getRecurrence("every other day of every other month")
1.50 -print getRecurrence("the second day of every other month")
1.51 -print getRecurrence("every other day of every other month from the third month of every year")
1.52 -print getRecurrence("every day from the second day until the 10th day of every other month")
1.53 -print getRecurrence("every day from the 10th day in the second month until the 10th day in the 10th month of every third month")
1.54 -print getRecurrence("every day of every third month from the 10th day in the second month until the 10th day in the 10th month")
1.55 +s = "every other day of every other month from the third month of every year"
1.56 +print s
1.57 +try:
1.58 + print "->", getRecurrence(s)
1.59 +except ParseError, exc:
1.60 + print exc
1.61 +
1.62 +s = "the second day of every other month"
1.63 +print s
1.64 +try:
1.65 + print "->", getRecurrence(s)
1.66 +except ParseError, exc:
1.67 + print exc
1.68 +
1.69 +s = "every day from the second day until the 10th day of every other month"
1.70 +print s
1.71 +try:
1.72 + print "->", getRecurrence(s)
1.73 +except ParseError, exc:
1.74 + print exc
1.75 +
1.76 +s = "every day from the 10th day in the second month until the 10th day in the 10th month of every third month"
1.77 +print s
1.78 +try:
1.79 + print "->", getRecurrence(s)
1.80 +except ParseError, exc:
1.81 + print exc
1.82 +
1.83 +# Syntax error: need to use "of" instead of "in".
1.84 +
1.85 +s = "every single day in the second month"
1.86 +print s
1.87 +try:
1.88 + print "->", getRecurrence(s)
1.89 +except ParseError, exc:
1.90 + print exc
1.91 +
1.92 +# Out of order: days do not contain months.
1.93 +
1.94 +s = "every other month from the first month of every other day from the first day"
1.95 +print s
1.96 +try:
1.97 + print "->", getRecurrence(s)
1.98 +except ParseError, exc:
1.99 + print exc
1.100
1.101 # vim: tabstop=4 expandtab shiftwidth=4