Test Failed
Pull Request — master (#86)
by Daniel
06:22 queued 03:08
created

test_morning.MorningTest.testMorning()   A

Complexity

Conditions 3

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 13
rs 9.9
c 0
b 0
f 0
cc 3
nop 1
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