lavkach3

Форк
0
234 строки · 9.7 Кб
1
import datetime
2

3
import pytest
4

5
from app.inventory.location.enums import PutawayStrategy
6
from app.inventory.order.models import OrderClass, BackOrderAction, ReservationMethod
7

8
@pytest.mark.asyncio
9
async def test_crud_order_type(async_inventory_client, headers, stores, companies, products, locations, token, ):
10
    """
11
    Проверяем rруд вокруг товаров
12
    """
13
    create_data = {
14
        'company_id': companies[0].id.__str__(),
15
        'prefix': 'IN',
16
        'title': 'title',
17
        'order_class': 'incoming',
18
        'allowed_location_src_ids': [locations['partner'].id.__str__(),],
19
        'exclusive_location_src_ids': None,
20
        'allowed_location_dest_ids': [locations['place'].id.__str__(),],
21
        'exclusive_location_dest_ids': None,
22
        'backorder_order_type_id': None,
23
        'backorder_action_type': 'ask',
24
        'store_id': None,
25
        'partner_id': None,
26
        'reservation_method': 'at_confirm',
27
        'reservation_time_before': 0,
28
        'allowed_package_ids': [locations['package'].id.__str__(),],
29
        'exclusive_package_ids': None,
30
        'is_homogeneity': False,
31
        'is_allow_create_package': True,
32
        'is_can_create_order_manualy': True,
33
        'is_overdelivery': False,
34
        'created_by': token['user_admin']['user_id'].__str__(),
35
        'edited_by': token['user_admin']['user_id'].__str__(),
36
        'barcode': '2132132131231',
37
        'strategy': 'fefo',
38
    }
39
    response = await async_inventory_client.post("/api/inventory/order_type", json=create_data, headers=headers['superadmin'])
40
    assert response.status_code == 200
41
    data = response.json()
42
    order_type_id_1 = data['id']
43
    #--------------------------------
44
    # Изменяем
45
    update_data = {
46
        'prefix': 'OUT',
47
        'title': 'title',
48
        'order_class': 'outgoing',
49
        'allowed_location_src_ids': [locations['partner'].id.__str__(),],
50
        'exclusive_location_src_ids': None,
51
        'allowed_location_dest_ids': [locations['place'].id.__str__(),],
52
        'exclusive_location_dest_ids': None,
53
        'backorder_order_type_id': None,
54
        'backorder_action_type': 'ask',
55
        'store_id': None,
56
        'partner_id': None,
57
        'reservation_method': 'manual',
58
        'reservation_time_before': 5,
59
        'allowed_package_ids': [],
60
        'exclusive_package_ids': None,
61
        'is_homogeneity': False,
62
        'is_allow_create_package': True,
63
        'is_can_create_order_manualy': True,
64
        'is_overdelivery': False,
65
        'created_by': token['user_admin']['user_id'].__str__(),
66
        'edited_by': token['user_admin']['user_id'].__str__(),
67
        'barcode': '2132132131231',
68
        'strategy': 'fefo',
69
    }
70
    response = await async_inventory_client.put(f"/api/inventory/order_type/{order_type_id_1}", json=update_data, headers=headers['superadmin'], )
71
    assert response.status_code == 200
72
    # --------------------------------
73
    # Поиск
74
    response = await async_inventory_client.get("/api/inventory/order_type", headers=headers['superadmin'], params={'size': 100, 'search': 'title'}
75
    )
76
    assert response.status_code == 200
77
    data = response.json()
78
    assert len(data.get('data')) == 1
79
    # Удаление
80
    response = await async_inventory_client.delete(f"/api/inventory/order_type/{order_type_id_1}", headers=headers['superadmin'], )
81
    assert response.status_code == 200
82

83

84
@pytest.mark.asyncio
85
async def test_crud_order(async_inventory_client, token, headers, stores, companies, locations, order_types):
86
    """
87
    Проверяем rруд вокруг товаров
88
    """
89
    create_data = {
90
        'company_id': companies[0].id.__str__(),
91
        'order_type_id': order_types['inbound'].id.__str__(),
92
        'parent_id': None,
93
        'external_number': 'external id',
94
        'store_id': stores[0].id.__str__(),
95
        'partner_id': None,
96
        'lot_id': None,
97
        'origin_type': 'Purchase Order',
98
        'origin_number': 'Some Purchase Order Number',
99
        'planned_date': datetime.datetime.now().isoformat(),
100
        'actual_date': None,
101
        'created_by': token['user_admin']['user_id'].__str__(),
102
        'edited_by': token['user_admin']['user_id'].__str__(),
103
        'expiration_datetime': datetime.datetime.now().isoformat(),
104
        'users_ids': None,
105
        'description': 'description',
106
        'status': 'draft'
107

108
    }
109
    response = await async_inventory_client.post("/api/inventory/order", json=create_data, headers=headers['superadmin'])
110
    assert response.status_code == 200
111
    data = response.json()
112
    order_id_1 = data['id']
113
    #--------------------------------
114
    # Изменяем
