channel-app 0.0.146__tar.gz → 0.0.148__tar.gz

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.
Files changed (93) hide show
  1. {channel_app-0.0.146/channel_app.egg-info → channel_app-0.0.148}/PKG-INFO +1 -1
  2. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/orders/addresses.py +8 -3
  3. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/tests/test_orders.py +95 -3
  4. {channel_app-0.0.146 → channel_app-0.0.148/channel_app.egg-info}/PKG-INFO +1 -1
  5. {channel_app-0.0.146 → channel_app-0.0.148}/setup.py +1 -1
  6. {channel_app-0.0.146 → channel_app-0.0.148}/.gitignore +0 -0
  7. {channel_app-0.0.146 → channel_app-0.0.148}/.vscode/settings.json +0 -0
  8. {channel_app-0.0.146 → channel_app-0.0.148}/Makefile +0 -0
  9. {channel_app-0.0.146 → channel_app-0.0.148}/Procfile-dist +0 -0
  10. {channel_app-0.0.146 → channel_app-0.0.148}/README.md +0 -0
  11. {channel_app-0.0.146 → channel_app-0.0.148}/akinon.json-dist +0 -0
  12. {channel_app-0.0.146 → channel_app-0.0.148}/bitbucket-pipelines.yml +0 -0
  13. {channel_app-0.0.146 → channel_app-0.0.148}/build.sh-dist +0 -0
  14. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/__init__.py +0 -0
  15. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/__init__.py +0 -0
  16. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/order/__init__.py +0 -0
  17. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/order/service.py +0 -0
  18. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product/__init__.py +0 -0
  19. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product/service.py +0 -0
  20. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product_image/__init__.py +0 -0
  21. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product_image/service.py +0 -0
  22. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product_price/__init__.py +0 -0
  23. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product_price/service.py +0 -0
  24. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product_stock/__init__.py +0 -0
  25. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/product_stock/service.py +0 -0
  26. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/setup/__init__.py +0 -0
  27. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/app/setup/service.py +0 -0
  28. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/__init__.py +0 -0
  29. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/__init__.py +0 -0
  30. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/orders/__init__.py +0 -0
  31. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/orders/orders.py +0 -0
  32. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/product_categories.py +0 -0
  33. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/product_images.py +0 -0
  34. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/product_prices.py +0 -0
  35. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/product_stocks.py +0 -0
  36. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/products.py +0 -0
  37. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/commands/setup.py +0 -0
  38. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/channel/integration.py +0 -0
  39. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/__init__.py +0 -0
  40. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/clients.py +0 -0
  41. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/commands.py +0 -0
  42. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/data.py +0 -0
  43. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/integration.py +0 -0
  44. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/products.py +0 -0
  45. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/settings.py +0 -0
  46. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/tests/test_clients.py +0 -0
  47. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/tests.py +0 -0
  48. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/core/utilities.py +0 -0
  49. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/__init__.py +0 -0
  50. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/batch_request.py +0 -0
  51. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/__init__.py +0 -0
  52. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/batch_requests.py +0 -0
  53. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/error_reports.py +0 -0
  54. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/integration_actions.py +0 -0
  55. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/orders/__init__.py +0 -0
  56. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/orders/cargo_companies.py +0 -0
  57. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/orders/customers.py +0 -0
  58. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/orders/orders.py +0 -0
  59. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/product_categories.py +0 -0
  60. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/product_images.py +0 -0
  61. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/product_prices.py +0 -0
  62. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/product_stocks.py +0 -0
  63. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/products.py +0 -0
  64. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/setup.py +0 -0
  65. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/tests/__init__.py +0 -0
  66. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/tests/test_product_images.py +0 -0
  67. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/tests/test_product_prices.py +0 -0
  68. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/tests/test_product_stocks.py +0 -0
  69. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/commands/tests/test_products.py +0 -0
  70. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/constants.py +0 -0
  71. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/exceptions.py +0 -0
  72. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app/omnitron/integration.py +0 -0
  73. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app.egg-info/SOURCES.txt +0 -0
  74. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app.egg-info/dependency_links.txt +0 -0
  75. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app.egg-info/requires.txt +0 -0
  76. {channel_app-0.0.146 → channel_app-0.0.148}/channel_app.egg-info/top_level.txt +0 -0
  77. {channel_app-0.0.146 → channel_app-0.0.148}/docs/Makefile +0 -0
  78. {channel_app-0.0.146 → channel_app-0.0.148}/docs/make.bat +0 -0
  79. {channel_app-0.0.146 → channel_app-0.0.148}/docs/requirements.txt +0 -0
  80. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/architecture.rst +0 -0
  81. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/command_reference.rst +0 -0
  82. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/conf.py +0 -0
  83. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/flows.rst +0 -0
  84. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/images/async.png +0 -0
  85. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/images/batch_request_state_machine.png +0 -0
  86. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/images/sync.png +0 -0
  87. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/index.rst +0 -0
  88. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/installation_and_usage.rst +0 -0
  89. {channel_app-0.0.146 → channel_app-0.0.148}/docs/source/terminology.rst +0 -0
  90. {channel_app-0.0.146 → channel_app-0.0.148}/requirements-dev.txt +0 -0
  91. {channel_app-0.0.146 → channel_app-0.0.148}/requirements.txt +0 -0
  92. {channel_app-0.0.146 → channel_app-0.0.148}/setup.cfg +0 -0
  93. {channel_app-0.0.146 → channel_app-0.0.148}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: channel_app
