Test Failed
Pull Request — master (#86)
by Daniel
04:59
created

test_sun.sunTest.assertSunOutput()   A

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nop 2
1
"""
2
Tests for the Marvin Sun action
3
"""
4
5
from unittest import mock
6
7
from test_action import ActionTest
8
from irc2phpbb import marvin_actions
9
10
class sunTest(ActionTest):
11
    """Tests for the Marvin Sun action"""
12
    def assertSunOutput(self, expectedOutput):
13
        """Test that marvin knows when the sun comes up, given an input file"""
14
        response = self.createResponseFrom("sun", "sun")
15
        with mock.patch("irc2phpbb.marvin_actions.requests") as r:
16
            r.get.return_value = response
17
            self.assertActionOutput(marvin_actions.marvinSun, "sol", expectedOutput)
18
19
    def testSun(self):
20
        """Test that marvin sends the sunrise and sunset times """
21
        self.assertSunOutput(
22
            "Idag går solen upp 7:12 och ner 18:21. Iallafall i trakterna kring BTH.")
23
24
    def testSunError(self):
25
        """Tests that marvin returns the proper error message when joke API is down"""
26
        with mock.patch("irc2phpbb.marvin_actions.requests.get", side_effect=Exception("API Down!")):
27
            self.assertStringsOutput(marvin_actions.marvinSun, "när går solen ner?", "sun", "error")
28