115
    update_data = {
116
        'order_type_id': order_types['inbound'].id.__str__(),
117
        'parent_id': None,
118
        'external_number': 'external id',
119
        'store_id': stores[0].id.__str__(),
120
        'partner_id': None,
121
        'lot_id': None,
122
        'origin_type': 'Purchase Order',
123
        'origin_number': 'Some Purchase Order Number',
124
        'planned_date': datetime.datetime.now().isoformat(),
125
        'actual_date': None,
126
        'created_by': token['user_admin']['user_id'].__str__(),
127
        'edited_by': token['user_admin']['user_id'].__str__(),
128
        'expiration_datetime': datetime.datetime.now().isoformat(),
129
        'users_ids': None,
130
        'description': 'description',
131
        'status': 'draft'
132
    }
133
    response = await async_inventory_client.put(f"/api/inventory/order/{order_id_1}", json=update_data, headers=headers['superadmin'], )
134
    assert response.status_code == 200
135
    # --------------------------------
136
    # Поиск
137
    response = await async_inventory_client.get("/api/inventory/order", headers=headers['superadmin'], params={'size': 100, 'search': 'external id'}
138
    )
139
    assert response.status_code == 200
140
    data = response.json()
141
    assert len(data.get('data')) == 1
142
    # Удаление
143
    response = await async_inventory_client.delete(f"/api/inventory/order/{order_id_1}", headers=headers['superadmin'], )
144
    assert response.status_code == 200
145

146
@pytest.mark.asyncio
147
async def test_crud_move(async_inventory_client, token, headers, stores, companies, locations, order_types):
148
    """
149
    Перед созданием Move нужно обязятельно создать Order
150
    """
151
    create_data = {
152
        'company_id': companies[0].id.__str__(),
153
        'order_type_id': order_types['inbound'].id.__str__(),
154
        'parent_id': None,
155
        'external_number': 'external id 1',
156
        'store_id': stores[0].id.__str__(),
157
        'partner_id': None,
158
        'lot_id': None,
159
        'origin_type': 'Purchase Order',
160
        'origin_number': 'Some Purchase Order Number',
161
        'planned_date': datetime.datetime.now().isoformat(),
162
        'actual_date': None,
163
        'created_by': token['user_admin']['user_id'].__str__(),
164
        'edited_by': token['user_admin']['user_id'].__str__(),
165
        'expiration_datetime': datetime.datetime.now().isoformat(),
166
        'users_ids': None,
167
        'description': 'description',
168
        'status': 'draft'
169

170
    }
171
    response = await async_inventory_client.post("/api/inventory/order", json=create_data, headers=headers['superadmin'])
172
    assert response.status_code == 200
173
    data = response.json()
174
    order_id_1 = data['id']
175

176
    #--Перед созданием Move нужно обязятельно создать Order
177
    create_data = {
178
        'company_id': companies[0].id.__str__(),
179
        'order_type_id': order_types['inbound'].id.__str__(),
180
        'parent_id': None,
181
        'external_number': 'external id 2',
182
        'store_id': stores[0].id.__str__(),
183
        'partner_id': None,
184
        'lot_id': None,
185
        'origin_type': 'Purchase Order',
186
        'origin_number': 'Some Purchase Order Number',
187
        'planned_date': datetime.datetime.now().isoformat(),
188
        'actual_date': None,
189
        'created_by': token['user_admin']['user_id'].__str__(),
190
        'edited_by': token['user_admin']['user_id'].__str__(),
191
        'expiration_datetime': datetime.datetime.now().isoformat(),
192
        'users_ids': None,
193
        'description': 'description',
194
        'status': 'draft'
195

196
    }
197
    response = await async_inventory_client.post("/api/inventory/order", json=create_data,
198
                                                 headers=headers['superadmin'])
199
    assert response.status_code == 200
200
    data = response.json()
201
    order_id_1 = data['id']
202
    # --------------------------------
203

204
    # Изменяем
205
    update_data = {
206
        'order_type_id': order_types['inbound'].id.__str__(),
207
        'parent_id': None,
208
        'external_number': 'external id 3',
209
        'store_id': stores[0].id.__str__(),
210
        'partner_id': None,
211
        'lot_id': None,
212
        'origin_type': 'Purchase Order',
213
        'origin_number': 'Some Purchase Order Number',
214
        'planned_date': datetime.datetime.now().isoformat(),
215
        'actual_date': None,
216
        'created_by': token['user_admin']['user_id'].__str__(),
217
        'edited_by': token['user_admin']['user_id'].__str__(),
218
        'expiration_datetime': datetime.datetime.now().isoformat(),
219
        'users_ids': None,
220
        'description': 'description',
221
        'status': 'draft'
222
    }
223
    response = await async_inventory_client.put(f"/api/inventory/order/{order_id_1}", json=update_data, headers=headers['superadmin'], )
224
    assert response.status_code == 200
225
    # --------------------------------
226
    # Поиск
227
    response = await async_inventory_client.get("/api/inventory/order", headers=headers['superadmin'], params={'size': 100, 'search': 'external id'}
228
    )
229
    assert response.status_code == 200
230
    data = response.json()
231
    assert len(data.get('data')) == 2
232
    # Удаление
233
    response = await async_inventory_client.delete(f"/api/inventory/order/{order_id_1}", headers=headers['superadmin'], )
234
    assert response.status_code == 200

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.