| Total Complexity | 3 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """ |
||
| 2 | Tests for the Marvin Morning action |
||
| 3 | """ |
||
| 4 | |||
| 5 | from datetime import date |
||
| 6 | from unittest import mock |
||
| 7 | |||
| 8 | from test_action import ActionTest |
||
| 9 | from irc2phpbb import marvin_general_actions |
||
| 10 | |||
| 11 | class MorningTest(ActionTest): |
||
| 12 | """Tests for the Marvin Morning action""" |
||
| 13 | def testMorning(self): |
||
| 14 | """Test that marvin wishes good morning, at most once per day""" |
||
| 15 | marvin_general_actions.lastDateGreeted = None |
||
| 16 | with mock.patch("irc2phpbb.marvin_general_actions.datetime") as d: |
||
| 17 | d.date.today.return_value = date(2024, 5, 17) |
||
| 18 | with mock.patch("irc2phpbb.marvin_general_actions.random") as r: |
||
| 19 | r.choice.return_value = "Morgon" |
||
| 20 | self.assertActionOutput(marvin_general_actions.marvinMorning, "morrn", "Morgon") |
||
| 21 | # Should only greet once per day |
||
| 22 | self.assertActionSilent(marvin_general_actions.marvinMorning, "morgon") |
||
| 23 | # Should greet again tomorrow |
||
| 24 | d.date.today.return_value = date(2024, 5, 18) |
||
| 25 | self.assertActionOutput(marvin_general_actions.marvinMorning, "godmorgon", "Morgon") |
||
| 26 |