-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel_test.py
More file actions
99 lines (57 loc) · 2.11 KB
/
Copy pathmodel_test.py
File metadata and controls
99 lines (57 loc) · 2.11 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
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
import model
from db import exception
shop = model.Shop()
try:
shop.create_db("data/model_test.db", model.DbType.SQLITE)
except Exception as e:
print(e, e.args, vars(e))
shop.open_db("data/model_test.db", model.DbType.SQLITE)
products = [[1, "cookie", 42, 1, 0],
[2, "milk", 15, 2, 0],
[3, "potatoes", 11, 3, 0],
[4, "vodka", 11, 4, 0]
]
prodP = []
for i in ['deals','products','customers']:
print(tuple([i]) in list(shop.database.adapter.sqlite_cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")))
for prod in products:
try:
shop.add_product(model.Product(prod))
except exception.ConstraintException as e:
print(e.column_name, e.typeNum)
prodP.append(model.Product(prod))
customer = model.Customer([0,
"Pupkin",
"Vasya",
"8-800-555-35-35",
"NY, Wall Stret 17, 32 floor"])
shop.add_customer(customer)
print("=================Customers===============")
print(list(shop.get_from("customers")))
shop.order.set_customer(customer)
print(list(shop.get_from("product")))
for p in prodP:
p.count = 1
shop.to_cart(prodP)
print("Sum :{}".format(shop.order.get_sum()))
print(shop.order.get_customer().get_initials())
print("=================Products================")
print(list(shop.get_from("products")))
shop.remove_from_cart([prodP[3]])
print("Sum :{}".format(shop.order.get_sum()))
print("============Products {removed last}=======")
print(list(shop.get_from("products")))
shop.place_order()
shop.clear_order()
# print(shop.get_order())
# shop.to_cart([1, 2, 3])
# print(shop.get_order())
# shop.remove_from_cart([2])
# print(shop.get_order())
# shop.to_cart([4])
# print(shop.get_order())
# shop.remove_from_cart([1, 2])
print("=================Customers===============")
print(list(shop.get_from("customers")))
print("=================Products================")
print(list(shop.get_from("products")))