-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconftest.py
207 lines (154 loc) · 5.34 KB
/
conftest.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import pytest
from enum import Enum
from supplier import models
from client.models import Client
from delivery_location.models import DeliveryLocation
from product.models import Product
from supplier_product.models import SupplierProduct
from ordered_product.models import OrderedProduct
import datetime
from django.contrib.auth.models import User
class TestFields(Enum):
USER_NAME_TEST = 'ScrappyKoko'
FIRST_NAME_TEST = 'Zohan'
LAST_NAME_TEST = 'Dvir'
PASSWORD_TEST = 'silkysmooth'
BUSINESS_NAME_TEST = 'hair_salon_inc'
class Fields(Enum):
user_name = 1
first_name = 2
last_name = 3
password = 4
business_name = 5
@pytest.fixture
def supplier0():
"""Creates supplier fixture.
Creates supplier fixture for further testing.
Args:
None.
Returns:
Supplier fixture.
"""
return models.Supplier(supplier_account=User.objects.create_user(username=TestFields['USER_NAME_TEST'].value,
first_name=TestFields['FIRST_NAME_TEST'].value,
last_name=TestFields['LAST_NAME_TEST'].value,
password=TestFields['PASSWORD_TEST'].value,),
business_name=TestFields['BUSINESS_NAME_TEST'].value)
@pytest.fixture()
def supplier1():
return models.Supplier(supplier_account=User.objects.create_user(username='meitar1234',
first_name='meitar',
last_name='rizner',
password='123456',),
business_name='vegShop')
@pytest.fixture
def saved_supplier0(supplier0):
"""Saves the supplier fixture.
Args:
Supplier0: supplier fixture.
Returns:
Supplier fixture.
"""
models.Supplier.save_supplier(supplier0)
return supplier0
@pytest.fixture
def saved_supplier1(supplier1):
models.Supplier.save_supplier(supplier1)
return supplier1
@pytest.fixture()
def client0():
return Client(client_account=User.objects.create_user(username='liorsil311',
first_name='lior',
last_name='silberman',
password='1234qwer',),
area='Tel Aviv')
@pytest.fixture
def client1():
return Client(client_account=User.objects.create_user(username="meitar1996",
first_name="Meitar",
last_name="rizner",
password="1234",),
area="Yuval")
@pytest.fixture
def saved_client0(client0):
client0.save_client()
return client0
@pytest.fixture
def saved_client1(client1):
client1.save_client()
return client1
@pytest.fixture
def product0():
return Product(qr_code="Q5o76MbdiNbXprNEnHfpcGWFp1CMF8XY",
product_name="Apple",
description="Sweety!")
@pytest.fixture
def product1():
return Product(qr_code="Q5o76MbdiNbXprNEnHfpcGWFp1CMF8XZ",
product_name="Tomato",
description="Sweety!")
@pytest.fixture
def saved_product0(product0):
product0.save_product()
return product0
@pytest.fixture
def saved_product1(product1):
product1.save_product()
return product1
@pytest.fixture
def supplier_product0(saved_product0, saved_supplier0):
SUPPLIER_PRODUCT_ID = 123685
QUANTITY = 9
PRICE = 14
return SupplierProduct(
supplier_product_id=SUPPLIER_PRODUCT_ID,
qr_code=saved_product0,
user_name=saved_supplier0,
price=PRICE,
quantity=QUANTITY
)
@pytest.fixture
def supplier_product1(saved_product1, saved_supplier0):
return SupplierProduct(qr_code=saved_product1,
user_name=saved_supplier0,
price=5,
quantity=50)
@pytest.fixture
def saved_supplier_product0(supplier_product0):
SupplierProduct.save_sup_product(supplier_product0)
return supplier_product0
@pytest.fixture
def saved_supplier_product1(supplier_product1):
SupplierProduct.save_sup_product(supplier_product1)
return supplier_product1
@pytest.fixture
def delivery_location0(saved_supplier0):
return DeliveryLocation(user_name=saved_supplier0, location="Kiryat Shemona", date=datetime.date(2022, 12, 30))
@pytest.fixture
def delivery_location1(delivery_location0):
return DeliveryLocation(user_name=delivery_location0.user_name, location="Haifa", date=datetime.date(2022, 12, 31))
@pytest.fixture
def delivery_location2(saved_supplier0):
return DeliveryLocation(user_name=saved_supplier0, location="Tel Aviv", date=datetime.date(2022, 12, 30))
@pytest.fixture
def delivery_location3(saved_supplier1):
return DeliveryLocation(user_name=saved_supplier1, location="Tel Aviv", date=datetime.date(2022, 12, 30))
@pytest.fixture
def ordered_product0(delivery_location0, saved_client0, saved_product0):
supprod = SupplierProduct(
supplier_product_id=63147,
qr_code=saved_product0,
user_name=delivery_location0.user_name,
price=142,
quantity=91
)
SupplierProduct.save_sup_product(supprod)
delivery_location0.add_delivery_location()
return OrderedProduct(
delivery_location_id=delivery_location0,
user_name=saved_client0,
supplier_product_id=supprod,
quantity=3)
@pytest.fixture
def client0_login(client, saved_client0):
client.force_login(user=saved_client0.client_account)