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

test_morning   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A MorningTest.testMorning() 0 13 3
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