-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormatterFT.py
51 lines (43 loc) · 1.54 KB
/
FormatterFT.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
import unittest
from Formatter import QueryFormatter
from FTData import TestData
class QueryFormatterFT(unittest.TestCase):
def setUp(self):
self.formatter = QueryFormatter()
def test_lower_query_str(self):
"""
GIVEN:query str with Upper chars
WHEN :call translate interface
THEN :translate all Upper chars to lower in query str
"""
ret = self.formatter.translate("HellO")
self.assertEqual("hello", ret)
def test_repalce_dish(self):
"""
GIVEN:query str with -
WHEN :call translate interface
THEN :trans - to \- in query str
"""
for data in TestData['REPLACE_DISH']:
ret = self.formatter.translate(data['INPUT'])
self.assertEqual(data['EXPECT'], ret)
def test_query_str_with_dish_and_no_replace_secen(self):
"""
GEVEN:query str with - and start with " and end with "
WEHN : call translate interface
THEN : not translate - in query str
"""
for data in TestData["NO_REPLACE_DISH"]:
ret = self.formatter.translate(data['INPUT'])
self.assertEqual(data['EXPECT'], ret)
def test_query_str_has_been_replaced(self):
"""
GEVEN:query str with \\-
WHEN :call trnaslate interface
THEN : - will not replace
"""
for data in TestData['HAS_BEEN_REPLACED']:
ret = self.formatter.translate(data['INPUT'])
self.assertEqual(data['EXPECT'], ret)
if __name__ == "__main__":
unittest.main()