summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-01-01 21:17:55 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2024-01-01 21:24:31 +0100
commitad4a9fe6c543deca1de8c6db8cda18eba7153ca4 (patch)
tree21d67fb5abf68dac0c532d6ffd1fb8380f5bda16 /test.py
parent70e43a432296fa6524e0468adaf271e13d6bb590 (diff)
downloadsignal-event-notifier-ad4a9fe6c543deca1de8c6db8cda18eba7153ca4.tar.gz
signal-event-notifier-ad4a9fe6c543deca1de8c6db8cda18eba7153ca4.zip
add responsibility offset
When the number of responsibilities is not a factor of 52 the next year has to start with an offset to continue the ongoing cycle. Since the event notifier is state less we pass the needed offset for the current year on the command line.
Diffstat (limited to 'test.py')
-rw-r--r--test.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/test.py b/test.py
index 5fbdd25..5ca77ea 100644
--- a/test.py
+++ b/test.py
@@ -8,6 +8,7 @@ import unittest
import signal_event_notifier as sen
DUMMY_CYCLIC_RESPONSIBILITIES = "alice:+1234\nbob:+5678,charlie:+5679"
+DUMMY_CYCLIC_RESPONSIBILITIES_3 = "alice:+1234\nbob:+5678\ncharlie:+5679"
TEST_CAL = "test/cal.ics"
@@ -33,11 +34,38 @@ class TestCyclicRespLoading(unittest.TestCase):
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):
+ for week in range(52 * 2):
resp = sen.load_responsibilities(day)
self.assertEqual(resp, expected[(week % 2)])
day += delta
+# pragma pylint: disable=missing-function-docstring,missing-class-docstring,invalid-name
+class TestCyclicUnevenRespLoading(unittest.TestCase):
+
+ def setUp(self):
+ os.environ[
+ sen.
+ RESPONSIBILITIES_ENV_VAR_NAME] = DUMMY_CYCLIC_RESPONSIBILITIES_3
+
+ 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 % 3)])
+ day += delta
+
+ # Second year
+ expected = [['bob:+5678'], ['charlie:+5679'], ['alice:+1234']]
+ offset = 1
+
+ for week in range(52):
+ resp = sen.load_responsibilities(day, offset=offset)
+ self.assertEqual(resp, expected[(week % 3)])
+ day += delta
+
+
if __name__ == '__main__':
unittest.main()