-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_buildMenu.py
More file actions
65 lines (47 loc) · 1.53 KB
/
Copy pathtest_buildMenu.py
File metadata and controls
65 lines (47 loc) · 1.53 KB
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
__author__ = 'zahidirfan'
import unittest
from unittest import TestCase
from buildmenu import BuildMenu
from contextlib import contextmanager
@contextmanager
def mock_raw_input(mock):
original_raw_input = __builtins__.raw_input
__builtins__.raw_input = lambda _: mock
yield
__builtins__.raw_input = original_raw_input
class TestBuildMenu(TestCase):
"""
Build Menu Test Suite
"""
menu = BuildMenu()
def test_getting_input_main_menu(self):
"""
Input to main Menu
:return:
"""
print "Getting input from the user"
with mock_raw_input("1"):
self.assertEqual(self.menu.main_menu(), "1")
print "Main Menu Entered"
def test_getting_input(self):
"""
Takes the input from the user
:return:
"""
print "Getting input from the user"
with mock_raw_input("berries"):
self.assertEqual(self.menu.get_user_input(), "berries")
print "Found Item"
def test_find_food(self):
"""
This finds the value that has been entered.
:return:
"""
self.menu.read_csv('WHFoods CSV For Zahid.csv')
results = self.menu.build_menu_from_input("berries")
# Ensuring that result is equal to one "BlackBerries" is a record found in the file
self.assertEqual(results.len, 1, "The records are not found there must be some problem")
def test_add_data(self):
self.fail("If not written yet")
if __name__ == '__main__':
unittest.main()