-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
30 lines (22 loc) · 872 Bytes
/
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
from data import load_data_from_json_file
from matsmart import get_available_items
"""
Super-rudimentary testing, invoke as module;
python -m test
Returns "Passed" if the get_available_items_json result corresponds to the saved test_results.json
"""
# test_item_list = ["bovete", "chia", "matvete", "quinoa", "havregryn"]
def ordered(obj):
if isinstance(obj, dict):
return sorted((k, ordered(v)) for k, v in obj.items())
if isinstance(obj, list):
return sorted(ordered(x) for x in obj)
else:
return obj
def test_available_result():
test_result = get_available_items(as_dict=True)
correct_result = load_data_from_json_file(filename="test_data/results.json")
assert ordered(test_result) == ordered(correct_result), "Should be same result"
if __name__ == "__main__":
test_available_result()
print("Passed")