-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_translator.py
67 lines (59 loc) · 2.63 KB
/
test_translator.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
63
64
65
66
67
#From exploratory testing to Automated Unit Testing :)
import translator as tsl
import unittest
class TestMorseTranslator(unittest.TestCase):
def test_morse_translation_func_single_word(self):
"""
Test that it can return right value of sos ->"... -- ..."
"""
data = "sos"
result_object = tsl.MorseTranslator(data)
result_value =result_object.morse_translation_func()
self.assertEqual(result_value,"... --- ...")
def test_morse_translation_func_two_words(self):
"""
Test that it can return right value of "sos sms"->"... --- ... / ... -- ..."
"""
data = "sos sms"
result_object = tsl.MorseTranslator(data)
result_value =result_object.morse_translation_func()
self.assertEqual(result_value,"... --- ... / ... -- ...")
def test_morse_translation_func_two_words_end_with_space(self):
"""
Test that it can return right value of "sos sms "->"... --- ... / ... -- ..."
Check that rstip working.
"""
data = "sos sms "
result_object = tsl.MorseTranslator(data)
result_value =result_object.morse_translation_func()
self.assertEqual(result_value,"... --- ... / ... -- ...")
def test_morse_translation_func_two_words_start_with_space(self):
"""
Test that it can return right value of " sos sms"->"... --- ... / ... -- ..."
Check that lstrip working.
"""
data = " sos sms"
result_object = tsl.MorseTranslator(data)
result_value =result_object.morse_translation_func()
self.assertEqual(result_value,"... --- ... / ... -- ...")
def test_morse_translation_func_two_words_capitalized(self):
"""
Test that it can return right value of "SOS SMS"->"... --- ... / ... -- ..."
Check that lower() working.
"""
data = "SOS SMS"
result_object = tsl.MorseTranslator(data)
result_value =result_object.morse_translation_func()
self.assertEqual(result_value,"... --- ... / ... -- ...")
def test_morse_translation_func_words_numbers(self):
"""
Test that it can return right value of "sos sms 12"->"... --- ... / ... -- ... / .---- ..---"
Check that lower() working.
"""
data = "sos sms 12"
preticted_result = "... --- ... / ... -- ... / .---- ..---"
result_object = tsl.MorseTranslator(data)
result_value =result_object.morse_translation_func()
self.assertEqual(result_value,preticted_result)
if __name__ == "__main__":
unittest.main()