/
server_test.py
41 lines (31 loc) · 983 Bytes
/
server_test.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
import unittest
import serv
class LoginTest(unittest.TestCase):
def test_login(self):
password = ''
with open('password.txt', 'r') as tmp_file:
password = tmp_file.read()
self.assertTrue(serv.login(password))
class ParserTest(unittest.TestCase):
def test_parse(self):
tmp_process = "ready"
food_entry = "Username, bread, 1, milk, 3"
tmp_dict = {
"Username": {
"process": tmp_process,
"bread": 1,
"milk": 3
}
}
self.assertEqual(tmp_dict, serv.parse_food(food_entry, tmp_process))
class NewParserTest(unittest.TestCase):
def test_new_parser(self):
food_entry = 'Bread, 1, Milk, 2, Meat, 3'
tmp_order = {
"Bread": 1,
"Milk": 2,
"Meat": 3
}
self.assertEqual(tmp_order, serv.parse_new_food(food_entry))
if __name__ == "__main__":
unittest.main()