channel-app 0.0.131__py3-none-any.whl → 0.0.135__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- channel_app/app/product/service.py +16 -0
- channel_app/core/commands.py +3 -1
- channel_app/core/tests.py +15 -164
- channel_app/omnitron/commands/tests/test_products.py +494 -0
- {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/METADATA +1 -1
- channel_app-0.0.135.dist-info/RECORD +60 -0
- {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/WHEEL +1 -1
- channel_app/channel_app/app/__init__.py +0 -0
- channel_app/channel_app/app/order/__init__.py +0 -0
- channel_app/channel_app/app/order/service.py +0 -230
- channel_app/channel_app/app/product/__init__.py +0 -0
- channel_app/channel_app/app/product/service.py +0 -237
- channel_app/channel_app/app/product_price/__init__.py +0 -0
- channel_app/channel_app/app/product_price/service.py +0 -254
- channel_app/channel_app/app/product_stock/__init__.py +0 -0
- channel_app/channel_app/app/product_stock/service.py +0 -258
- channel_app/channel_app/app/setup/__init__.py +0 -0
- channel_app/channel_app/app/setup/service.py +0 -61
- channel_app/channel_app/channel/__init__.py +0 -0
- channel_app/channel_app/channel/commands/__init__.py +0 -0
- channel_app/channel_app/channel/commands/orders/__init__.py +0 -0
- channel_app/channel_app/channel/commands/orders/orders.py +0 -329
- channel_app/channel_app/channel/commands/product_categories.py +0 -1
- channel_app/channel_app/channel/commands/product_images.py +0 -1
- channel_app/channel_app/channel/commands/product_prices.py +0 -148
- channel_app/channel_app/channel/commands/product_stocks.py +0 -220
- channel_app/channel_app/channel/commands/products.py +0 -161
- channel_app/channel_app/channel/commands/setup.py +0 -948
- channel_app/channel_app/channel/integration.py +0 -84
- channel_app/channel_app/core/__init__.py +0 -0
- channel_app/channel_app/core/clients.py +0 -12
- channel_app/channel_app/core/commands.py +0 -364
- channel_app/channel_app/core/data.py +0 -227
- channel_app/channel_app/core/integration.py +0 -74
- channel_app/channel_app/core/products.py +0 -64
- channel_app/channel_app/core/settings.py +0 -28
- channel_app/channel_app/core/utilities.py +0 -99
- channel_app/channel_app/omnitron/__init__.py +0 -0
- channel_app/channel_app/omnitron/batch_request.py +0 -82
- channel_app/channel_app/omnitron/commands/__init__.py +0 -0
- channel_app/channel_app/omnitron/commands/batch_requests.py +0 -281
- channel_app/channel_app/omnitron/commands/error_reports.py +0 -86
- channel_app/channel_app/omnitron/commands/integration_actions.py +0 -200
- channel_app/channel_app/omnitron/commands/orders/__init__.py +0 -0
- channel_app/channel_app/omnitron/commands/orders/addresses.py +0 -242
- channel_app/channel_app/omnitron/commands/orders/cargo_companies.py +0 -40
- channel_app/channel_app/omnitron/commands/orders/customers.py +0 -72
- channel_app/channel_app/omnitron/commands/orders/orders.py +0 -450
- channel_app/channel_app/omnitron/commands/product_categories.py +0 -1
- channel_app/channel_app/omnitron/commands/product_images.py +0 -1
- channel_app/channel_app/omnitron/commands/product_prices.py +0 -192
- channel_app/channel_app/omnitron/commands/product_stocks.py +0 -229
- channel_app/channel_app/omnitron/commands/products.py +0 -735
- channel_app/channel_app/omnitron/commands/setup.py +0 -839
- channel_app/channel_app/omnitron/constants.py +0 -98
- channel_app/channel_app/omnitron/exceptions.py +0 -42
- channel_app/channel_app/omnitron/integration.py +0 -159
- channel_app/setup.py +0 -21
- channel_app-0.0.131.dist-info/RECORD +0 -110
- /channel_app/{channel_app → omnitron/commands/tests}/__init__.py +0 -0
- {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,494 @@
|
|
1
|
+
from unittest.mock import MagicMock, patch
|
2
|
+
from omnisdk.base_client import BaseClient
|
3
|
+
from omnisdk.omnitron.endpoints import (
|
4
|
+
ChannelIntegrationActionEndpoint,
|
5
|
+
ChannelProductEndpoint,
|
6
|
+
)
|
7
|
+
from omnisdk.omnitron.models import ChannelAttributeConfig
|
8
|
+
|
9
|
+
from channel_app.core.commands import OmnitronCommandInterface
|
10
|
+
from channel_app.core.tests import BaseTestCaseMixin
|
11
|
+
from channel_app.omnitron.commands.products import (
|
12
|
+
GetDeletedProducts,
|
13
|
+
GetInsertedProducts,
|
14
|
+
GetUpdatedProducts,
|
15
|
+
Product, GetMappedProducts, GetProductPrices,
|
16
|
+
)
|
17
|
+
from channel_app.omnitron.constants import BatchRequestStatus
|
18
|
+
|
19
|
+
|
20
|
+
class TestGetInsertedProducts(BaseTestCaseMixin):
|
21
|
+
"""
|
22
|
+
Test case for GetInsertedProducts
|
23
|
+
|
24
|
+
run: python -m unittest channel_app.omnitron.commands.tests.test_products.TestGetInsertedProducts
|
25
|
+
"""
|
26
|
+
def setUp(self) -> None:
|
27
|
+
self.get_inserted_products = GetInsertedProducts(
|
28
|
+
integration=self.mock_integration
|
29
|
+
)
|
30
|
+
self.sample_products = [
|
31
|
+
Product(name='test', failed_reason_type=None),
|
32
|
+
Product(name='test2', failed_reason_type='error')
|
33
|
+
]
|
34
|
+
self.limit = 1
|
35
|
+
|
36
|
+
@patch.object(GetInsertedProducts, 'get_products')
|
37
|
+
def test_get_data(self, mock_get_products):
|
38
|
+
mock_get_products.return_value = [self.sample_products[0]]
|
39
|
+
self.get_inserted_products.BATCH_SIZE = self.limit
|
40
|
+
|
41
|
+
products = self.get_inserted_products.get_data()
|
42
|
+
|
43
|
+
self.assertEqual(len(products), 1)
|
44
|
+
self.assertEqual(products[0].name, 'test')
|
45
|
+
mock_get_products.assert_called_once_with(limit=self.limit)
|
46
|
+
|
47
|
+
@patch.object(GetInsertedProducts, 'get_products')
|
48
|
+
def test_get_data_with_limit_in_objects_dict(self, mock_get_products):
|
49
|
+
mock_get_products.return_value = [self.sample_products[0]]
|
50
|
+
self.get_inserted_products.objects = {'limit': self.limit}
|
51
|
+
|
52
|
+
products = self.get_inserted_products.get_data()
|
53
|
+
|
54
|
+
self.assertEqual(len(products), 1)
|
55
|
+
self.assertEqual(products[0].name, 'test')
|
56
|
+
mock_get_products.assert_called_once_with(limit=self.limit)
|
57
|
+
|
58
|
+
def test_update_state_property(self):
|
59
|
+
self.assertEqual(
|
60
|
+
self.get_inserted_products.update_state,
|
61
|
+
BatchRequestStatus.commit
|
62
|
+
)
|
63
|
+
|
64
|
+
def test_validated_data(self):
|
65
|
+
validated_products = self.get_inserted_products.validated_data(
|
66
|
+
self.sample_products
|
67
|
+
)
|
68
|
+
|
69
|
+
self.assertIn(self.sample_products[0], validated_products)
|
70
|
+
self.assertNotIn(self.sample_products[1], validated_products)
|
71
|
+
|
72
|
+
@patch('channel_app.core.clients.OmnitronApiClient')
|
73
|
+
@patch.object(BaseClient, 'get_instance')
|
74
|
+
@patch.object(GetInsertedProducts, 'update_batch_request')
|
75
|
+
@patch.object(GetInsertedProducts, 'create_batch_objects')
|
76
|
+
@patch.object(ChannelProductEndpoint, 'list')
|
77
|
+
def test_get_products(
|
78
|
+
self,
|
79
|
+
mock_list,
|
80
|
+
mock_create_batch_objects,
|
81
|
+
mock_update_batch_request,
|
82
|
+
mock_get_instance,
|
83
|
+
mock_omnitron_api_client,
|
84
|
+
):
|
85
|
+
mock_list.return_value = self.sample_products
|
86
|
+
|
87
|
+
products = self.get_inserted_products.get_products(
|
88
|
+
limit=self.limit + 1
|
89
|
+
)
|
90
|
+
|
91
|
+
self.assertEqual(len(products), 2)
|
92
|
+
self.assertEqual(products[0].name, 'test')
|
93
|
+
self.assertEqual(products[1].name, 'test2')
|
94
|
+
|
95
|
+
|
96
|
+
class TestGetUpdatedProducts(BaseTestCaseMixin):
|
97
|
+
"""
|
98
|
+
Test case for GetUpdatedProducts
|
99
|
+
run: python -m unittest channel_app.omnitron.commands.tests.test_products.TestGetUpdatedProducts
|
100
|
+
"""
|
101
|
+
def setUp(self):
|
102
|
+
self.get_inserted_products = GetInsertedProducts(
|
103
|
+
integration=self.mock_integration
|
104
|
+
)
|
105
|
+
self.get_updated_products = GetUpdatedProducts(
|
106
|
+
integration=self.mock_integration
|
107
|
+
)
|
108
|
+
self.sample_products = [
|
109
|
+
Product(
|
110
|
+
pk=1,
|
111
|
+
name='test',
|
112
|
+
failed_reason_type=None,
|
113
|
+
modified_date='2021-01-01T00:00:00Z'
|
114
|
+
),
|
115
|
+
Product(
|
116
|
+
pk=2,
|
117
|
+
name='test2',
|
118
|
+
failed_reason_type='error',
|
119
|
+
modified_date='2021-01-01T00:00:00Z'
|
120
|
+
)
|
121
|
+
]
|
122
|
+
|
123
|
+
@patch.object(GetInsertedProducts, 'get_products')
|
124
|
+
@patch.object(GetUpdatedProducts, 'get_integration_actions')
|
125
|
+
def test_get_data(self, mock_get_integration_actions, mock_get_products):
|
126
|
+
mock_get_integration_actions.return_value = self.sample_products
|
127
|
+
mock_get_products.return_value = [self.sample_products[0]]
|
128
|
+
products = self.get_updated_products.get_data()
|
129
|
+
|
130
|
+
self.assertEqual(len(products), 1)
|
131
|
+
self.assertEqual(products[0].name, 'test')
|
132
|
+
|
133
|
+
@patch('channel_app.core.clients.OmnitronApiClient')
|
134
|
+
@patch.object(BaseClient, 'get_instance')
|
135
|
+
@patch.object(ChannelIntegrationActionEndpoint, '_list')
|
136
|
+
def test_get_integration_actions(
|
137
|
+
self,
|
138
|
+
mock_list,
|
139
|
+
mock_get_instance,
|
140
|
+
mock_omnitron_api_client
|
141
|
+
):
|
142
|
+
example_response = MagicMock()
|
143
|
+
example_response.json.return_value = [
|
144
|
+
{
|
145
|
+
'id': 1,
|
146
|
+
'channel': 1,
|
147
|
+
'content_type': 'product',
|
148
|
+
'remote_id': 1,
|
149
|
+
'object_id': 1,
|
150
|
+
},
|
151
|
+
{
|
152
|
+
'id': 2,
|
153
|
+
'channel': 1,
|
154
|
+
'content_type': 'product',
|
155
|
+
'remote_id': 2,
|
156
|
+
'object_id': 2,
|
157
|
+
}
|
158
|
+
]
|
159
|
+
mock_list.return_value = example_response
|
160
|
+
|
161
|
+
products = self.get_updated_products.get_integration_actions(
|
162
|
+
self.sample_products
|
163
|
+
)
|
164
|
+
|
165
|
+
for product in products:
|
166
|
+
for key, value \
|
167
|
+
in example_response.json.return_value[product.pk - 1].items():
|
168
|
+
self.assertEqual(
|
169
|
+
getattr(product.integration_action, key),
|
170
|
+
value
|
171
|
+
)
|
172
|
+
|
173
|
+
|
174
|
+
def test_get_integration_actions_without_product(self):
|
175
|
+
products = self.get_updated_products.get_integration_actions([])
|
176
|
+
self.assertEqual(products, [])
|
177
|
+
|
178
|
+
|
179
|
+
class TestGetInsertedOrUpdatedProducts(
|
180
|
+
TestGetInsertedProducts,
|
181
|
+
BaseTestCaseMixin
|
182
|
+
):
|
183
|
+
"""
|
184
|
+
Test case for GetInsertedOrUpdatedProducts
|
185
|
+
run: python -m unittest channel_app.omnitron.commands.tests.test_products.TestGetInsertedOrUpdatedProducts
|
186
|
+
"""
|
187
|
+
def setUp(self) -> None:
|
188
|
+
self.get_inserted_products = GetInsertedProducts(
|
189
|
+
integration=self.mock_integration
|
190
|
+
)
|
191
|
+
self.get_inserted_products.path = "inserts_or_updates"
|
192
|
+
return super().setUp()
|
193
|
+
|
194
|
+
|
195
|
+
class TestGetDeletedProducts(BaseTestCaseMixin):
|
196
|
+
"""
|
197
|
+
Test case for GetDeletedProducts
|
198
|
+
run: python -m unittest channel_app.omnitron.commands.tests.test_products.TestGetDeletedProducts
|
199
|
+
"""
|
200
|
+
|
201
|
+
def setUp(self) -> None:
|
202
|
+
self.get_deleted_products = GetDeletedProducts(
|
203
|
+
integration=self.mock_integration
|
204
|
+
)
|
205
|
+
self.products = [
|
206
|
+
{
|
207
|
+
"pk": 23,
|
208
|
+
"channel": 3,
|
209
|
+
"content_type": {
|
210
|
+
"id": 1,
|
211
|
+
"app_label": "products",
|
212
|
+
"model": "product"
|
213
|
+
},
|
214
|
+
"object_id": 1,
|
215
|
+
"remote_id": None,
|
216
|
+
"version_date": "2023-11-07T08:58:16.079727Z",
|
217
|
+
"state": {},
|
218
|
+
"modified_date": "2023-11-08T09:11:56.919937Z",
|
219
|
+
"local_batch_id": "7c43e5fb-32be-4a18-a6fa-539c9d2485ee",
|
220
|
+
"status": "processing",
|
221
|
+
"created_date": "2023-11-08T09:11:56.919929Z"
|
222
|
+
}
|
223
|
+
]
|
224
|
+
|
225
|
+
@patch.object(GetDeletedProducts, 'get_deleted_products_ia')
|
226
|
+
def test_get_data(self, mock_get_deleted_products_ia):
|
227
|
+
mock_get_deleted_products_ia.return_value = self.products
|
228
|
+
products = self.get_deleted_products.get_data()
|
229
|
+
self.assertEqual(len(products), 1)
|
230
|
+
|
231
|
+
product = products[0]
|
232
|
+
self.assertEqual(product.get('pk'), 23)
|
233
|
+
|
234
|
+
@patch('channel_app.core.clients.OmnitronApiClient')
|
235
|
+
@patch.object(BaseClient, 'get_instance')
|
236
|
+
@patch.object(ChannelIntegrationActionEndpoint, '_list')
|
237
|
+
def test_get_deleted_products_ia(
|
238
|
+
self,
|
239
|
+
mock_list,
|
240
|
+
mock_get_instance,
|
241
|
+
mock_omnitron_api_client
|
242
|
+
):
|
243
|
+
example_response = MagicMock()
|
244
|
+
example_response.json.return_value = self.products
|
245
|
+
mock_list.return_value = example_response
|
246
|
+
products_ia = self.get_deleted_products.get_deleted_products_ia()
|
247
|
+
self.assertEqual(len(products_ia), 1)
|
248
|
+
|
249
|
+
product = products_ia[0].get_parameters()
|
250
|
+
self.assertEqual(product.get('pk'), 23)
|
251
|
+
|
252
|
+
|
253
|
+
class TestGetMappedProducts(BaseTestCaseMixin):
|
254
|
+
"""
|
255
|
+
Test case for GetMappedProducts
|
256
|
+
run: python -m unittest channel_app.omnitron.commands.tests.test_products.TestGetMappedProducts
|
257
|
+
"""
|
258
|
+
|
259
|
+
def setUp(self) -> None:
|
260
|
+
self.get_mapped_products = GetMappedProducts(
|
261
|
+
integration=self.mock_integration
|
262
|
+
)
|
263
|
+
self.sample_products = [
|
264
|
+
Product(
|
265
|
+
pk=1,
|
266
|
+
name='test',
|
267
|
+
failed_reason_type=None,
|
268
|
+
modified_date='2021-01-01T00:00:00Z'
|
269
|
+
),
|
270
|
+
Product(
|
271
|
+
pk=2,
|
272
|
+
name='test2',
|
273
|
+
failed_reason_type='error',
|
274
|
+
modified_date='2021-01-01T00:00:00Z'
|
275
|
+
)
|
276
|
+
]
|
277
|
+
|
278
|
+
@patch.object(GetMappedProducts, 'get_mapping')
|
279
|
+
def test_get_data(self, mock_get_mapping):
|
280
|
+
mock_get_mapping.return_value = self.sample_products
|
281
|
+
result = self.get_mapped_products.get_data()
|
282
|
+
self.assertEqual(len(result), 2)
|
283
|
+
|
284
|
+
@patch.object(GetMappedProducts, 'check_product')
|
285
|
+
def test_validated_data(self, mock_check_product):
|
286
|
+
data = self.sample_products
|
287
|
+
self.get_mapped_products.validated_data(data)
|
288
|
+
self.assertEqual(mock_check_product.call_count, 2)
|
289
|
+
|
290
|
+
@patch.object(GetMappedProducts, 'get_attribute_config_list')
|
291
|
+
@patch.object(GetMappedProducts, 'update_and_check_product')
|
292
|
+
def test_check_product_gets_attribute_config_list(
|
293
|
+
self,
|
294
|
+
mock_update_and_check_product,
|
295
|
+
mock_get_attribute_config_list
|
296
|
+
):
|
297
|
+
product = Product()
|
298
|
+
product.mapped_attributes = MagicMock()
|
299
|
+
product.mapped_attributes.attribute_set_id = 1
|
300
|
+
product.mapped_attributes.mapped_attribute_values = {
|
301
|
+
"1": {
|
302
|
+
"value": "test"
|
303
|
+
}
|
304
|
+
}
|
305
|
+
mock_get_attribute_config_list.return_value = [
|
306
|
+
ChannelAttributeConfig()
|
307
|
+
]
|
308
|
+
self.get_mapped_products.check_product(
|
309
|
+
product,
|
310
|
+
{}
|
311
|
+
)
|
312
|
+
mock_get_attribute_config_list.assert_called_once()
|
313
|
+
|
314
|
+
@patch.object(GetMappedProducts, 'check_attribute_value_defined')
|
315
|
+
@patch.object(GetMappedProducts, 'check_required')
|
316
|
+
def test_update_and_check_product_checks_attribute_value_and_required(
|
317
|
+
self,
|
318
|
+
mock_check_required,
|
319
|
+
mock_check_attribute_value_defined
|
320
|
+
):
|
321
|
+
product = Product()
|
322
|
+
product.mapped_attributes = MagicMock()
|
323
|
+
product.mapped_attributes.mapped_attribute_values = {}
|
324
|
+
config = ChannelAttributeConfig()
|
325
|
+
config.attribute_remote_id = 1
|
326
|
+
config.is_required = True
|
327
|
+
config.is_variant = True
|
328
|
+
config.is_custom = True
|
329
|
+
config.is_meta = True
|
330
|
+
config.attribute = {
|
331
|
+
"pk": 1,
|
332
|
+
"name": "test",
|
333
|
+
}
|
334
|
+
result = self.get_mapped_products.update_and_check_product(
|
335
|
+
config,
|
336
|
+
product
|
337
|
+
)
|
338
|
+
self.assertFalse(result)
|
339
|
+
|
340
|
+
@patch.object(GetMappedProducts, 'check_attribute_value_defined')
|
341
|
+
@patch.object(GetMappedProducts, 'check_required')
|
342
|
+
def test_update_and_check_product(
|
343
|
+
self,
|
344
|
+
mock_check_required,
|
345
|
+
mock_check_attribute_value_defined
|
346
|
+
):
|
347
|
+
product = Product()
|
348
|
+
product.mapped_attributes = MagicMock()
|
349
|
+
product.mapped_attributes.mapped_attribute_values = {
|
350
|
+
"1": {
|
351
|
+
"value": "test"
|
352
|
+
}
|
353
|
+
}
|
354
|
+
config = ChannelAttributeConfig()
|
355
|
+
config.attribute_remote_id = 1
|
356
|
+
config.is_required = True
|
357
|
+
config.is_variant = True
|
358
|
+
config.is_custom = True
|
359
|
+
config.is_meta = True
|
360
|
+
config.attribute = {
|
361
|
+
"pk": 1,
|
362
|
+
"name": "test",
|
363
|
+
}
|
364
|
+
result = self.get_mapped_products.update_and_check_product(
|
365
|
+
config,
|
366
|
+
product
|
367
|
+
)
|
368
|
+
self.assertTrue(result)
|
369
|
+
|
370
|
+
@patch.object(GetMappedProducts, 'get_attribute_config_list')
|
371
|
+
def test_get_attribute_config_list_returns_configs_data(
|
372
|
+
self,
|
373
|
+
mock_get_attribute_config_list
|
374
|
+
):
|
375
|
+
config = ChannelAttributeConfig()
|
376
|
+
mock_get_attribute_config_list.return_value = [
|
377
|
+
config
|
378
|
+
]
|
379
|
+
result = self.get_mapped_products.get_attribute_config_list(
|
380
|
+
{"attribute_set": 1, "limit": 10}
|
381
|
+
)
|
382
|
+
self.assertEqual(result, [config])
|
383
|
+
|
384
|
+
def test_check_attribute_value_defined_raises_exception_when_mapped_value_not_defined(self):
|
385
|
+
mapped_attributes_obj = MagicMock()
|
386
|
+
mapped_attributes_obj.mapped_attributes = {"name": "value"}
|
387
|
+
mapped_attributes_obj.mapped_attribute_values = {}
|
388
|
+
config = ChannelAttributeConfig()
|
389
|
+
config.attribute = {"pk": 1, "name": "name"}
|
390
|
+
config.attribute_set = {"pk": 1, "name": "name"}
|
391
|
+
config.is_custom = False
|
392
|
+
with self.assertRaises(Exception):
|
393
|
+
self.get_mapped_products.check_attribute_value_defined(
|
394
|
+
config,
|
395
|
+
mapped_attributes_obj
|
396
|
+
)
|
397
|
+
|
398
|
+
def test_check_required_raises_exception_when_required_attribute_missing(self):
|
399
|
+
product = Product()
|
400
|
+
product.sku = "sku"
|
401
|
+
self.get_mapped_products.integration = MagicMock()
|
402
|
+
self.get_mapped_products.integration.channel_id = 1
|
403
|
+
mapped_attributes = {}
|
404
|
+
config = ChannelAttributeConfig()
|
405
|
+
config.attribute = {"name": "name"}
|
406
|
+
config.is_required = True
|
407
|
+
with self.assertRaises(Exception):
|
408
|
+
self.get_mapped_products.check_required(
|
409
|
+
product,
|
410
|
+
config,
|
411
|
+
mapped_attributes
|
412
|
+
)
|
413
|
+
|
414
|
+
@patch.object(GetMappedProducts, 'get_mapping')
|
415
|
+
def test_get_mapping_returns_mapped_products(self, mock_get_mapping):
|
416
|
+
product = Product()
|
417
|
+
mock_get_mapping.return_value = [product]
|
418
|
+
result = self.get_mapped_products.get_mapping([product])
|
419
|
+
self.assertEqual(result, [product])
|
420
|
+
|
421
|
+
@patch.object(GetMappedProducts, 'get_mapping')
|
422
|
+
def test_get_mapping_returns_empty_list_when_no_products(self, mock_get_mapping):
|
423
|
+
mock_get_mapping.return_value = []
|
424
|
+
result = self.get_mapped_products.get_mapping([])
|
425
|
+
self.assertEqual(result, [])
|
426
|
+
|
427
|
+
|
428
|
+
class TestGetMappedProductsWithOutCommit(TestGetMappedProducts):
|
429
|
+
pass
|
430
|
+
|
431
|
+
|
432
|
+
class TestGetProductPrices(BaseTestCaseMixin):
|
433
|
+
"""
|
434
|
+
Test case for GetProductPrices
|
435
|
+
run: python -m unittest channel_app.omnitron.commands.tests.test_products.TestGetProductPrices
|
436
|
+
"""
|
437
|
+
|
438
|
+
def setUp(self) -> None:
|
439
|
+
self.get_product_prices = GetProductPrices(
|
440
|
+
integration=self.mock_integration
|
441
|
+
)
|
442
|
+
|
443
|
+
@patch.object(BaseClient, 'get_instance')
|
444
|
+
@patch.object(GetProductPrices, 'get_prices')
|
445
|
+
def test_successful_product_price_retrieval(
|
446
|
+
self,
|
447
|
+
mock_get_instance,
|
448
|
+
mock_get_prices
|
449
|
+
):
|
450
|
+
products = [Product(pk=i, productprice=10) for i in range(1, 6)]
|
451
|
+
self.get_product_prices.objects = products
|
452
|
+
|
453
|
+
result = self.get_product_prices.get_data()
|
454
|
+
self.assertEqual(result, products)
|
455
|
+
|
456
|
+
@patch.object(GetProductPrices, 'get_prices')
|
457
|
+
@patch.object(BaseClient, 'get_instance')
|
458
|
+
def test_product_price_retrieval_with_successful_get_product_price(
|
459
|
+
self,
|
460
|
+
mock_get_instance,
|
461
|
+
mock_get_prices
|
462
|
+
):
|
463
|
+
products = [Product(pk=i) for i in range(1, 6)]
|
464
|
+
|
465
|
+
price_list = []
|
466
|
+
for product in products:
|
467
|
+
price = MagicMock()
|
468
|
+
price.product = product.pk
|
469
|
+
price_list.append(price)
|
470
|
+
|
471
|
+
mock_get_prices.return_value = price_list
|
472
|
+
result = self.get_product_prices.get_product_price(products)
|
473
|
+
self.assertEqual(result, products)
|
474
|
+
|
475
|
+
@patch.object(GetProductPrices, 'get_prices')
|
476
|
+
@patch.object(BaseClient, 'get_instance')
|
477
|
+
def test_product_price_retrieval_with_failed_get_product_price(
|
478
|
+
self,
|
479
|
+
mock_get_instance,
|
480
|
+
mock_get_prices
|
481
|
+
):
|
482
|
+
products = [Product(pk=i, product_price=0) for i in range(1, 6)]
|
483
|
+
|
484
|
+
price_list = []
|
485
|
+
for product in products:
|
486
|
+
price = MagicMock()
|
487
|
+
price.product = product.pk
|
488
|
+
|
489
|
+
if len(price_list) < len(products) - 1:
|
490
|
+
price_list.append(price)
|
491
|
+
|
492
|
+
mock_get_prices.return_value = price_list
|
493
|
+
result = self.get_product_prices.get_product_price(products)
|
494
|
+
self.assertFalse(hasattr(result[-1], 'productprice'))
|
@@ -0,0 +1,60 @@
|
|
1
|
+
channel_app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
channel_app/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
channel_app/app/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
channel_app/app/order/service.py,sha256=DTevtxN1SbnpzFC56LEvanCqNwO7tQM43PKtqCJSDK0,11272
|
5
|
+
channel_app/app/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
channel_app/app/product/service.py,sha256=7DZF-Vtoaf5eKT1m_ccEOAqUxWSO7Csop4HEtJmcrvw,10646
|
7
|
+
channel_app/app/product_image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
channel_app/app/product_image/service.py,sha256=5YsqymA2aVYO9bcy92sBDOixwnzw_H7RB2FbrXL48vI,5527
|
9
|
+
channel_app/app/product_price/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
channel_app/app/product_price/service.py,sha256=AJRwaQ3f93xWO-DqHCFVA_g9JtYyrM1sdrYUIXndTnE,12392
|
11
|
+
channel_app/app/product_stock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
+
channel_app/app/product_stock/service.py,sha256=Oh7-bA_TixCz7WeBdLJ5YOzPYXXQu9Mn9e3z_Wph7_E,12244
|
13
|
+
channel_app/app/setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
+
channel_app/app/setup/service.py,sha256=d53IKrQjahNZvxCaZAmXo2VUKBMM6-wm-P9I9tBTYOY,4553
|
15
|
+
channel_app/channel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
+
channel_app/channel/integration.py,sha256=q7wwPvYukEEoLCMZZ6d4GDiRHV8u_dPHT3cGU6DUuik,3587
|
17
|
+
channel_app/channel/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
|
+
channel_app/channel/commands/product_categories.py,sha256=ktN8NnWNcHcVREVOU-SSZbH5ZEwihAUOgHsZm1KcEpY,52
|
19
|
+
channel_app/channel/commands/product_images.py,sha256=8lCSt-_YkD1IytAXOtAJAwWd9d53QZPKir-iopK1fC0,4855
|
20
|
+
channel_app/channel/commands/product_prices.py,sha256=pOY_1qb_0soGyK1wkTy2epL4xUeFflFfWLGCKoVRiCo,4855
|
21
|
+
channel_app/channel/commands/product_stocks.py,sha256=3mUz9K1zA3ljvtcOBgD5uQsMHBmzTxrSfj5vHXBV5qs,8157
|
22
|
+
channel_app/channel/commands/products.py,sha256=ZzmJbcOJISOcsZ9F3FL012rqU-eNhwW_LGYYlb2WmzA,5257
|
23
|
+
channel_app/channel/commands/setup.py,sha256=NNUq7jzBHXt61Jhm9XExm2kXp6u7YEjO45fjpIRiNKk,36040
|
24
|
+
channel_app/channel/commands/orders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
|
+
channel_app/channel/commands/orders/orders.py,sha256=PcoDuJDR-1RuZBPqKgkPXJWkbr7OwQasyqzKrXigmFg,12487
|
26
|
+
channel_app/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
+
channel_app/core/clients.py,sha256=o8OBkXwof8BobEyiiHPwmGsUcOlPb60u3oUeAUxo_hc,1591
|
28
|
+
channel_app/core/commands.py,sha256=dQ-aJxZkc0j25hmp1Ui_s1ykY5LQ5_wxZCo6OrcxmnI,14120
|
29
|
+
channel_app/core/data.py,sha256=-9jDxdYZrvUhusbOfvtAfHwlweky_p-XD2zzOW5liLA,6302
|
30
|
+
channel_app/core/integration.py,sha256=OqpN8B3KBLsjjrbZXZaNVF6NtObejh7P_7kGFj1xU3o,2817
|
31
|
+
channel_app/core/products.py,sha256=uInjFw-vze1XP8vWEeq4VWDZVQQIiatoe1YsQ6n_H5E,2092
|
32
|
+
channel_app/core/settings.py,sha256=66y5YJksINO0WQ6UwXeYQXiCVfjrve0r4QgRENQaGyQ,1212
|
33
|
+
channel_app/core/tests.py,sha256=PXyVy3N1ylpHGZKKs6LbyB5kj493_4bvDQiVkSOci0M,433
|
34
|
+
channel_app/core/utilities.py,sha256=3iSU4RHFSsdTWBfUYBK23CRGtAIC-nYIBIJLm0Dlx3o,4168
|
35
|
+
channel_app/omnitron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
|
+
channel_app/omnitron/batch_request.py,sha256=S8IHtbI1RtVLbnOwtfXSmkrREGp8wUYW2E-eu5omwyY,3550
|
37
|
+
channel_app/omnitron/constants.py,sha256=2kvdez5VJPzhNcMyV0VaG_6JTYkUVYwuOifnMIwGOg8,2718
|
38
|
+
channel_app/omnitron/exceptions.py,sha256=_NjIx5LKPbKiP5jrJJGIfKGsRbGK6Thas3j5MGlq8Js,928
|
39
|
+
channel_app/omnitron/integration.py,sha256=Jw9SZeDMLKRxzrZB02FTVhwDbercawfCi_GwYSPqFdc,9253
|
40
|
+
channel_app/omnitron/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
|
+
channel_app/omnitron/commands/batch_requests.py,sha256=WXd1iCJKC-nCcMHZ2XDP9UVcC2Xq3MFd1uCqz8h5_pU,11638
|
42
|
+
channel_app/omnitron/commands/error_reports.py,sha256=PFeWryOjAyN6huKn5W8gq-ii0aa2yTGPfBoWieNL5RQ,2942
|
43
|
+
channel_app/omnitron/commands/integration_actions.py,sha256=PvjxXr85UYhiIaNF6ub_Bi5JZm5b59XFTlB52WxgZF0,7412
|
44
|
+
channel_app/omnitron/commands/product_categories.py,sha256=XCYJ-G2qxytNNnixnPKHosPXyNiVwQ2q202dRTITkVA,43
|
45
|
+
channel_app/omnitron/commands/product_images.py,sha256=fwUntMOzRvcXrVbZ5Xd5O73w7K009jPakXqVdmWKOuk,5561
|
46
|
+
channel_app/omnitron/commands/product_prices.py,sha256=HZ37Hw7YHKhZg7_kjSR-dNb0g2pz4WQAkcRHIwHLFvQ,12527
|
47
|
+
channel_app/omnitron/commands/product_stocks.py,sha256=LQFEdfv7hnY1-LWshat2h8hu7dAPDyngOCxfttqJxpw,13822
|
48
|
+
channel_app/omnitron/commands/products.py,sha256=As8Hnw3h6dOfPdxPBPUs-Hdip_9IaQXQyLAMsAylMTs,32098
|
49
|
+
channel_app/omnitron/commands/setup.py,sha256=dcbvvIFDKKeDVziwR2qWJhVd92IlVLEoYIbMrxKjWDE,35220
|
50
|
+
channel_app/omnitron/commands/orders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
|
+
channel_app/omnitron/commands/orders/addresses.py,sha256=l3lW8PuR19vIcPztghVxKMy6GszXAd_G1JvCOmV9evw,11777
|
52
|
+
channel_app/omnitron/commands/orders/cargo_companies.py,sha256=pTyOgsoIBLHUIj7F2eB_y3NXS8p8Qi0rsqjIZ7AZiWs,1308
|
53
|
+
channel_app/omnitron/commands/orders/customers.py,sha256=ojI04p6DLlNQUYGwuTBKOf8cNoXgeGFwleH8lM6WOxU,3518
|
54
|
+
channel_app/omnitron/commands/orders/orders.py,sha256=MJP3nAhBqOYfe028tjn7TOzxrjojcFNAIUScTxm2zXw,22755
|
55
|
+
channel_app/omnitron/commands/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
56
|
+
channel_app/omnitron/commands/tests/test_products.py,sha256=fHw4APDAoeCZ26eodk_xDTMfLpTXBG95MTDnkfD22KI,17220
|
57
|
+
channel_app-0.0.135.dist-info/METADATA,sha256=st1fMGE1L-XPVYRLJ7QlALqLl9Za6jtepbrQENRQ2is,353
|
58
|
+
channel_app-0.0.135.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
59
|
+
channel_app-0.0.135.dist-info/top_level.txt,sha256=JT-gM6L5Cwxr1xEoN7NHrREDs-d6iGFGfRnK-NrJ3tU,12
|
60
|
+
channel_app-0.0.135.dist-info/RECORD,,
|
File without changes
|
File without changes
|