-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_driver.py
122 lines (70 loc) · 3.84 KB
/
test_driver.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from driver import DeviceDriver, data_handler
driver = DeviceDriver()
# Execute test
def test_execute():
result = driver.execute_operation("apple", ["place"], [60])
assert result == "Not a valid operation."
# Pick test
def test_pick():
result = driver.execute_operation("pick", ["Destination"], [80])
assert result == "Wrong combination of parameters"
# Place test
def test_place():
result = driver.execute_operation("place", ["Source"], [80])
assert result == "Wrong combination of parameters"
# Transfer test
def test_transfer():
result = driver.execute_operation("transfer", ["origin", "apple"], [80, 100])
assert result == "Wrong combination of parameters"
# Initialize test
def test_initialize():
result, scheduled_tasks, initialized, previous_operation = data_handler("initialize", driver, [], 0, "")
assert result == ""
# Multiple initialization test
def test_initialize_twice():
result, scheduled_tasks, initialized, previous_operation = data_handler("initialize", driver, ["initialize"], 1, "")
assert result == "Already initialized"
# Hasn't been initialized test
def test_initialize_not():
result, scheduled_tasks, initialized, previous_operation = data_handler("pick", driver, [], 0, "")
assert result == "Not initialized"
# Invalid operation test
def test_invalid_operation():
result, scheduled_tasks, initialized, previous_operation = data_handler("mango", driver, ["initialize"], 1, "")
assert result == "invalid operation"
# Invalid combination of parameters test
def test_wrong_combination():
result, scheduled_tasks, initialized, previous_operation = data_handler("place ['Source'] [70]", driver, ["initialize"], 1, "")
assert result == "Wrong combination of parameters"
# Invalid combination of parameters test 2
def test_wrong_combination_2():
result, scheduled_tasks, initialized, previous_operation = data_handler("pick ['Destination'] [70]", driver, ["initialize"], 1, "")
assert result == "Wrong combination of parameters"
# Invalid combination of parameters test 3
def test_wrong_combination_3():
result, scheduled_tasks, initialized, previous_operation = data_handler("pick ['Destination','Source'] [70,80]", driver, ["initialize"], 1, "")
assert result == "Wrong combination of parameters"
# TypeError test
def test_incorrect_input():
result, scheduled_tasks, initialized, previous_operation = data_handler("pick ['Source'] ['70']", driver, ["initialize"], 1, "")
assert result == "Incorrect input format, parameter values incorrect"
# ValueError test
def test_incorrect_input_2():
result, scheduled_tasks, initialized, previous_operation = data_handler("place [Destination] ['70']", driver, ["initialize"], 1, "")
assert result == "Incorrect input format, make sure to use brackets or exclamation marks"
# SyntaxError test
def test_incorrect_input_3():
result, scheduled_tasks, initialized, previous_operation = data_handler("pick ['Source'] ['70]", driver, ["initialize"], 1, "")
assert result == "Incorrect input format, make sure to use brackets or exclamation marks"
# IndexError test
def test_incorrect_input_4():
result, scheduled_tasks, initialized, previous_operation = data_handler("transfer ['Source'] [60,70]", driver, ["initialize"], 1, "")
assert result == "Incorrect input format, list parameter mismatch"
# operation order test
def test_transfer_after_pick():
result, scheduled_tasks, initialized, previous_operation = data_handler("transfer ['Destination','Source'] [70,80]", driver, ["initialize"], 1, "pick")
assert result == "Cannot run transfer operation following pick"
# repetitive operation test
def test_pick_after_pick():
result, scheduled_tasks, initialized, previous_operation = data_handler("pick ['Source'] [70]", driver, ["initialize"], 1, "pick")
assert result == "Cannot repeat operation"