-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_service.py
34 lines (24 loc) · 981 Bytes
/
test_service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import unittest
from testfixtures import compare
from testfixtures import ShouldRaise
class TestServiceChoicesDetect(unittest.TestCase):
def _callFUT(self, *args, **kwargs):
from nhk.service import ServiceChoices
return ServiceChoices.detect(*args, **kwargs)
def test_detect_by_service(self):
from nhk.service import Service
service = Service('666', 'spam')
result = self._callFUT(service)
compare(result.code, '666')
compare(result.name, 'spam')
def test_detect_by_code(self):
result = self._callFUT('g1')
compare(result.code, 'g1')
compare(result.name, 'NHK総合1')
def test_detect_by_name(self):
result = self._callFUT('NHK総合1')
compare(result.code, 'g1')
compare(result.name, 'NHK総合1')
def test_detect_error(self):
with ShouldRaise(KeyError('Service: ham not found')):
self._callFUT('ham')