-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEX08.py
62 lines (50 loc) · 2.27 KB
/
EX08.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""Callcentre tester."""
import EX08_helper
import unittest
class Tests(unittest.TestCase):
"""
Callcentre class testing class.
This class contain methods that test Callcentre class.
"""
def setup(self):
"""
Create object with EX08_helper.
This method creates a callcentre module with the help
of the EX08_helper module and get_callcentre() method
"""
call_centre_instance = EX08_helper.get_callcentre()
return call_centre_instance
def test_not_looping(self):
""""Test if callcentre returns right noun."""
instance = self.setup()
noun_list = ["koer", "porgand", "madis", "kurk", "tomat", "koer"]
for i in range(6):
self.assertEqual(
instance.create_sentence('noun'), noun_list[i])
def test_caps_data(self):
"""Test if callcentre handles capslock."""
instance = self.setup()
self.assertEqual(
instance.create_sentence('noun ABABAB'), 'koer ABABAB')
def test_recursive(self):
"""Test if callcentre prints two sentences."""
instance = self.setup()
self.assertEqual(instance.create_sentence('twosentences'),
'koer sööb koera . porgand lööb porgandit .')
def test_false_order(self):
"""Test if words appear in right order."""
instance = self.setup()
self.assertEqual(instance.create_sentence('beautifulsentence '
'beautifulsentence '
'beautifulsentence '
'beautifulsentence '
'beautifulsentence '
'beautifulsentence'),
'ilus koer sööb ilusat koera . '
'kole porgand lööb koledat porgandit . '
'pahane madis jagab pahast madist . '
'magus kurk tahab magusat kurki . '
'sinu tomat ei taha sinu tomatit . '
'ilus koer sööb ilusat koera .')
if __name__ == '__main__':
unittest.main()