3
- Version: 0.0.146
3
+ Version: 0.0.148
4
4
  Summary: Channel app for Sales Channels
5
5
  Home-page: https://github.com/akinon/channel_app
6
6
  Author: akinonteam
@@ -162,16 +162,19 @@ class GetOrCreateAddress(OmnitronCommandInterface):
162
162
  district_pk = district.pk
163
163
  return country_pk, city_pk, township_pk, district_pk
164
164
 
165
- def get_mapping_object(self, code, endpoint):
165
+ def get_mapping_object(self, code, endpoint, extra_filters=None):
166
166
  """
167
167
  :param code: Identifier code for the City and Country on the Sales Channel. This is
168
168
  prefix with channel_id as integration_code
169
169
  :param endpoint: omnitron sdk endpoint
170
+ :param extra_filters: extra filters for the endpoint, dict or None
170
171
  :return: mapped objects E.g (City, Country)
171
172
  """
172
173
  integration_code = f"{self.integration.channel_id}_{code}"
173
174
  params = {"mapping__code__exact": integration_code,
174
175
  "mapping__integration_type": INTEGRATION_TYPE}
176
+ if extra_filters:
177
+ params.update(extra_filters)
175
178
  objects = endpoint.list(params=params)
176
179
  if len(objects) != 1:
177
180
  raise IntegrationMappingException(params={"code": integration_code})
@@ -235,7 +238,8 @@ class GetOrCreateAddress(OmnitronCommandInterface):
235
238
  if len(townships) == 1:
236
239
  return townships[0]
237
240
  try:
238
- townships = self.get_mapping_object(township_name, endpoint)
241
+ extra_filters = {"city": city.pk, "is_active": True}
242
+ townships = self.get_mapping_object(township_name, endpoint, extra_filters)
239
243
  except IntegrationMappingException as exc:
