-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_lookwell.py
57 lines (50 loc) · 1.37 KB
/
test_lookwell.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
# LookWell v0.0
# srl
from lookwell import ItemList, Mill
def get_list0():
list = ItemList({
"items": [
{
"tags": ["upc/0001", "food/organic/apple"],
"desc": "2# bag of fuji apple",
"unit": {
"unit": "pound",
"qty": 2,
"container": "bag"
},
}
]
})
return list
def test_itemlist():
list = get_list0()
assert list is not None
item = list.findByTag("upc/0001")
assert item is not None
assert item.unitstr() == "2 pound bag"
def test_mill():
mill = Mill(get_list0())
assert mill.qtyByTag('upc/0001') is None
mill.process({
"date": "2021-03-01"
})
assert mill.qtyByTag('upc/0001') is None
mill.process({
"buy": {
"tag": "upc/0001",
"qty": 2,
}
})
assert mill.qtyByTag("upc/0001").getInUnit("pound") == 4
mill.process({
"date": "2021-03-02",
"census": [
{"tag": "upc/0001",
"qty": {"unit": "each", "qty": 9}}]})
assert mill.qtyByTag("upc/001").getInUnit("each") == 9
mill.process({
"date": "2021-03-03",
"eat": [
{"tag": "upc/0001",
"qty": {"unit": "each", "qty": 2}}]})
assert mill.qtyByTag("upc/001").getInUnit("each") == 7