diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-07-16 22:24:55 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-07-16 22:24:55 +0200 |
| commit | 6985b205d60dc78d53b0d30ab0a94d203e06aae8 (patch) | |
| tree | 201850f98c9312d504443c9cb897a612b90e4fc3 /test.py | |
| download | signal-event-notifier-6985b205d60dc78d53b0d30ab0a94d203e06aae8.tar.gz signal-event-notifier-6985b205d60dc78d53b0d30ab0a94d203e06aae8.zip | |
initial commit
Diffstat (limited to 'test.py')
| -rw-r--r-- | test.py | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +"""Test for the signal event notifier""" + +import datetime +import os +import unittest + +import signal_event_notifier as sen + +DUMMY_CYCLIC_RESPONSIBILITIES = "alice:+1234\nbob:+5678,charlie:+5679" + +TEST_CAL = "test/cal.ics" + + +# pragma pylint: disable=missing-function-docstring,missing-class-docstring,invalid-name +class TestCyclicRespLoading(unittest.TestCase): + + def setUp(self): + os.environ[ + sen.RESPONSIBILITIES_ENV_VAR_NAME] = DUMMY_CYCLIC_RESPONSIBILITIES + + def test_cyclic_resp_first_week(self): + first = datetime.date(year=2013, month=1, day=1) + resp = sen.load_responsibilities(first) + self.assertEqual(resp, ['alice:+1234']) + + def test_cyclic_resp_second_week(self): + second = datetime.date(year=2013, month=1, day=8) + resp = sen.load_responsibilities(second) + self.assertEqual(resp, ['bob:+5678', 'charlie:+5679']) + + def test_cyclic_resp_all_weeks(self): + expected = [['alice:+1234'], ['bob:+5678', 'charlie:+5679']] + day = datetime.date(year=2013, month=1, day=1) + delta = datetime.timedelta(days=7) + for week in range(52): + resp = sen.load_responsibilities(day) + self.assertEqual(resp, expected[(week % 2)]) + day += delta + + +if __name__ == '__main__': + unittest.main() |