240
244
  raise TownshipException(
241
245
  params={"type": ErrorType.township.value,
@@ -264,7 +268,8 @@ class GetOrCreateAddress(OmnitronCommandInterface):
264
268
  if len(districts) == 1:
265
269
  return districts[0]
266
270
  try:
267
- districts = self.get_mapping_object(district_name, endpoint)
271
+ extra_filters = {"city": city.pk, "township": township.pk, "is_active": True}
272
+ districts = self.get_mapping_object(district_name, endpoint, extra_filters)
268
273
  except IntegrationMappingException as exc:
269
274
  raise DistrictException(
270
275
  params={"type": ErrorType.district.value,
@@ -2,15 +2,16 @@ from dataclasses import asdict
2
2
  from unittest.mock import MagicMock, patch
3
3
  from omnisdk.base_client import BaseClient
4
4
  from omnisdk.omnitron.endpoints import (
5
- ChannelOrderEndpoint,
6
5
  ChannelCargoEndpoint,
7
6
  ChannelCustomerEndpoint,
7
+ ChannelOrderEndpoint,
8
+ ChannelOrderItemEndpoint,
8
9
  )
9
10
  from channel_app.core.data import CustomerDto, OrderBatchRequestResponseDto
10
11
  from channel_app.core.tests import BaseTestCaseMixin
11
12
  from channel_app.omnitron.commands.orders.cargo_companies import GetCargoCompany
12
13
  from channel_app.omnitron.commands.orders.customers import GetOrCreateCustomer
13
- from channel_app.omnitron.commands.orders.orders import ProcessOrderBatchRequests
14
+ from channel_app.omnitron.commands.orders.orders import GetOrderItems, GetOrderItemsWithOrder, ProcessOrderBatchRequests
14
15
  from channel_app.omnitron.constants import BatchRequestStatus, CustomerIdentifierField
15
16
 
16
17
 
@@ -389,4 +390,95 @@ class TestGetCargoCompany(BaseTestCaseMixin):
389
390
  cargo_company.erp_code,
390
391
  self.channel_cargo_endpoint_response_data['erp_code']
391
392
  )
392
-
393
+
394
+
395
+ class TestGetOrderItems(BaseTestCaseMixin):
396
+ """
397
+ Test case for GetOrderItems
398
+ run: python -m unittest channel_app.omnitron.commands.tests.test_orders.TestGetOrderItems
399
+ """
400
+ def setUp(self) -> None:
401
+ self.instance = GetOrderItems(
402
+ integration=self.mock_integration,
403
+ )
404
+ self.order = MagicMock(
405
+ pk=1,
406
+ )
407
+ self.order_items = [
408
+ MagicMock(
409
+ pk=7,
410
+ order=1,
411
+ content_type='orderitem'
412
+ ),
413
+ MagicMock(
414
+ pk=8,
415
+ order=1,
416
+ content_type='orderitem'
417
+ )
418
+ ]
419
+ self.instance.objects = self.order
420
+
421
+ @patch.object(GetOrderItems, 'get_order_items')
422
+ def test_get_data(self, mock_get_order_items):
423
+ mock_get_order_items.return_value = self.order_items
424
+ order_items = self.instance.get_data()
425
+
426
+ self.assertEqual(len(order_items), 2)
427
+
428
+ for order_item in order_items:
429
+ self.assertEqual(order_item.order, self.order.pk)
430
+ self.assertEqual(order_item.content_type, 'orderitem')
431
+
432
+ def test_get_order_items(self):
433
+ response = MagicMock()
434
+ response.list.return_value = self.order_items
435
+
436
+ with patch.object(
437
+ ChannelOrderItemEndpoint,
438
+ '__new__',
439
+ return_value=response
440
+ ):
441
+ order_items = self.instance.get_order_items(self.order)
442
+ self.assertEqual(len(order_items), 2)
443
+
444
+ for order_item in order_items:
445
+ self.assertEqual(order_item.order, self.order.pk)
446
+ self.assertEqual(order_item.content_type, 'orderitem')
447
+
448
+
449
+ class TestGetOrderItemsWithOrder(BaseTestCaseMixin):
450
+ """
451
+ Test case for GetOrderItems
452
+ run: python -m unittest channel_app.omnitron.commands.tests.test_orders.TestGetOrderItemsWithOrder
453
+ """
454
+ def setUp(self) -> None:
455
+ self.instance = GetOrderItemsWithOrder(
456
+ integration=self.mock_integration,
457
+ )
458
+ self.orders = [
459
+ MagicMock(
460
+ pk=1,
461
+ orderitem_set=[],
462
+ ),
463
+ ]
464
+ self.order_items = [
465
+ MagicMock(
466
+ pk=7,
467
+ order=1,
468
+ content_type='orderitem'
469
+ ),
470
+ MagicMock(
471
+ pk=8,
472
+ order=1,
473
+ content_type='orderitem'
474
+ ),
475
+ ]
476
+ self.instance.objects = self.orders
477
+
478
+ @patch.object(GetOrderItemsWithOrder, 'get_order_items')
479
+ def test_get_data(self, mock_get_order_items):
480
+ mock_get_order_items.return_value = self.order_items
481
+ orders = self.instance.get_data()
482
+
483
+ self.assertEqual(len(orders), 1)
484
+ self.assertEqual(len(orders[0].orderitem_set), 2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: channel_app
3
- Version: 0.0.146
3
+ Version: 0.0.148
4
4
  Summary: Channel app for Sales Channels
5
5
  Home-page: https://github.com/akinon/channel_app
6
6
  Author: akinonteam
@@ -5,7 +5,7 @@ with open("README.md") as f:
5
5
 
6
6
  setup(
7
7
  name="channel_app",
8
- version="0.0.146",
8
+ version="0.0.148",
9
9
  packages=find_packages(),
10
10
  url="https://github.com/akinon/channel_app",
11
11
  description="Channel app for Sales Channels",
File without changes
File without changes
File without changes
File without changes
File without changes