| 33 | |
| 34 | @pytest.mark.rrule |
| 35 | class RRuleTest(unittest.TestCase): |
| 36 | def _rrulestr_reverse_test(self, rule): |
| 37 | """ |
| 38 | Call with an `rrule` and it will test that `str(rrule)` generates a |
| 39 | string which generates the same `rrule` as the input when passed to |
| 40 | `rrulestr()` |
| 41 | """ |
| 42 | rr_str = str(rule) |
| 43 | rrulestr_rrule = rrulestr(rr_str) |
| 44 | |
| 45 | self.assertEqual(list(rule), list(rrulestr_rrule)) |
| 46 | |
| 47 | def testStrAppendRRULEToken(self): |
| 48 | # `_rrulestr_reverse_test` does not check if the "RRULE:" prefix |
| 49 | # property is appended properly, so give it a dedicated test |
| 50 | self.assertEqual(str(rrule(YEARLY, |
| 51 | count=5, |
| 52 | dtstart=datetime(1997, 9, 2, 9, 0))), |
| 53 | "DTSTART:19970902T090000\n" |
| 54 | "RRULE:FREQ=YEARLY;COUNT=5") |
| 55 | |
| 56 | rr_str = ( |
| 57 | 'DTSTART:19970105T083000\nRRULE:FREQ=YEARLY;INTERVAL=2' |
| 58 | ) |
| 59 | self.assertEqual(str(rrulestr(rr_str)), rr_str) |
| 60 | |
| 61 | def testYearly(self): |
| 62 | self.assertEqual(list(rrule(YEARLY, |
| 63 | count=3, |
| 64 | dtstart=datetime(1997, 9, 2, 9, 0))), |
| 65 | [datetime(1997, 9, 2, 9, 0), |
| 66 | datetime(1998, 9, 2, 9, 0), |
| 67 | datetime(1999, 9, 2, 9, 0)]) |
| 68 | |
| 69 | def testYearlyInterval(self): |
| 70 | self.assertEqual(list(rrule(YEARLY, |
| 71 | count=3, |
| 72 | interval=2, |
| 73 | dtstart=datetime(1997, 9, 2, 9, 0))), |
| 74 | [datetime(1997, 9, 2, 9, 0), |
| 75 | datetime(1999, 9, 2, 9, 0), |
| 76 | datetime(2001, 9, 2, 9, 0)]) |
| 77 | |
| 78 | def testYearlyIntervalLarge(self): |
| 79 | self.assertEqual(list(rrule(YEARLY, |
| 80 | count=3, |
| 81 | interval=100, |
| 82 | dtstart=datetime(1997, 9, 2, 9, 0))), |
| 83 | [datetime(1997, 9, 2, 9, 0), |
| 84 | datetime(2097, 9, 2, 9, 0), |
| 85 | datetime(2197, 9, 2, 9, 0)]) |
| 86 | |
| 87 | def testYearlyByMonth(self): |
| 88 | self.assertEqual(list(rrule(YEARLY, |
| 89 | count=3, |
| 90 | bymonth=(1, 3), |
| 91 | dtstart=datetime(1997, 9, 2, 9, 0))), |
| 92 | [datetime(1998, 1, 2, 9, 0), |
nothing calls this directly
no outgoing calls
no test coverage detected