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

test_lunch   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 18
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A LunchTest.testLunchLocations() 0 13 4
1
"""
2
Tests for the Marvin Lunch action
3
"""
4
5
from unittest import mock
6
7
from test_action import ActionTest
8
from irc2phpbb import marvin_actions
9
10
class LunchTest(ActionTest):
11
    """Tests for the Marvin Lunch action"""
12
    def testLunchLocations(self):
13
        """Test that marvin can provide lunch suggestions for certain places"""
14
        locations = ["karlskrona", "goteborg", "angelholm", "hassleholm", "malmo"]
15
        with mock.patch("irc2phpbb.marvin_actions.random") as r:
16
            for location in locations:
17
                for i, place in enumerate(self.strings.get("lunch").get("location").get(location)):
18
                    r.randint.side_effect = [0, i]
19
                    self.assertActionOutput(
20
                        marvin_actions.marvinLunch, f"mat {location}", f"Ska vi ta {place}?")
21
            r.randint.side_effect = [1, 2]
22
            self.assertActionOutput(
23
                marvin_actions.marvinLunch, "dags att luncha", "Jag är lite sugen på Indiska?")
24
        self.assertActionSilent(marvin_actions.marvinLunch, "matdags")
25