diff --git a/.travis.yml b/.travis.yml index 216eef5..c91455d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ python: - '3.5' - '3.6' - '3.7' + - '3.8' before_install: - pip install -r requirements.txt script: diff --git a/README b/README index 41ff9a3..f69296c 100644 --- a/README +++ b/README @@ -75,5 +75,5 @@ Documentation - `English`_ - `Russian`_ -.. _English: http://www.retailcrm.pro/docs/Developers/Index -.. _Russian: http://www.retailcrm.ru/docs/Developers/Index \ No newline at end of file +.. _English: https://help.retailcrm.pro/Developers/Index +.. _Russian: https://help.retailcrm.ru/Developers/Index diff --git a/README.md b/README.md index 6ef288c..74480a9 100644 --- a/README.md +++ b/README.md @@ -77,5 +77,5 @@ result = client.task_create(task, site) ## Documentation -* [English](http://www.retailcrm.pro/docs/Developers/Index) -* [Russian](http://www.retailcrm.ru/docs/Developers/Index) +* [English](https://help.retailcrm.pro/Developers/Index) +* [Russian](https://help.retailcrm.ru/Developers/Index) diff --git a/requirements.txt b/requirements.txt index 871dfba..a724468 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ multidimensional-urlencode==0.0.4 nose==1.3.7 -requests==2.20.0 -coverage==4.5.4 +requests==2.24.0 +coverage==5.2.1 +pook==1.0.1 +setuptools==49.6.0 diff --git a/retailcrm/versions/v4.py b/retailcrm/versions/v4.py index 57605e8..6c357d7 100644 --- a/retailcrm/versions/v4.py +++ b/retailcrm/versions/v4.py @@ -592,16 +592,16 @@ class Client(Base): return self.post('/telephony/calls/upload') - def telephony_manager(self, phone, details=True, ignoreStatus=False): + def telephony_manager(self, phone, details=True, ignore_status=False): """ :param phone: string :param details: string - :param ignoreStatus: string + :param ignore_status: string :return: Response """ self.parameters['phone'] = phone self.parameters['details'] = details - self.parameters['ignoreStatus'] = ignoreStatus + self.parameters['ignoreStatus'] = ignore_status return self.get('/telephony/manager') @@ -658,5 +658,5 @@ class Client(Base): """ :return: Response """ - + return self.get('/statistic/update') diff --git a/retailcrm/versions/v5.py b/retailcrm/versions/v5.py index 4594014..8819bcd 100644 --- a/retailcrm/versions/v5.py +++ b/retailcrm/versions/v5.py @@ -479,8 +479,12 @@ class Client(Base): return self.post('/customers-corporate/' + str(address[uid_type]) + '/addresses/create') - - def customer_corporate_addresses_edit(self, uid_corporate, address, uid_type='externalId', entity_by='externalId', site=None): + def customer_corporate_addresses_edit(self, + uid_corporate, + address, + uid_type='externalId', + entity_by='externalId', + site=None): """ :param address: object :param uid_corporate: string @@ -493,14 +497,18 @@ class Client(Base): if uid_type != 'externalId': self.parameters['by'] = uid_type - + if entity_by != 'externalId': self.parameters['entityBy'] = entity_by if site is not None: self.parameters['site'] = site - return self.post('/customers-corporate/' + str(uid_corporate) + '/addresses/' + str(address[entity_by]) + '/edit') + return self.post('/customers-corporate/' + + str(uid_corporate) + + '/addresses/' + + str(address[entity_by]) + + '/edit') def customer_corporate_companies(self, uid, uid_type='externalId', limit=20, page=1, filters=None, site=None): """ @@ -542,7 +550,12 @@ class Client(Base): return self.post('/customers-corporate/' + str(company[uid_type]) + '/companies/create') - def customer_corporate_companies_edit(self, uid_corporate, company, uid_type='externalId', entity_by='externalId', site=None): + def customer_corporate_companies_edit(self, + uid_corporate, + company, + uid_type='externalId', + entity_by='externalId', + site=None): """ :param company: object :param uid_corporate: string @@ -555,14 +568,15 @@ class Client(Base): if uid_type != 'externalId': self.parameters['by'] = uid_type - + if entity_by != 'externalId': self.parameters['entityBy'] = entity_by if site is not None: self.parameters['site'] = site - return self.post('/customers-corporate/' + str(uid_corporate) + '/companies/' + str(company[entity_by]) + '/edit') + return self.post('/customers-corporate/' + + str(uid_corporate) + '/companies/' + str(company[entity_by]) + '/edit') def customer_corporate_contacts(self, uid, uid_type='externalId', limit=20, page=1, filters=None, site=None): """ @@ -604,8 +618,12 @@ class Client(Base): return self.post('/customers-corporate/' + str(contact[uid_type]) + '/contacts/create') - - def customer_corporate_contacts_edit(self, uid_corporate, contact, uid_type='externalId', entity_by='externalId', site=None): + def customer_corporate_contacts_edit(self, + uid_corporate, + contact, + uid_type='externalId', + entity_by='externalId', + site=None): """ :param contact: object :param uid_corporate: string @@ -618,14 +636,15 @@ class Client(Base): if uid_type != 'externalId': self.parameters['by'] = uid_type - + if entity_by != 'externalId': self.parameters['entityBy'] = entity_by if site is not None: self.parameters['site'] = site - return self.post('/customers-corporate/' + str(uid_corporate) + '/contacts/' + str(contact[entity_by]) + '/edit') + return self.post('/customers-corporate/' + + str(uid_corporate) + '/contacts/' + str(contact[entity_by]) + '/edit') def customer_corporate_edit(self, customer_corporate, uid_type='externalId', site=None): """ @@ -713,7 +732,7 @@ class Client(Base): self.parameters['page'] = page return self.get('/files') - + def files_upload(self, file, site=None): """ :param file: objects @@ -1007,21 +1026,21 @@ class Client(Base): return self.post('/payment/check') - def payment_create_invoice(self, createInvoice): + def payment_create_invoice(self, create_invoice): """ - :param createInvoice: object + :param create_invoice: object :return: Response """ - self.parameters['createInvoice'] = json.dumps(createInvoice) + self.parameters['createInvoice'] = json.dumps(create_invoice) return self.post('/payment/create-invoice') - def payment_update_invoice(self, updateInvoice): + def payment_update_invoice(self, update_invoice): """ - :param updateInvoice: object + :param update_invoice: object :return: Response """ - self.parameters['updateInvoice'] = json.dumps(updateInvoice) + self.parameters['updateInvoice'] = json.dumps(update_invoice) return self.post('/payment/update-invoice') @@ -1355,9 +1374,8 @@ class Client(Base): """ if site is not None: self.parameters['site'] = site - - self.parameters['offers'] = json.dumps(offers) + self.parameters['offers'] = json.dumps(offers) return self.post('/store/inventories/upload') @@ -1474,16 +1492,16 @@ class Client(Base): return self.post('/telephony/calls/upload') - def telephony_manager(self, phone, details=True, ignoreStatus=True): + def telephony_manager(self, phone, details=True, ignore_status=True): """ :param phone: string :param details: string - :param ignoreStatus: string - :return: Response + :param ignore_status: string + :return: Response """ self.parameters['phone'] = phone self.parameters['details'] = details - self.parameters['ignoreStatus'] = ignoreStatus + self.parameters['ignoreStatus'] = ignore_status return self.get('/telephony/manager') diff --git a/setup.py b/setup.py index 43fc55f..1aeb58e 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ def read(filename): setup( name='retailcrm', - version='5.0.3', + version='5.1.0', description='retailCRM API client', long_description=read('README'), url='https://github.com/retailcrm/api-client-python', @@ -25,7 +25,7 @@ setup( license='MIT', packages=['retailcrm', 'retailcrm/versions'], package_data={}, - install_requires=['requests', 'multidimensional_urlencode', 'nose'], + install_requires=['requests', 'multidimensional_urlencode', 'nose', 'coverage', 'pook', 'setuptools'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Other Environment', @@ -38,6 +38,7 @@ setup( 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3 :: Only', 'Topic :: Software Development :: Libraries :: Python Modules', ] diff --git a/tests/v3_tests.py b/tests/v3_tests.py index d6bc6a1..70465a9 100644 --- a/tests/v3_tests.py +++ b/tests/v3_tests.py @@ -42,14 +42,14 @@ class TestVersion3(unittest.TestCase): 'phones': [], 'contragentType': 'individual' } - + __order = { 'slug': 5604, 'summ': 0, 'id': 5604, 'number': '5604A', 'externalId': '5603', - 'orderType': 'tttt', + 'orderType': 's789', 'orderMethod': 'shopping-cart', 'countryIso': 'RU', 'createdAt': '2020-04-07 15:44:24', @@ -101,10 +101,10 @@ class TestVersion3(unittest.TestCase): 'id': 5608 }, 'offer': { - 'externalId': 'xcxc55' + 'externalId': 's789' } } - } + } def setUp(self): """ @@ -112,10 +112,11 @@ class TestVersion3(unittest.TestCase): """ self.client = retailcrm.v3( - os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY')) + os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY')) - def dictionaryEncode(self, key, dictonary): - return urlencode({key: json.dumps(dictonary)}) + @staticmethod + def dictionaryEncode(key, dictionary): + return urlencode({key: json.dumps(dictionary)}) @pook.on def test_wrong_api_url(self): @@ -128,11 +129,11 @@ class TestVersion3(unittest.TestCase): .reply(404) .headers(self.__header) .json( - { + { 'success': 'true', 'errorMsg': 'Account does not exist.' } - ) + ) ) client = retailcrm.v3('https://epoqq.retailcrm.ru', os.getenv('RETAILCRM_KEY')) @@ -149,11 +150,11 @@ class TestVersion3(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/statistic/update') - .headers({'X-API-KEY': 'XXXX'}) - .reply(200) - .headers(self.__header) - .json({'errorMsg': 'Wrong "apiKey" value.'}) - ) + .headers({'X-API-KEY': 'XXXX'}) + .reply(200) + .headers(self.__header) + .json({'errorMsg': 'Wrong "apiKey" value.'}) + ) client = retailcrm.v3(os.getenv('RETAILCRM_URL'), 'XXXX') response = client.statistic_update() @@ -168,11 +169,11 @@ class TestVersion3(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/statistic/update') - .headers({'X-API-KEY': None}) - .reply(200) - .headers(self.__header) - .json({'errorMsg': '"apiKey" is missing.'}) - ) + .headers({'X-API-KEY': None}) + .reply(200) + .headers(self.__header) + .json({'errorMsg': '"apiKey" is missing.'}) + ) client = retailcrm.v3(os.getenv('RETAILCRM_URL'), None) response = client.statistic_update() @@ -187,11 +188,11 @@ class TestVersion3(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/api-versions') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'versions': ['3.0', '4.0', '5.0']}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'versions': ['3.0', '4.0', '5.0']}) + ) response = self.client.api_versions() pook.off() @@ -205,12 +206,12 @@ class TestVersion3(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/credentials') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'credentials': [], 'siteAccess': 'access_full'}) - ) - + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'credentials': [], 'siteAccess': 'access_full'}) + ) + response = self.client.api_credentials() pook.off() @@ -235,10 +236,10 @@ class TestVersion3(unittest.TestCase): 'totalCount': 4342, 'currentPage': 1, 'totalPageCount': 87 - }, + }, 'customers': [self.__customer] } - ) + ) ) response = self.client.customers({'bad': 'false', 'contragentType': 'individual'}) @@ -254,12 +255,12 @@ class TestVersion3(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/customers/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customer', self.__customer)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7777}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customer', self.__customer)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7777}) + ) response = self.client.customer_create(self.__customer) pook.off() @@ -274,12 +275,12 @@ class TestVersion3(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/customers/fix-external-ids') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customers', self.__customer['externalId'])) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customers', self.__customer['externalId'])) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customers_fix_external_ids(self.__customer['externalId']) pook.off() @@ -302,13 +303,13 @@ class TestVersion3(unittest.TestCase): { 'success': 'true', 'uploadedCustomers': [ - { + { 'id': 9717, 'externalId': 'c-983344770' } ] } - ) + ) ) response = self.client.customers_upload(self.__customer) @@ -326,11 +327,11 @@ class TestVersion3(unittest.TestCase): uid = str(self.__customer['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/customers/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'customers': self.__customer}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'customers': self.__customer}) + ) response = self.client.customer(uid) pook.off() @@ -347,19 +348,19 @@ class TestVersion3(unittest.TestCase): uid = str(self.__customer['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/customers/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customer', self.__customer)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 9717}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customer', self.__customer)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 9717}) + ) response = self.client.customer_edit(self.__customer) pook.off() self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_orders(self): """ @@ -382,7 +383,7 @@ class TestVersion3(unittest.TestCase): }, 'orders': [self.__order] } - ) + ) ) response = self.client.orders({'bad': 'false', 'contragentType': 'individual'}) @@ -398,12 +399,12 @@ class TestVersion3(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/orders/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('order', self.__order)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7777, 'order': self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('order', self.__order)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7777, 'order': self.__order}) + ) response = self.client.order_create(self.__order) pook.off() @@ -418,12 +419,12 @@ class TestVersion3(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/orders/fix-external-ids') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orders', self.__order['externalId'])) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orders', self.__order['externalId'])) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.orders_fix_external_ids(self.__order['externalId']) pook.off() @@ -434,11 +435,11 @@ class TestVersion3(unittest.TestCase): @pook.on def test_orders_history(self): """ - V3 Test method orders_history + V3 Test method orders_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/orders/history') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params({'startDate': '2020-01-07', 'endDate': '2020-04-12'}) .reply(200) .headers(self.__header) @@ -448,7 +449,7 @@ class TestVersion3(unittest.TestCase): 'generatedAt': '2020-04-12 15:44:24', 'orders': [self.__order] } - ) + ) ) response = self.client.orders_history('2020-01-07', '2020-04-12') @@ -480,7 +481,7 @@ class TestVersion3(unittest.TestCase): } ] } - ) + ) ) response = self.client.orders_statuses([5604], [5603]) @@ -504,14 +505,14 @@ class TestVersion3(unittest.TestCase): { 'success': 'true', 'uploadedOrders': [ - { + { 'id': 5604, 'externalId': '5603' } ], 'orders': [self.__order] } - ) + ) ) response = self.client.orders_upload(self.__order) @@ -529,11 +530,11 @@ class TestVersion3(unittest.TestCase): uid = str(self.__order['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/orders/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'orders' : self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'orders': self.__order}) + ) response = self.client.order(uid) pook.off() @@ -550,12 +551,12 @@ class TestVersion3(unittest.TestCase): uid = str(self.__order['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/orders/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('order', self.__order)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5604, 'order': self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('order', self.__order)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5604, 'order': self.__order}) + ) response = self.client.order_edit(self.__order) pook.off() @@ -578,14 +579,14 @@ class TestVersion3(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 1, - 'currentPage': 1, - 'totalPageCount': 1 - }, - 'packs' : [self.__pack] + 'limit': 20, + 'totalCount': 1, + 'currentPage': 1, + 'totalPageCount': 1 + }, + 'packs': [self.__pack] } - ) + ) ) response = self.client.packs({'store': '7777z'}) @@ -601,12 +602,12 @@ class TestVersion3(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/orders/packs/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('pack', {'store': '7777z', 'quantity': 1, 'itemId': 7632})) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7777}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('pack', {'store': '7777z', 'quantity': 1, 'itemId': 7632})) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7777}) + ) response = self.client.pack_create({'store': '7777z', 'quantity': 1, 'itemId': 7632}) pook.off() @@ -617,7 +618,7 @@ class TestVersion3(unittest.TestCase): @pook.on def test_packs_history(self): """ - V3 Test method packs_history + V3 Test method packs_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/orders/packs/history') @@ -639,23 +640,23 @@ class TestVersion3(unittest.TestCase): 'code': 'zzz' }, 'pack': { - 'id': 678, - 'quantity': 1, - 'store': {'code': 'zzz'}, - 'item': { - 'id': 222, - 'order': {'id': 6677}, - 'offer': {'externalId': '333'} - } + 'id': 678, + 'quantity': 1, + 'store': {'code': 'zzz'}, + 'item': { + 'id': 222, + 'order': {'id': 6677}, + 'offer': {'externalId': '333'} + } }, 'source': 'api' } ] - } - ) + } + ) ) - response = self.client.packs_history({'startDate' : '2016-01-07', 'endDate' : '2020-04-12'}) + response = self.client.packs_history({'startDate': '2016-01-07', 'endDate': '2020-04-12'}) pook.off() self.assertTrue(response.is_successful(), True) @@ -670,11 +671,11 @@ class TestVersion3(unittest.TestCase): uid = str(self.__pack['id']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/orders/packs/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'pack': self.__pack}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'pack': self.__pack}) + ) response = self.client.pack(uid) pook.off() @@ -691,11 +692,11 @@ class TestVersion3(unittest.TestCase): uid = str(self.__pack['id']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/orders/packs/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.pack_delete(uid) pook.off() @@ -712,12 +713,12 @@ class TestVersion3(unittest.TestCase): uid = str(self.__pack['id']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/orders/packs/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('pack', self.__pack)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5604}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('pack', self.__pack)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5604}) + ) response = self.client.pack_edit(self.__pack) pook.off() @@ -728,15 +729,15 @@ class TestVersion3(unittest.TestCase): @pook.on def test_countries(self): """ - V3 Test method countries + V3 Test method countries """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/reference/countries') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'countriesIso': ['RU', 'UA', 'BY', 'KZ']}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'countriesIso': ['RU', 'UA', 'BY', 'KZ']}) + ) response = self.client.countries() pook.off() @@ -747,7 +748,7 @@ class TestVersion3(unittest.TestCase): @pook.on def test_delivery_services(self): """ - V3 Test method delivery_services + V3 Test method delivery_services """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/reference/delivery-services') @@ -763,7 +764,7 @@ class TestVersion3(unittest.TestCase): 'code': '0tq6d' }, 'a080k': { - 'name': 'wmenw', + 'name': 's789', 'code': 'a080k' }, 'a6zgf': { @@ -772,7 +773,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.delivery_services() @@ -787,15 +788,15 @@ class TestVersion3(unittest.TestCase): V3 Test method delivery_services_edit """ - service = {'code': 'a080k', 'name': 'wmenw'} + service = {'code': 'a080k', 'name': 's789'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/delivery-services/' + service['code'] + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryService', service)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryService', service)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_services_edit(service) pook.off() @@ -806,11 +807,11 @@ class TestVersion3(unittest.TestCase): @pook.on def test_delivery_types(self): """ - V3 Test method delivery_types + V3 Test method delivery_types """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/reference/delivery-types') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(201) .headers(self.__header) .json( @@ -818,7 +819,7 @@ class TestVersion3(unittest.TestCase): 'success': 'true', 'deliveryTypes': { '1kp52': { - 'name': '1cxub', + 'name': 's789', 'code': '1kp52', 'defaultCost': 300, 'defaultNetCost': 0, @@ -829,9 +830,9 @@ class TestVersion3(unittest.TestCase): 'deliveryServices': [], 'defaultForCrm': 'false' }, - 'xhxij': { + 's789': { 'name': '1s0ei', - 'code': 'xhxij', + 'code': 's789', 'defaultCost': 300, 'defaultNetCost': 0, 'paymentTypes': [ @@ -843,7 +844,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.delivery_types() @@ -858,15 +859,15 @@ class TestVersion3(unittest.TestCase): V3 Test method delivery_types_edit """ - delivery_type = {'code': 'xhxij', 'name': '1s0ei'} + delivery_type = {'code': 's789', 'name': '1s0ei'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/delivery-types/' + delivery_type['code'] + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryType', delivery_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryType', delivery_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_types_edit(delivery_type) pook.off() @@ -877,7 +878,7 @@ class TestVersion3(unittest.TestCase): @pook.on def test_order_methods(self): """ - V3 Test method order_methods + V3 Test method order_methods """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/reference/order-methods') @@ -896,22 +897,22 @@ class TestVersion3(unittest.TestCase): 'isFromPos': 'false' }, '44cmd': { - 'name': '1tdf4', - 'code': '44cmd', - 'defaultForCrm': 'false', - 'defaultForApi': 'false', - 'isFromPos': 'false' + 'name': '1tdf4', + 'code': '44cmd', + 'defaultForCrm': 'false', + 'defaultForApi': 'false', + 'isFromPos': 'false' }, 'zoc5q': { - 'name': '1y0cp', - 'code': 'zoc5q', - 'defaultForCrm': 'false', - 'defaultForApi': 'false', - 'isFromPos': 'false' + 'name': '1y0cp', + 'code': 'zoc5q', + 'defaultForCrm': 'false', + 'defaultForApi': 'false', + 'isFromPos': 'false' } } } - ) + ) ) response = self.client.order_methods() @@ -929,12 +930,12 @@ class TestVersion3(unittest.TestCase): method = {'code': 'zoc5q', 'name': '1y0cp'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/order-methods/' + method['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orderMethod', method)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orderMethod', method)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_methods_edit(method) pook.off() @@ -956,9 +957,9 @@ class TestVersion3(unittest.TestCase): { 'success': 'true', 'orderTypes': { - 'tttt': { + 's789': { 'name': 'test', - 'code': 'tttt', + 'code': 's789', 'defaultForCrm': 'true', 'defaultForApi': 'true', 'ordering': 990 @@ -972,7 +973,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.order_types() @@ -987,15 +988,15 @@ class TestVersion3(unittest.TestCase): V3 Test method order_types_edit """ - order_type = {'code': 'tttt', 'name': 'test'} + order_type = {'code': 's789', 'name': 'test'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/order-types/' + order_type['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orderType', order_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orderType', order_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_types_edit(order_type) pook.off() @@ -1006,11 +1007,11 @@ class TestVersion3(unittest.TestCase): @pook.on def test_payment_statuses(self): """ - V3 Test method payment_statuses + V3 Test method payment_statuses """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/reference/payment-statuses') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(200) .headers(self.__header) .json( @@ -1049,7 +1050,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.payment_statuses() @@ -1067,12 +1068,12 @@ class TestVersion3(unittest.TestCase): status = {'code': 'payment-start', 'name': 'Платеж проведен'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/payment-statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('paymentStatus', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('paymentStatus', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.payment_statuses_edit(status) pook.off() @@ -1083,7 +1084,7 @@ class TestVersion3(unittest.TestCase): @pook.on def test_payment_types(self): """ - V3 Test method payment_types + V3 Test method payment_types """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/reference/payment-types') @@ -1112,7 +1113,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.payment_types() @@ -1130,12 +1131,12 @@ class TestVersion3(unittest.TestCase): payment_type = {'code': '238c06', 'name': 'TestPaymentType-238c06'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/payment-types/' + payment_type['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('paymentType', payment_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('paymentType', payment_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.payment_types_edit(payment_type) pook.off() @@ -1146,7 +1147,7 @@ class TestVersion3(unittest.TestCase): @pook.on def test_product_statuses(self): """ - V3 Test method product_statuses + V3 Test method product_statuses """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/reference/product-statuses') @@ -1173,7 +1174,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.product_statuses() @@ -1191,12 +1192,12 @@ class TestVersion3(unittest.TestCase): status = {'code': 'in-reserve', 'name': 'В резерве'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/product-statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('productStatus', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('productStatus', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.product_statuses_edit(status) pook.off() @@ -1231,7 +1232,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.sites() @@ -1249,12 +1250,12 @@ class TestVersion3(unittest.TestCase): site = {'code': 'code', 'name': 'XXX'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/sites/' + site['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('site', site)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('site', site)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.sites_edit(site) pook.off() @@ -1300,7 +1301,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.status_groups() @@ -1337,7 +1338,7 @@ class TestVersion3(unittest.TestCase): } } } - ) + ) ) response = self.client.statuses() @@ -1355,12 +1356,12 @@ class TestVersion3(unittest.TestCase): status = {'code': 'new', 'name': 'Новый'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('status', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('status', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.statuses_edit(status) pook.off() @@ -1392,11 +1393,11 @@ class TestVersion3(unittest.TestCase): 'type': 'store-type-warehouse', 'inventoryType': 'integer', 'code': 'q6w5i', - 'name': 'uutgj' + 'name': 's789' } ] } - ) + ) ) response = self.client.stores() @@ -1411,15 +1412,15 @@ class TestVersion3(unittest.TestCase): V3 Test method stores_edit """ - store = {'code': 'q6w5i', 'name': 'uutgj'} + store = {'code': 'q6w5i', 'name': 's789'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/reference/stores/' + store['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('store', store)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('store', store)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.stores_edit(store) pook.off() @@ -1435,13 +1436,13 @@ class TestVersion3(unittest.TestCase): (pook.get(os.getenv('RETAILCRM_URL') + '/api/v3/store/inventories') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .params({'filter[site]' : 'https://help.ru'}) + .params({'filter[site]': 'https://help.ru'}) .reply(200) .headers(self.__header) .json( { 'success': 'true', - 'pagination': + 'pagination': { 'limit': 20, 'totalCount': 34, @@ -1460,10 +1461,9 @@ class TestVersion3(unittest.TestCase): { 'externalId': '33', 'quantity': 0 - } - ] + }] } - ) + ) ) response = self.client.inventories({'site': 'https://help.ru'}) @@ -1471,7 +1471,7 @@ class TestVersion3(unittest.TestCase): self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_inventories_upload(self): """ @@ -1480,7 +1480,7 @@ class TestVersion3(unittest.TestCase): (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/store/inventories/upload') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('offers', {'externalId': 'wenw', 'id': 5603})) + .body(self.dictionaryEncode('offers', {'externalId': 's789', 'id': 5603})) .reply(200) .headers(self.__header) .json( @@ -1488,14 +1488,14 @@ class TestVersion3(unittest.TestCase): 'success': 'true', 'processedOffersCount': 0, 'notFoundOffers': { - 'externalId': 'wenw', + 'externalId': 's789', 'xmlId': 9999 } } - ) + ) ) - response = self.client.inventories_upload({'externalId': 'wenw', 'id': 5603}) + response = self.client.inventories_upload({'externalId': 's789', 'id': 5603}) pook.off() self.assertTrue(response.is_successful(), True) @@ -1508,21 +1508,20 @@ class TestVersion3(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/call/event') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(urlencode( + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(urlencode( { - 'hangupStatus': 'busy', + 'hangupStatus': 'busy', 'phone': '+799999999', 'code': 'c2321', 'type': 'hangup' - }) - ) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + })) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) - response = self.client.telephony_call_event('+799999999', 'hangup', 'c2321', 'busy') + response = self.client.telephony_call_event('+799999999', 'hangup', 'c2321', 'busy') pook.off() self.assertTrue(response.is_successful(), True) @@ -1536,7 +1535,7 @@ class TestVersion3(unittest.TestCase): (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/calls/upload') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('calls', {})) + .body(self.dictionaryEncode('calls', {})) .reply(200) .headers(self.__header) .json( @@ -1545,10 +1544,10 @@ class TestVersion3(unittest.TestCase): 'processedCallsCount': 5555, 'duplicateCalls': [] } - ) + ) ) - response = self.client.telephony_calls_upload({}) + response = self.client.telephony_calls_upload({}) pook.off() self.assertTrue(response.is_successful(), True) @@ -1569,19 +1568,19 @@ class TestVersion3(unittest.TestCase): { 'success': 'true', 'manager': { - 'id': 777, + 'id': 777, 'firstName': 'yyy', 'lastName': 'xxxx', - 'patronymic': 'qwer', + 'patronymic': 's789', 'email': 'mail@retailcrm.ru', 'code': 'ccc7' }, 'customer': { 'id': 888, - 'externalId': '5406', + 'externalId': '5406', 'firstName': 'ccc', - 'lastName': 'zzzz', - 'patronymic': 'asdf', + 'lastName': 's789', + 'patronymic': 's789', 'email': 'mail@retailcrm.ru', 'code': 'ccc7', 'phones': [{'number': '+71111111111'}] @@ -1591,16 +1590,16 @@ class TestVersion3(unittest.TestCase): 'lastOrderLink': 'https://lastOrderLink.ru', 'newCustomerLink': 'https://newCustomerLink.ru', 'customerLink': 'https://customerLink.ru', - } + } } - ) + ) ) response = self.client.telephony_manager('+79999999999') pook.off() self.assertTrue(response.is_successful(), True) - self.assertTrue(response.get_status_code() < 400, True) + self.assertTrue(response.get_status_code() < 400, True) @pook.on def test_telephony_settings(self): @@ -1611,24 +1610,22 @@ class TestVersion3(unittest.TestCase): code = 'xxx' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/settings/' + code) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(urlencode( + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(urlencode( { - 'code': code, + 'code': code, 'clientId': '123x', 'makeCallUrl': 'url', 'active': 'active', 'name': 'name', 'image': 'url_image' - } - ) - ) - .reply(201) - .headers(self.__header) - .json({'success': 'true'}) - ) + })) + .reply(201) + .headers(self.__header) + .json({'success': 'true'}) + ) - response = self.client.telephony_settings(code, '123x', 'url', 'active', 'name', 'url_image') + response = self.client.telephony_settings(code, '123x', 'url', 'active', 'name', 'url_image') pook.off() self.assertTrue(response.is_successful(), True) @@ -1639,13 +1636,13 @@ class TestVersion3(unittest.TestCase): """ V3 Test method statistic_update """ - + (pook.get(os.getenv('RETAILCRM_URL') + '/statistic/update') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.statistic_update() pook.off() diff --git a/tests/v4_tests.py b/tests/v4_tests.py index 76c0992..96069ce 100644 --- a/tests/v4_tests.py +++ b/tests/v4_tests.py @@ -18,10 +18,10 @@ class TestVersion4(unittest.TestCase): TestClass for v4 """ __header = {'Server': 'nginx/1.16.0', 'Content-Type': 'application/json; charset=UTF-8'} - + __customer = { 'id': 9717, - 'externalId': 'c-111111111', + 'externalId': 'c-34234', 'createdAt': '2020-04-09 16:55:59', 'vip': 'false', 'bad': 'false', @@ -41,14 +41,14 @@ class TestVersion4(unittest.TestCase): 'phones': [], 'contragentType': 'individual' } - + __order = { - 'slug': 5604, + 'slug': 3425, 'summ': 0, - 'id': 5604, + 'id': 3425, 'number': '5604A', 'externalId': '5603', - 'orderType': 'tttt', + 'orderType': 'individual', 'orderMethod': 'shopping-cart', 'countryIso': 'RU', 'createdAt': '2020-04-07 15:44:24', @@ -65,9 +65,6 @@ class TestVersion4(unittest.TestCase): 'vip': 'false', 'bad': 'false', 'site': '127-0-0-1-8080', - 'marginSumm': 0, - 'totalSumm': 0, - 'averageSumm': 0, 'ordersCount': 1, 'customFields': [], 'personalDiscount': 0, @@ -100,10 +97,10 @@ class TestVersion4(unittest.TestCase): 'id': 5608 }, 'offer': { - 'externalId': 'xcxc55' + 'externalId': 'x2342' } } - } + } def setUp(self): """ @@ -111,10 +108,11 @@ class TestVersion4(unittest.TestCase): """ self.client = retailcrm.v4( - os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY')) + os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY')) - def dictionaryEncode(self, key, dictonary): - return urlencode({key: json.dumps(dictonary)}) + @staticmethod + def dictionaryEncode(key, dictionary): + return urlencode({key: json.dumps(dictionary)}) @pook.on def test_wrong_api_url(self): @@ -127,11 +125,11 @@ class TestVersion4(unittest.TestCase): .reply(404) .headers(self.__header) .json( - { + { 'success': 'true', 'errorMsg': 'Account does not exist.' } - ) + ) ) client = retailcrm.v4('https://epoqq.retailcrm.ru', os.getenv('RETAILCRM_KEY')) @@ -148,11 +146,11 @@ class TestVersion4(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/statistic/update') - .headers({'X-API-KEY': 'XXXX'}) - .reply(200) - .headers(self.__header) - .json({'errorMsg': 'Wrong "apiKey" value.'}) - ) + .headers({'X-API-KEY': 'XXXX'}) + .reply(200) + .headers(self.__header) + .json({'errorMsg': 'Wrong "apiKey" value.'}) + ) client = retailcrm.v4(os.getenv('RETAILCRM_URL'), 'XXXX') response = client.statistic_update() @@ -167,11 +165,11 @@ class TestVersion4(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/statistic/update') - .headers({'X-API-KEY': None}) - .reply(200) - .headers(self.__header) - .json({'errorMsg': '"apiKey" is missing.'}) - ) + .headers({'X-API-KEY': None}) + .reply(200) + .headers(self.__header) + .json({'errorMsg': '"apiKey" is missing.'}) + ) client = retailcrm.v4(os.getenv('RETAILCRM_URL'), None) response = client.statistic_update() @@ -179,42 +177,6 @@ class TestVersion4(unittest.TestCase): self.assertEqual(response.get_error_msg(), '"apiKey" is missing.') - @pook.on - def test_api_versions(self): - """ - V4 Test api-versions method - """ - - (pook.get(os.getenv('RETAILCRM_URL') + '/api/api-versions') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'versions': ['3.0', '4.0', '5.0']}) - ) - - response = self.client.api_versions() - pook.off() - - self.assertTrue(response.is_successful(), True) - - @pook.on - def test_api_credentials(self): - """ - V4 Test api-credentials method - """ - - (pook.get(os.getenv('RETAILCRM_URL') + '/api/credentials') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'credentials': [], 'siteAccess': 'access_full'}) - ) - - response = self.client.api_credentials() - pook.off() - - self.assertTrue(response.is_successful(), True) - @pook.on def test_customers(self): """ @@ -230,14 +192,14 @@ class TestVersion4(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 4347, - 'currentPage': 1, - 'totalPageCount': 87 - }, + 'limit': 20, + 'totalCount': 4347, + 'currentPage': 1, + 'totalPageCount': 87 + }, 'customers': [self.__customer] } - ) + ) ) response = self.client.customers({'online': 'No', 'contragentType': 'individual'}) @@ -253,12 +215,12 @@ class TestVersion4(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/customers/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customer', self.__customer)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7117}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customer', self.__customer)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7117}) + ) response = self.client.customer_create(self.__customer) pook.off() @@ -273,12 +235,12 @@ class TestVersion4(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/customers/fix-external-ids') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customers', self.__customer['externalId'])) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customers', self.__customer['externalId'])) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customers_fix_external_ids(self.__customer['externalId']) pook.off() @@ -289,18 +251,18 @@ class TestVersion4(unittest.TestCase): @pook.on def test_customers_history(self): """ - V4 Test method customers_history + V4 Test method customers_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/customers/history') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params( { 'filter[sinceId]': '1111', 'filter[startDate]': '2016-01-07', - 'filter[endDate]': '2020-04-12' + 'filter[endDate]': '2020-04-12' } - ) + ) .reply(200) .headers(self.__header) .json( @@ -321,7 +283,7 @@ class TestVersion4(unittest.TestCase): 'newValue': 4949, 'customer': { 'id': 4949, - 'externalId': 'xxxxxxx1', + 'externalId': 'x2342', 'createdAt': '2018-04-11 09:01:26', 'vip': 'false', 'bad': 'false', @@ -344,15 +306,15 @@ class TestVersion4(unittest.TestCase): } ] } - ) + ) ) response = self.client.customers_history( - { - 'sinceId': '1111', - 'startDate': '2016-01-07', - 'endDate': '2020-04-12' - } + { + 'sinceId': '1111', + 'startDate': '2016-01-07', + 'endDate': '2020-04-12' + } ) pook.off() @@ -374,13 +336,13 @@ class TestVersion4(unittest.TestCase): { 'success': 'true', 'uploadedCustomers': [ - { + { 'id': 9717, 'externalId': 'c-983344770' } ] } - ) + ) ) response = self.client.customers_upload(self.__customer) @@ -398,11 +360,11 @@ class TestVersion4(unittest.TestCase): uid = str(self.__customer['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/customers/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'customers': self.__customer}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'customers': self.__customer}) + ) response = self.client.customer(uid) pook.off() @@ -419,12 +381,12 @@ class TestVersion4(unittest.TestCase): uid = str(self.__customer['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/customers/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customer', self.__customer)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 9717}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customer', self.__customer)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 9717}) + ) response = self.client.customer_edit(self.__customer) pook.off() @@ -462,7 +424,7 @@ class TestVersion4(unittest.TestCase): 'requiredFields': [], 'statusList': [ { - 'code': 'rrrr', + 'code': 's789', 'name': 'sss', 'isEditable': 'true' }, @@ -477,7 +439,7 @@ class TestVersion4(unittest.TestCase): 'availableShipmentCountries': [] } } - ) + ) ) response = self.client.delivery_setting(code) @@ -493,10 +455,10 @@ class TestVersion4(unittest.TestCase): """ configuration = { - 'payerType': ['sender'], + 'payerType': ['sender'], 'statusList': [ { - 'code': 'rrrr', + 'code': 's789', 'name': 'sss', 'isEditable': 'true' } @@ -506,12 +468,12 @@ class TestVersion4(unittest.TestCase): } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/delivery/generic/setting/' + configuration['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('configuration', configuration)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'code': 'generic.zzz'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('configuration', configuration)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'code': 'generic.zzz'}) + ) response = self.client.delivery_setting_edit(configuration) pook.off() @@ -538,19 +500,19 @@ class TestVersion4(unittest.TestCase): } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/delivery/generic/' + code + '/tracking') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('statusUpdate', tracking)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('statusUpdate', tracking)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_tracking(code, tracking) pook.off() self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_marketplace_setting_edit(self): """ @@ -561,16 +523,16 @@ class TestVersion4(unittest.TestCase): configuration = {'name': 'Test123', 'code': code, 'configurationUrl': 'https://may.cat.ru'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/marketplace/external/setting/' + code + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('configuration', configuration)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) - - response = self.client.marketplace_setting_edit(configuration) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('configuration', configuration)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) + + self.client.marketplace_setting_edit(configuration) pook.off() - + @pook.on def test_orders(self): """ @@ -586,14 +548,14 @@ class TestVersion4(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 2464, - 'currentPage': 1, - 'totalPageCount': 50 - }, + 'limit': 20, + 'totalCount': 2464, + 'currentPage': 1, + 'totalPageCount': 50 + }, 'orders': [self.__order] } - ) + ) ) response = self.client.orders({'city': 'Moscow', 'contragentType': 'individual'}) @@ -609,12 +571,12 @@ class TestVersion4(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/orders/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('order', self.__order)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 8888, 'order': self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('order', self.__order)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 8888, 'order': self.__order}) + ) response = self.client.order_create(self.__order) pook.off() @@ -629,12 +591,12 @@ class TestVersion4(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/orders/fix-external-ids') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orders', (self.__order['externalId']))) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orders', (self.__order['externalId']))) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.orders_fix_external_ids(self.__order['externalId']) pook.off() @@ -645,18 +607,18 @@ class TestVersion4(unittest.TestCase): @pook.on def test_orders_history(self): """ - V4 Test method orders_history + V4 Test method orders_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/orders/history') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params( { 'filter[sinceId]': '1111', 'filter[startDate]': '2016-01-07', - 'filter[endDate]': '2020-04-12' + 'filter[endDate]': '2020-04-12' } - ) + ) .reply(200) .headers(self.__header) .json( @@ -682,7 +644,7 @@ class TestVersion4(unittest.TestCase): 'summ': 0, 'id': 9090, 'number': '9090A', - 'externalId': 'xxxxxxxs', + 'externalId': 'x353', 'orderType': 'eshop-individual', 'orderMethod': 'shopping-cart', 'createdAt': '2018-04-11 09:01:29', @@ -744,15 +706,15 @@ class TestVersion4(unittest.TestCase): } ] } - ) + ) ) response = self.client.orders_history( - { - 'sinceId': '1111', - 'startDate': '2016-01-07', - 'endDate': '2020-04-12' - } + { + 'sinceId': '1111', + 'startDate': '2016-01-07', + 'endDate': '2020-04-12' + } ) pook.off() @@ -782,7 +744,7 @@ class TestVersion4(unittest.TestCase): } ] } - ) + ) ) response = self.client.orders_statuses([5604], [5603]) @@ -806,14 +768,14 @@ class TestVersion4(unittest.TestCase): { 'success': 'true', 'uploadedOrders': [ - { + { 'id': 5604, 'externalId': '5603' } ], 'orders': [self.__order] } - ) + ) ) response = self.client.orders_upload(self.__order) @@ -831,11 +793,11 @@ class TestVersion4(unittest.TestCase): uid = str(self.__order['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/orders/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'orders' : self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'orders': self.__order}) + ) response = self.client.order(uid) pook.off() @@ -852,12 +814,12 @@ class TestVersion4(unittest.TestCase): uid = str(self.__order['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/orders/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('order', self.__order)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5604, 'order': self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('order', self.__order)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5604, 'order': self.__order}) + ) response = self.client.order_edit(self.__order) pook.off() @@ -880,14 +842,14 @@ class TestVersion4(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 1, - 'currentPage': 1, - 'totalPageCount': 1 - }, - 'packs' : [self.__pack] + 'limit': 20, + 'totalCount': 1, + 'currentPage': 1, + 'totalPageCount': 1 + }, + 'packs': [self.__pack] } - ) + ) ) response = self.client.packs({'store': '7777z'}) @@ -903,12 +865,12 @@ class TestVersion4(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/orders/packs/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('pack', self.__pack)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7777}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('pack', self.__pack)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7777}) + ) response = self.client.pack_create(self.__pack) pook.off() @@ -919,7 +881,7 @@ class TestVersion4(unittest.TestCase): @pook.on def test_packs_history(self): """ - V4 Test method packs_history + V4 Test method packs_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/orders/packs/history') @@ -938,26 +900,26 @@ class TestVersion4(unittest.TestCase): 'created': 'true', 'field': 'store', 'newValue': { - 'code': 'zzz' + 'code': 'eee' }, 'pack': { - 'id': 678, - 'quantity': 1, - 'store': {'code': 'zzz'}, - 'item': { - 'id': 222, - 'order': {'id': 6677}, - 'offer': {'externalId': '333'} - } + 'id': 678, + 'quantity': 1, + 'store': {'code': 'eee'}, + 'item': { + 'id': 222, + 'order': {'id': 6677}, + 'offer': {'externalId': '333'} + } }, 'source': 'api' } ] - } - ) + } + ) ) - response = self.client.packs_history({'startDate' : '2016-01-07', 'endDate' : '2020-04-12'}) + response = self.client.packs_history({'startDate': '2016-01-07', 'endDate': '2020-04-12'}) pook.off() self.assertTrue(response.is_successful(), True) @@ -972,11 +934,11 @@ class TestVersion4(unittest.TestCase): uid = str(self.__pack['id']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/orders/packs/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'pack': self.__pack}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'pack': self.__pack}) + ) response = self.client.pack(uid) pook.off() @@ -993,11 +955,11 @@ class TestVersion4(unittest.TestCase): uid = '7777' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/orders/packs/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.pack_delete(uid) pook.off() @@ -1014,12 +976,12 @@ class TestVersion4(unittest.TestCase): uid = str(self.__pack['id']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/orders/packs/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('pack', self.__pack)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5604}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('pack', self.__pack)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5604}) + ) response = self.client.pack_edit(self.__pack) pook.off() @@ -1030,15 +992,15 @@ class TestVersion4(unittest.TestCase): @pook.on def test_countries(self): """ - V4 Test method countries + V4 Test method countries """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/reference/countries') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'countriesIso': ['RU', 'UA', 'BY', 'KZ']}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'countriesIso': ['RU', 'UA', 'BY', 'KZ']}) + ) response = self.client.countries() pook.off() @@ -1049,7 +1011,7 @@ class TestVersion4(unittest.TestCase): @pook.on def test_delivery_services(self): """ - V4 Test method delivery_services + V4 Test method delivery_services """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/reference/delivery-services') @@ -1066,13 +1028,13 @@ class TestVersion4(unittest.TestCase): 'active': 'true' }, 'hmo8s': { - 'name': 'kgkk3', + 'name': 'j456', 'code': 'hmo8s', 'active': 'true' } } } - ) + ) ) response = self.client.delivery_services() @@ -1087,15 +1049,15 @@ class TestVersion4(unittest.TestCase): V4 Test method delivery_services_edit """ - service = {'code': 'hmo8s', 'name': 'kgkk3'} + service = {'code': 'hmo8s', 'name': 'g4562'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/delivery-services/' + service['code'] + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryService', service)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryService', service)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_services_edit(service) pook.off() @@ -1106,11 +1068,11 @@ class TestVersion4(unittest.TestCase): @pook.on def test_delivery_types(self): """ - V4 Test method delivery_types + V4 Test method delivery_types """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/reference/delivery-types') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(201) .headers(self.__header) .json( @@ -1118,7 +1080,7 @@ class TestVersion4(unittest.TestCase): 'success': 'true', 'deliveryTypes': { '1kp52': { - 'name': '1cxub', + 'name': 'xas', 'code': '1kp52', 'defaultCost': 300, 'defaultNetCost': 0, @@ -1129,9 +1091,9 @@ class TestVersion4(unittest.TestCase): 'deliveryServices': [], 'defaultForCrm': 'false' }, - 'xhxij': { + 'wer': { 'name': '1s0ei', - 'code': 'xhxij', + 'code': 'd452', 'defaultCost': 300, 'defaultNetCost': 0, 'paymentTypes': [ @@ -1143,7 +1105,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.delivery_types() @@ -1158,15 +1120,15 @@ class TestVersion4(unittest.TestCase): V4 Test method delivery_types_edit """ - delivery_type = {'code': 'xhxij', 'name': '1s0ei'} + delivery_type = {'code': 'x345', 'name': '1s0ei'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/delivery-types/' + delivery_type['code'] + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryType', delivery_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryType', delivery_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_types_edit(delivery_type) pook.off() @@ -1177,7 +1139,7 @@ class TestVersion4(unittest.TestCase): @pook.on def test_order_methods(self): """ - V4 Test method order_methods + V4 Test method order_methods """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/reference/order-methods') @@ -1189,22 +1151,22 @@ class TestVersion4(unittest.TestCase): 'success': 'true', 'orderMethods': { '44cmd': { - 'name': '1tdf4', - 'code': '44cmd', - 'defaultForCrm': 'false', - 'defaultForApi': 'false', - 'isFromPos': 'false' + 'name': '1tdf4', + 'code': '44cmd', + 'defaultForCrm': 'false', + 'defaultForApi': 'false', + 'isFromPos': 'false' }, 'zoc5q': { - 'name': '1y0cp', - 'code': 'zoc5q', - 'defaultForCrm': 'false', - 'defaultForApi': 'false', - 'isFromPos': 'false' + 'name': '1y0cp', + 'code': 'zoc5q', + 'defaultForCrm': 'false', + 'defaultForApi': 'false', + 'isFromPos': 'false' } } } - ) + ) ) response = self.client.order_methods() @@ -1222,12 +1184,12 @@ class TestVersion4(unittest.TestCase): method = {'code': 'zoc5q', 'name': '1y0cp'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/order-methods/' + method['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orderMethod', method)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orderMethod', method)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_methods_edit(method) pook.off() @@ -1249,9 +1211,9 @@ class TestVersion4(unittest.TestCase): { 'success': 'true', 'orderTypes': { - 'tttt': { + 's234': { 'name': 'test', - 'code': 'tttt', + 'code': 's234', 'defaultForCrm': 'true', 'defaultForApi': 'true', 'ordering': 990 @@ -1265,7 +1227,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.order_types() @@ -1280,15 +1242,15 @@ class TestVersion4(unittest.TestCase): V4 Test method order_types_edit """ - order_type = {'code': 'tttt', 'name': 'test'} + order_type = {'code': 's234', 'name': 'test'} - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/order-types/' + order_type['code']+ '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orderType', order_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/order-types/' + order_type['code'] + '/edit') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orderType', order_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_types_edit(order_type) pook.off() @@ -1299,11 +1261,11 @@ class TestVersion4(unittest.TestCase): @pook.on def test_payment_statuses(self): """ - V4 Test method payment_statuses + V4 Test method payment_statuses """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/reference/payment-statuses') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(200) .headers(self.__header) .json( @@ -1316,7 +1278,7 @@ class TestVersion4(unittest.TestCase): 'defaultForCrm': 'false', 'defaultForApi': 'false', 'paymentComplete': 'false', - 'ordering': 20, + 'ordering': 14, 'paymentTypes': [ 'bank-card', 'bank-transfer', @@ -1342,7 +1304,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.payment_statuses() @@ -1360,12 +1322,12 @@ class TestVersion4(unittest.TestCase): status = {'code': 'payment-start', 'name': 'Платеж проведен'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/payment-statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('paymentStatus', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('paymentStatus', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.payment_statuses_edit(status) pook.off() @@ -1376,7 +1338,7 @@ class TestVersion4(unittest.TestCase): @pook.on def test_payment_types(self): """ - V4 Test method payment_types + V4 Test method payment_types """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/reference/payment-types') @@ -1389,7 +1351,7 @@ class TestVersion4(unittest.TestCase): 'paymentTypes': { '056a3e': { 'name': 'TestPaymentType-056a3e', - 'code': '056a3e', + 'code': '2345', 'defaultForCrm': 'false', 'defaultForApi': 'false', 'deliveryTypes': [], @@ -1405,7 +1367,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.payment_types() @@ -1423,12 +1385,12 @@ class TestVersion4(unittest.TestCase): payment_type = {'code': '238c06', 'name': 'TestPaymentType-238c06'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/payment-types/' + payment_type['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('paymentType', payment_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('paymentType', payment_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.payment_types_edit(payment_type) pook.off() @@ -1439,7 +1401,7 @@ class TestVersion4(unittest.TestCase): @pook.on def test_product_statuses(self): """ - V4 Test method product_statuses + V4 Test method product_statuses """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/reference/product-statuses') @@ -1466,7 +1428,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.product_statuses() @@ -1484,12 +1446,12 @@ class TestVersion4(unittest.TestCase): status = {'code': 'in-reserve', 'name': 'В резерве'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/product-statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('productStatus', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('productStatus', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.product_statuses_edit(status) pook.off() @@ -1524,7 +1486,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.sites() @@ -1542,12 +1504,12 @@ class TestVersion4(unittest.TestCase): site = {'code': 'code', 'name': 'XXX'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/sites/' + site['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('site', site)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('site', site)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.sites_edit(site) pook.off() @@ -1572,7 +1534,7 @@ class TestVersion4(unittest.TestCase): 'new': { 'name': 'Новый', 'code': 'new', - 'ordering': 10, + 'ordering': 23, 'process': 'false', 'statuses': [ 'new', @@ -1593,7 +1555,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.status_groups() @@ -1630,7 +1592,7 @@ class TestVersion4(unittest.TestCase): } } } - ) + ) ) response = self.client.statuses() @@ -1648,12 +1610,12 @@ class TestVersion4(unittest.TestCase): status = {'code': 'new', 'name': 'Новый'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('status', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('status', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.statuses_edit(status) pook.off() @@ -1685,11 +1647,11 @@ class TestVersion4(unittest.TestCase): 'type': 'store-type-warehouse', 'inventoryType': 'integer', 'code': 'q6w5i', - 'name': 'uutgj' + 'name': 'u532' } ] } - ) + ) ) response = self.client.stores() @@ -1704,15 +1666,15 @@ class TestVersion4(unittest.TestCase): V4 Test method stores_edit """ - store = {'code': 'q6w5i', 'name': 'uutgj'} + store = {'code': 'q6w5i', 'name': 'u245'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/reference/stores/' + store['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('store', store)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('store', store)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.stores_edit(store) pook.off() @@ -1728,7 +1690,7 @@ class TestVersion4(unittest.TestCase): (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/store/inventories') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .params({'filter[site]' : 'https://retailcrm.ru'}) + .params({'filter[site]': 'https://retailcrm.ru'}) .reply(200) .headers(self.__header) .json( @@ -1755,7 +1717,7 @@ class TestVersion4(unittest.TestCase): } ] } - ) + ) ) response = self.client.inventories({'site': 'https://retailcrm.ru'}) @@ -1763,14 +1725,14 @@ class TestVersion4(unittest.TestCase): self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_inventories_upload(self): """ V4 Test method inventories_upload """ - inventories = {'externalId': '5603', 'id': 5603} + inventories = {'externalId': '5603', 'id': 5603} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/store/inventories/upload') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) @@ -1782,11 +1744,11 @@ class TestVersion4(unittest.TestCase): 'success': 'true', 'processedOffersCount': 0, 'notFoundOffers': { - 'externalId': 'wenw', + 'externalId': 'u234', 'xmlId': 9999 } } - ) + ) ) response = self.client.inventories_upload(inventories) @@ -1818,7 +1780,7 @@ class TestVersion4(unittest.TestCase): } ] } - ) + ) ) response = self.client.prices_upload(price) @@ -1877,7 +1839,7 @@ class TestVersion4(unittest.TestCase): } ] } - ) + ) ) response = self.client.products({'priceType': 'base', 'active': 1}) @@ -1885,13 +1847,13 @@ class TestVersion4(unittest.TestCase): self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_store_setting(self): """ V4 Test method store_setting """ - + code = 'xxx' (pook.get(os.getenv('RETAILCRM_URL') + '/api/v4/store/setting/' + code) @@ -1915,7 +1877,7 @@ class TestVersion4(unittest.TestCase): 'baseUrl': '/' } } - ) + ) ) response = self.client.store_setting(code) @@ -1923,7 +1885,7 @@ class TestVersion4(unittest.TestCase): self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_store_setting_edit(self): """ @@ -1931,23 +1893,23 @@ class TestVersion4(unittest.TestCase): """ setting = { - 'code': 'xxx', - 'name': 'test', + 'code': 'xxx', + 'name': 'test', 'actions': [ { - 'code': 'ccc', + 'code': 'ccc', 'url': 'https://test' } ] } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/store/setting/' + setting['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('configuration', setting)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('configuration', setting)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.store_setting_edit(setting) pook.off() @@ -1961,17 +1923,17 @@ class TestVersion4(unittest.TestCase): V4 Test method telephony_call_event """ - call_event = {'phone': '+799999999','type': 'out'} + call_event = {'phone': '+799999999', 'type': 'out'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/telephony/call/event') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('event', call_event)) - .reply(200) - .headers(self.__header) - .json({'success': 'false', 'errorMsg': 'Telephony not enabled'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('event', call_event)) + .reply(200) + .headers(self.__header) + .json({'success': 'false', 'errorMsg': 'Telephony not enabled'}) + ) - response = self.client.telephony_call_event(call_event) + response = self.client.telephony_call_event(call_event) pook.off() self.assertTrue(response.is_successful(), True) @@ -1984,17 +1946,17 @@ class TestVersion4(unittest.TestCase): """ call = {'phone': '79999999999', 'type': 'out'} - - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/telephony/calls/upload') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('calls', call)) - .reply(200) - .headers(self.__header) - .json({'success': 'false', 'errorMsg': 'Telephony not enabled or not supports calls upload'} - ) - ) - response = self.client.telephony_calls_upload(call) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/telephony/calls/upload') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('calls', call)) + .reply(200) + .headers(self.__header) + .json({'success': 'false', 'errorMsg': 'Telephony not enabled or not supports calls upload'} + ) + ) + + response = self.client.telephony_calls_upload(call) pook.off() self.assertTrue(response.is_successful(), True) @@ -2015,19 +1977,19 @@ class TestVersion4(unittest.TestCase): { 'success': 'true', 'manager': { - 'id': 777, + 'id': 777, 'firstName': 'yyy', 'lastName': 'xxxx', - 'patronymic': 'qwer', + 'patronymic': 'www', 'email': 'mail@retailcrm.ru', 'code': 'ccc7' }, 'customer': { 'id': 888, - 'externalId': '5406', + 'externalId': '5406', 'firstName': 'ccc', - 'lastName': 'zzzz', - 'patronymic': 'asdf', + 'lastName': 'zzz', + 'patronymic': 'sss', 'email': 'mail@retailcrm.ru', 'code': 'ccc7', 'phones': [{'number': '+71111111111'}] @@ -2037,16 +1999,16 @@ class TestVersion4(unittest.TestCase): 'lastOrderLink': 'https://lastOrderLink.ru', 'newCustomerLink': 'https://newCustomerLink.ru', 'customerLink': 'https://customerLink.ru', - } + } } - ) + ) ) response = self.client.telephony_manager('+79999999999') pook.off() self.assertTrue(response.is_successful(), True) - self.assertTrue(response.get_status_code() < 400, True) + self.assertTrue(response.get_status_code() < 400, True) @pook.on def test_telephony_setting(self): @@ -2076,36 +2038,36 @@ class TestVersion4(unittest.TestCase): 'name': 'telephony.company.www' } } - ) + ) ) response = self.client.telephony_setting(code) pook.off() self.assertTrue(response.is_successful(), True) - self.assertTrue(response.get_status_code() < 400, True) + self.assertTrue(response.get_status_code() < 400, True) @pook.on def test_telephony_setting_edit(self): """ V4 Test method telephony_setting_edit """ - + configuration = { - 'code': 'www', - 'clientId': '5604', - 'makeCallUrl': 'https://retailcrm.ru' + 'code': 'www', + 'clientId': '5604', + 'makeCallUrl': 'https://retailcrm.ru' } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v4/telephony/setting/' + configuration['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('configuration', configuration)) - .reply(201) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('configuration', configuration)) + .reply(201) + .headers(self.__header) + .json({'success': 'true'}) + ) - response = self.client.telephony_setting_edit(configuration) + response = self.client.telephony_setting_edit(configuration) pook.off() self.assertTrue(response.is_successful(), True) @@ -2139,6 +2101,8 @@ class TestVersion4(unittest.TestCase): 'isDeliveryMen': 'false', 'deliveryTypes': [], 'breakdownOrderTypes': ['xxx', 'yyy', 'zzz'], + }, + { 'name': 'Руководители', 'code': 'director', 'isManager': 'false', @@ -2152,7 +2116,7 @@ class TestVersion4(unittest.TestCase): } ] } - ) + ) ) response = self.client.user_groups() @@ -2195,9 +2159,9 @@ class TestVersion4(unittest.TestCase): 'isManager': 'false', 'groups': [] } - ] + ] } - ) + ) ) response = self.client.users({'status': 'online', 'isManager': 'false'}) @@ -2235,7 +2199,7 @@ class TestVersion4(unittest.TestCase): 'groups': [] } } - ) + ) ) response = self.client.user(uid) @@ -2249,13 +2213,13 @@ class TestVersion4(unittest.TestCase): """ V4 Test method statistic_update """ - + (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/statistic/update') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.statistic_update() pook.off() diff --git a/tests/v5_tests.py b/tests/v5_tests.py index bed49fc..afdb5ab 100644 --- a/tests/v5_tests.py +++ b/tests/v5_tests.py @@ -12,6 +12,7 @@ import retailcrm import pook import json + class TestVersion5(unittest.TestCase): """ TestClass for v5 @@ -41,14 +42,14 @@ class TestVersion5(unittest.TestCase): 'phones': [], 'contragentType': 'individual' } - + __order = { 'slug': 5604, 'summ': 0, 'id': 5604, 'number': '5604A', 'externalId': '5603', - 'orderType': 'tttt', + 'orderType': 'individual', 'orderMethod': 'shopping-cart', 'countryIso': 'RU', 'createdAt': '2020-04-07 15:44:24', @@ -100,43 +101,43 @@ class TestVersion5(unittest.TestCase): 'id': 5608 }, 'offer': { - 'externalId': 'xcxc55' + 'externalId': 'y6642' } } - } + } __cost = { - 'id': 635, - 'dateFrom': '2020-01-30', - 'dateTo': '2020-01-30', - 'summ': 2, - 'costItem': 'delivery-cost', - 'createdAt': '2020-01-30 16:43:36', - 'order': { - 'id': 4798, - 'number': '16', - 'externalId': '16' - }, - 'sites': [ - 'prestashop' - ] + 'id': 635, + 'dateFrom': '2020-01-30', + 'dateTo': '2020-01-30', + 'summ': 2, + 'costItem': 'delivery-cost', + 'createdAt': '2020-01-30 16:43:36', + 'order': { + 'id': 4798, + 'number': '16', + 'externalId': '16' + }, + 'sites': [ + 'prestashop' + ] } __file = { - 'id': 30, - 'filename': 'API upload 18-09-2019 13:14:00', - 'type': 'application/pdf', - 'createdAt': '2019-09-18 13:14:00', - 'size': 124225, - 'attachment': [ - { - 'order': { - 'id': 7777, - 'number': '7777A', - 'site': 'hhhh' - } + 'id': 30, + 'filename': 'API upload 18-09-2019 13:14:00', + 'type': 'application/pdf', + 'createdAt': '2019-09-18 13:14:00', + 'size': 124225, + 'attachment': [ + { + 'order': { + 'id': 7777, + 'number': '7777A', + 'site': 'hhhh' } - ] + } + ] } __customer_corporate = { @@ -181,7 +182,7 @@ class TestVersion5(unittest.TestCase): 'complete': 'false', 'phone': '+79185550000', 'performerId': 15 - } + } def setUp(self): """ @@ -189,10 +190,11 @@ class TestVersion5(unittest.TestCase): """ self.client = retailcrm.v5( - os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY')) + os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY')) - def dictionaryEncode(self, key, dictonary): - return urlencode({key: json.dumps(dictonary)}) + @staticmethod + def dictionaryEncode(key, dictionary): + return urlencode({key: json.dumps(dictionary)}) @pook.on def test_wrong_api_url(self): @@ -205,11 +207,11 @@ class TestVersion5(unittest.TestCase): .reply(404) .headers(self.__header) .json( - { + { 'success': 'true', 'errorMsg': 'Account does not exist.' } - ) + ) ) client = retailcrm.v5('https://epoqq.retailcrm.ru', os.getenv('RETAILCRM_KEY')) @@ -226,11 +228,11 @@ class TestVersion5(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/statistic/update') - .headers({'X-API-KEY': 'XXXX'}) - .reply(200) - .headers(self.__header) - .json({'errorMsg': 'Wrong "apiKey" value.'}) - ) + .headers({'X-API-KEY': 'XXXX'}) + .reply(200) + .headers(self.__header) + .json({'errorMsg': 'Wrong "apiKey" value.'}) + ) client = retailcrm.v5(os.getenv('RETAILCRM_URL'), 'XXXX') response = client.statistic_update() @@ -245,11 +247,11 @@ class TestVersion5(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/statistic/update') - .headers({'X-API-KEY': None}) - .reply(200) - .headers(self.__header) - .json({'errorMsg': '"apiKey" is missing.'}) - ) + .headers({'X-API-KEY': None}) + .reply(200) + .headers(self.__header) + .json({'errorMsg': '"apiKey" is missing.'}) + ) client = retailcrm.v5(os.getenv('RETAILCRM_URL'), None) response = client.statistic_update() @@ -264,11 +266,11 @@ class TestVersion5(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/api-versions') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'versions': ['3.0', '4.0', '5.0']}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'versions': ['3.0', '4.0', '5.0']}) + ) response = self.client.api_versions() pook.off() @@ -282,12 +284,12 @@ class TestVersion5(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/credentials') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'credentials': [], 'siteAccess': 'access_full'}) - ) - + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'credentials': [], 'siteAccess': 'access_full'}) + ) + response = self.client.api_credentials() pook.off() @@ -296,7 +298,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_costs(self): """ - V5 Test method costs + V5 Test method costs """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/costs') @@ -307,14 +309,14 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 6, - 'currentPage': 1, - 'totalPageCount': 1 - }, + 'limit': 20, + 'totalCount': 6, + 'currentPage': 1, + 'totalPageCount': 1 + }, 'costs': [self.__cost] } - ) + ) ) response = self.client.costs() @@ -330,12 +332,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/costs/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('cost', self.__cost)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7117}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('cost', self.__cost)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7117}) + ) response = self.client.cost_create(self.__cost) pook.off() @@ -346,12 +348,12 @@ class TestVersion5(unittest.TestCase): @pook.on def test_costs_delete(self): """ - V5 Test method costs_delete + V5 Test method costs_delete """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/costs/delete') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('ids', [555,666,777])) + .body(self.dictionaryEncode('ids', [555, 666, 777])) .reply(200) .headers(self.__header) .json( @@ -360,10 +362,10 @@ class TestVersion5(unittest.TestCase): 'count': 3, 'notRemovedIds': [] } - ) + ) ) - response = self.client.costs_delete([555,666,777]) + response = self.client.costs_delete([555, 666, 777]) pook.off() self.assertTrue(response.is_successful(), True) @@ -376,12 +378,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/costs/upload') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('costs', [self.__cost])) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'uploadedCosts': [555]}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('costs', [self.__cost])) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'uploadedCosts': [555]}) + ) response = self.client.costs_upload([self.__cost]) pook.off() @@ -398,11 +400,11 @@ class TestVersion5(unittest.TestCase): uid = str(self.__cost['id']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/costs/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'cost': self.__cost}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'cost': self.__cost}) + ) response = self.client.cost(uid) pook.off() @@ -419,11 +421,11 @@ class TestVersion5(unittest.TestCase): uid = '7777' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/costs/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.cost_delete(uid) pook.off() @@ -440,12 +442,12 @@ class TestVersion5(unittest.TestCase): uid = str(self.__cost['id']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/costs/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('cost', self.__cost)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 7777}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('cost', self.__cost)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 7777}) + ) response = self.client.cost_edit(self.__cost) pook.off() @@ -456,7 +458,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_custom_fields(self): """ - V5 Test method custom_fields + V5 Test method custom_fields """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/custom-fields') @@ -489,7 +491,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.custom_fields({'entity': 'customer'}) @@ -501,7 +503,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_custom_dictionaries(self): """ - V5 Test method custom_dictionaries + V5 Test method custom_dictionaries """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/custom-fields/dictionaries') @@ -532,7 +534,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.custom_dictionaries({'name': 'test223'}) @@ -548,18 +550,18 @@ class TestVersion5(unittest.TestCase): """ custom_dictionary = { - 'name': 'test', + 'name': 'test', 'code': 'test', - 'elements': [{'name': 'fear', 'code': 'ffdg'}] + 'elements': [{'name': 'fear', 'code': 'e456'}] } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/custom-fields/dictionaries/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customDictionary', custom_dictionary)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'code': 'test'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customDictionary', custom_dictionary)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'code': 'test'}) + ) response = self.client.custom_dictionary_create(custom_dictionary) pook.off() @@ -594,37 +596,40 @@ class TestVersion5(unittest.TestCase): ] } } - ) ) - + ) response = self.client.custom_dictionary(uid) pook.off() self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_custom_dictionary_edit(self): """ V5 Test method custom_dictionary_edit """ - customDictionary = { - 'name': 'test', + custom_dictionary = { + 'name': 'test', 'code': 'test', - 'elements': [{'name': 'fear', 'code': 'ffdg'}] + 'elements': [{'name': 'fear', 'code': 'e456'}] } - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/custom-fields/dictionaries/' + customDictionary['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customDictionary', customDictionary)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'code': 'test'}) - ) + (pook.post( + os.getenv('RETAILCRM_URL') + + '/api/v5/custom-fields/dictionaries/' + + custom_dictionary['code'] + + '/edit') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customDictionary', custom_dictionary)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'code': 'test'}) + ) - response = self.client.custom_dictionary_edit(customDictionary) + response = self.client.custom_dictionary_edit(custom_dictionary) pook.off() self.assertTrue(response.is_successful(), True) @@ -637,19 +642,19 @@ class TestVersion5(unittest.TestCase): """ custom_field = { - 'name': 'test', + 'name': 'test', 'code': 'test', 'type': 'text', 'entity': 'customer' } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/custom-fields/' + custom_field['entity'] + '/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customField', custom_field)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'code': 'test'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customField', custom_field)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'code': 'test'}) + ) response = self.client.custom_field_create(custom_field) pook.off() @@ -686,7 +691,7 @@ class TestVersion5(unittest.TestCase): 'viewMode': 'editable' } } - ) + ) ) response = self.client.custom_field(code, entity) @@ -702,20 +707,21 @@ class TestVersion5(unittest.TestCase): """ custom_field = { - 'name': 'test', + 'name': 'test', 'ordering': 5555, 'displayArea': 'customer', 'entity': 'customer', 'code': 'test' } - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/custom-fields/' + custom_field['entity'] + '/' + custom_field['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customField', custom_field)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'code': 'test'}) - ) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/custom-fields/' + custom_field['entity'] + '/' + custom_field[ + 'code'] + '/edit') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customField', custom_field)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'code': 'test'}) + ) response = self.client.custom_field_edit(custom_field) pook.off() @@ -745,7 +751,7 @@ class TestVersion5(unittest.TestCase): }, 'customers': [self.__customer] } - ) + ) ) response = self.client.customers({'online': 'No', 'contragentType': 'individual'}) @@ -763,14 +769,11 @@ class TestVersion5(unittest.TestCase): customer = {'id': 5604} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers/combine') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body( - self.dictionaryEncode('customers', customer) + '&' + - self.dictionaryEncode('resultCustomer', customer)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customers_combine(customer, customer) pook.off() @@ -785,12 +788,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customer', self.__customer)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7117}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customer', self.__customer)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7117}) + ) response = self.client.customer_create(self.__customer) pook.off() @@ -805,12 +808,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers/fix-external-ids') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customers', self.__customer['externalId'])) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customers', self.__customer['externalId'])) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customers_fix_external_ids(self.__customer['externalId']) pook.off() @@ -821,18 +824,18 @@ class TestVersion5(unittest.TestCase): @pook.on def test_customers_history(self): """ - V5 Test method customers_history + V5 Test method customers_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/customers/history') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params( { 'filter[sinceId]': '1111', 'filter[startDate]': '2016-01-07', - 'filter[endDate]': '2020-04-12' + 'filter[endDate]': '2020-04-12' } - ) + ) .reply(200) .headers(self.__header) .json( @@ -853,7 +856,7 @@ class TestVersion5(unittest.TestCase): 'newValue': 4949, 'customer': { 'id': 4949, - 'externalId': 'xxxxxxx1', + 'externalId': 'c456', 'createdAt': '2018-04-11 09:01:26', 'vip': 'false', 'bad': 'false', @@ -876,15 +879,15 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.customers_history( - { - 'sinceId': '1111', - 'startDate': '2016-01-07', - 'endDate': '2020-04-12' - } + { + 'sinceId': '1111', + 'startDate': '2016-01-07', + 'endDate': '2020-04-12' + } ) pook.off() @@ -894,11 +897,11 @@ class TestVersion5(unittest.TestCase): @pook.on def test_customers_notes(self): """ - V5 Test method customers_notes + V5 Test method customers_notes """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/customers/notes') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params({'filter[createdAtFrom]': '2020-04-18', 'filter[createdAtTo]': '2020-04-21'}) .reply(200) .headers(self.__header) @@ -924,7 +927,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.customer_notes({'createdAtFrom': '2020-04-18', 'createdAtTo': '2020-04-21'}) @@ -939,15 +942,15 @@ class TestVersion5(unittest.TestCase): V5 Test method customer_note_create """ - note = {'managerId': 23, 'text': 'test','customer': {'id': 5604}} + note = {'managerId': 23, 'text': 'test', 'customer': {'id': 5604}} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers/notes/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('note', note)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 2222}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('note', note)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 2222}) + ) response = self.client.customer_note_create(note) pook.off() @@ -964,11 +967,11 @@ class TestVersion5(unittest.TestCase): uid = '279' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers/notes/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customer_note_delete(uid) pook.off() @@ -991,13 +994,13 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'uploadedCustomers': [ - { + { 'id': 9717, 'externalId': 'c-983344770' } ] } - ) + ) ) response = self.client.customers_upload(self.__customer) @@ -1015,11 +1018,11 @@ class TestVersion5(unittest.TestCase): uid = str(self.__customer['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/customers/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'customers': self.__customer}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'customers': self.__customer}) + ) response = self.client.customer(uid) pook.off() @@ -1036,12 +1039,12 @@ class TestVersion5(unittest.TestCase): uid = str(self.__customer['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customer', self.__customer)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 9717}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customer', self.__customer)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 9717}) + ) response = self.client.customer_edit(self.__customer) pook.off() @@ -1064,14 +1067,14 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 128, - 'currentPage': 1, - 'totalPageCount': 7 - }, + 'limit': 20, + 'totalCount': 128, + 'currentPage': 1, + 'totalPageCount': 7 + }, 'customersCorporate': [self.__customer_corporate] } - ) + ) ) response = self.client.customers_corporate({'vip': 'false', 'companyName': 'Test'}) @@ -1089,14 +1092,11 @@ class TestVersion5(unittest.TestCase): customer = {'id': 5604} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/combine') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body( - self.dictionaryEncode('customers', customer) + '&' + - self.dictionaryEncode('resultCustomer', customer)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customers_combine_corporate(customer, customer) pook.off() @@ -1111,12 +1111,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customerCorporate', self.__customer_corporate)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7117}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customerCorporate', self.__customer_corporate)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7117}) + ) response = self.client.customer_corporate_create(self.__customer_corporate) pook.off() @@ -1131,12 +1131,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/fix-external-ids') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customerCorporate', self.__customer_corporate['externalId'])) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customerCorporate', self.__customer_corporate['externalId'])) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customers_corporate_fix_external_ids(self.__customer_corporate['externalId']) pook.off() @@ -1147,18 +1147,18 @@ class TestVersion5(unittest.TestCase): @pook.on def test_customers_history(self): """ - V5 Test method customers_corporate_history + V5 Test method customers_corporate_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/history') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params( { 'filter[sinceId]': '1111', 'filter[startDate]': '2016-01-07', - 'filter[endDate]': '2020-04-12' + 'filter[endDate]': '2020-04-12' } - ) + ) .reply(200) .headers(self.__header) .json( @@ -1195,15 +1195,15 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.customers_corporate_history( - { - 'sinceId': '1111', - 'startDate': '2016-01-07', - 'endDate': '2020-04-12' - } + { + 'sinceId': '1111', + 'startDate': '2016-01-07', + 'endDate': '2020-04-12' + } ) pook.off() @@ -1213,11 +1213,11 @@ class TestVersion5(unittest.TestCase): @pook.on def test_customer_corporate_notes(self): """ - V5 Test method customer_corporate_notes + V5 Test method customer_corporate_notes """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/notes') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params({'filter[createdAtFrom]': '2020-04-18', 'filter[createdAtTo]': '2020-04-21'}) .reply(200) .headers(self.__header) @@ -1243,7 +1243,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.customer_corporate_notes({'createdAtFrom': '2020-04-18', 'createdAtTo': '2020-04-21'}) @@ -1258,15 +1258,15 @@ class TestVersion5(unittest.TestCase): V5 Test method customer_corporate_note_create """ - note = {'managerId': 23, 'text': 'test','customer': {'id': 5604}} + note = {'managerId': 23, 'text': 'test', 'customer': {'id': 5604}} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/notes/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('note', note)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 2222}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('note', note)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 2222}) + ) response = self.client.customer_corporate_note_create(note) pook.off() @@ -1283,11 +1283,11 @@ class TestVersion5(unittest.TestCase): uid = '279' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/notes/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.customer_corporate_note_delete(uid) pook.off() @@ -1310,13 +1310,13 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'uploadedCustomers': [ - { + { 'id': 9717, 'externalId': 'c-983344770' } ] } - ) + ) ) response = self.client.customers_corporate_upload(self.__customer_corporate) @@ -1334,11 +1334,11 @@ class TestVersion5(unittest.TestCase): uid = str(self.__customer_corporate['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'customerCorporate': self.__customer_corporate}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'customerCorporate': self.__customer_corporate}) + ) response = self.client.customer_corporate(uid) pook.off() @@ -1364,7 +1364,7 @@ class TestVersion5(unittest.TestCase): 'success': 'true', 'addresses': [{ 'id': 3995, - 'text': '123123, Russian Federation, TETETETE, ADdress 1, ', + 'text': '123123, Russian Federation, Moscow, Kutuzovski 14', 'isMain': 'true', 'name': 'Test' }], @@ -1375,7 +1375,7 @@ class TestVersion5(unittest.TestCase): 'totalPageCount': 1 } } - ) + ) ) response = self.client.customer_corporate_addresses(uid) @@ -1391,14 +1391,16 @@ class TestVersion5(unittest.TestCase): """ address = {'isMain': 'true', 'name': 'Test', 'externalId': 'cc_9'} - - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + address['externalId'] + '/addresses/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('address', address)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 9717}) - ) + + (pook.post( + os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + address[ + 'externalId'] + '/addresses/create') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('address', address)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 9717}) + ) response = self.client.customer_corporate_addresses_create(address) pook.off() @@ -1415,13 +1417,14 @@ class TestVersion5(unittest.TestCase): uid = str(self.__customer_corporate['externalId']) address = {'isMain': 'true', 'name': 'Test', 'externalId': 'ccc8'} - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid + '/addresses/' + address['externalId'] +'/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('address', address)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': '7777'}) - ) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid + '/addresses/' + address[ + 'externalId'] + '/edit') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('address', address)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': '7777'}) + ) response = self.client.customer_corporate_addresses_edit(uid, address) pook.off() @@ -1476,7 +1479,7 @@ class TestVersion5(unittest.TestCase): "totalPageCount": 1 } } - ) + ) ) response = self.client.customer_corporate_companies(uid) @@ -1493,13 +1496,15 @@ class TestVersion5(unittest.TestCase): company = {'isMain': 'true', 'name': 'TestN', 'externalId': 'cc_9'} - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + company['externalId'] + '/companies/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('company', company)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 9717}) - ) + (pook.post( + os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + company[ + 'externalId'] + '/companies/create') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('company', company)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 9717}) + ) response = self.client.customer_corporate_companies_create(company) pook.off() @@ -1516,13 +1521,14 @@ class TestVersion5(unittest.TestCase): uid = str(self.__customer_corporate['externalId']) company = {'isMain': 'true', 'name': 'TestN', 'externalId': 'ccc9'} - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid + '/companies/' + company['externalId'] +'/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('company', company)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 7777}) - ) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid + '/companies/' + company[ + 'externalId'] + '/edit') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('company', company)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 7777}) + ) response = self.client.customer_corporate_companies_edit(uid, company) pook.off() @@ -1565,7 +1571,7 @@ class TestVersion5(unittest.TestCase): 'totalPageCount': 1 } } - ) + ) ) response = self.client.customer_corporate_contacts(uid) @@ -1582,13 +1588,15 @@ class TestVersion5(unittest.TestCase): contact = {'isMain': 'true', 'name': 'TestM', 'externalId': 'cc_9'} - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + contact['externalId'] + '/contacts/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('contact', contact)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 9717}) - ) + (pook.post( + os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + contact[ + 'externalId'] + '/contacts/create') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('contact', contact)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 9717}) + ) response = self.client.customer_corporate_contacts_create(contact) pook.off() @@ -1605,20 +1613,21 @@ class TestVersion5(unittest.TestCase): uid = str(self.__customer_corporate['externalId']) contact = {'isMain': 'true', 'name': 'TestM', 'externalId': 'cc_10'} - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid + '/contacts/' + contact['externalId'] +'/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('contact', contact)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': '7777'}) - ) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid + '/contacts/' + contact[ + 'externalId'] + '/edit') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('contact', contact)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': '7777'}) + ) response = self.client.customer_corporate_contacts_edit(uid, contact) pook.off() self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_customer_corporate_edit(self): """ @@ -1628,12 +1637,12 @@ class TestVersion5(unittest.TestCase): uid = str(self.__customer_corporate['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('customersCorporate', self.__customer_corporate)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': '9717'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('customersCorporate', self.__customer_corporate)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': '9717'}) + ) response = self.client.customer_corporate_edit(self.__customer_corporate) pook.off() @@ -1660,13 +1669,13 @@ class TestVersion5(unittest.TestCase): } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/delivery/generic/' + code + '/tracking') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode( + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode( 'statusUpdate', delivery_id)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_tracking(code, delivery_id) pook.off() @@ -1718,7 +1727,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.delivery_shipments({'stores': 'test'}) @@ -1733,15 +1742,15 @@ class TestVersion5(unittest.TestCase): V5 Test method delivery_shipment_create """ - delivery_shipment = {'status': 'cancelled', 'store': 'test'} + delivery_shipment = {'status': 'cancelled', 'store': 'test'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/delivery/shipments/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryShipment', delivery_shipment )) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5555, 'status': 'cancelled'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryShipment', delivery_shipment)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5555, 'status': 'cancelled'}) + ) response = self.client.delivery_shipment_create(delivery_shipment) pook.off() @@ -1763,8 +1772,8 @@ class TestVersion5(unittest.TestCase): .headers(self.__header) .json( { - 'success': 'true', - 'deliveryShipments': + 'success': 'true', + 'deliveryShipments': { 'integrationCode': 'xxx', 'id': 1, @@ -1787,21 +1796,21 @@ class TestVersion5(unittest.TestCase): 'extraData': [] } } - ) ) - + ) + response = self.client.delivery_shipment(uid) pook.off() self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_delivery_shipment_edit(self): """ V5 Test method delivery_shipment_edit """ - + delivery_shipment = { 'integrationCode': 'xxx', 'id': 1, @@ -1810,7 +1819,7 @@ class TestVersion5(unittest.TestCase): 'store': 'test', 'managerId': 23, 'status': 'processing', - 'date': '2020-03-31', + 'date': '2020-03-31', 'time': { 'from': '13:00', 'to': '18:00' @@ -1826,12 +1835,12 @@ class TestVersion5(unittest.TestCase): uid = delivery_shipment['id'] (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/delivery/shipment/' + str(uid) + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryShipment', delivery_shipment)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5555, 'status': 'cancelled'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryShipment', delivery_shipment)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5555, 'status': 'cancelled'}) + ) response = self.client.delivery_shipment_edit(delivery_shipment) pook.off() @@ -1842,9 +1851,9 @@ class TestVersion5(unittest.TestCase): @pook.on def test_files(self): """ - V5 Test method files + V5 Test method files """ - + (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/files') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params({'filter[sizeFrom]': '1'}) @@ -1861,7 +1870,7 @@ class TestVersion5(unittest.TestCase): }, 'files': [self.__file] } - ) + ) ) response = self.client.files({'sizeFrom': '1'}) @@ -1877,12 +1886,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/files/upload') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('file', self.__file)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'file': {'id': 92}}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('file', self.__file)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'file': {'id': 92}}) + ) response = self.client.files_upload(self.__file) pook.off() @@ -1899,11 +1908,11 @@ class TestVersion5(unittest.TestCase): uid = str(self.__file['id']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/files/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'file': self.__file}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'file': self.__file}) + ) response = self.client.file(uid) pook.off() @@ -1920,11 +1929,11 @@ class TestVersion5(unittest.TestCase): uid = '7777' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/files/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.files_delete(uid) pook.off() @@ -1941,12 +1950,12 @@ class TestVersion5(unittest.TestCase): uid = '7777' (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/files/' + uid + '/download') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .params(uid) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .params(uid) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.files_download(uid) pook.off() @@ -1963,12 +1972,12 @@ class TestVersion5(unittest.TestCase): uid = '30' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/files/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('file', self.__file)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('file', self.__file)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.files_edit(self.__file) pook.off() @@ -1993,37 +2002,37 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': '20', - 'totalCount': '4347', - 'currentPage': '1', - 'totalPageCount': '87' - }, - 'integrationModule': - { - 'success': 'true', - 'integrationModule': { - 'code': 'xxx', - 'integrationCode': 'xxx', - 'active': 'true', - 'freeze': 'false', - 'name': 'test', - 'native': 'false', - 'actions': {}, - 'availableCountries': [], - 'integrations': { - 'store': { - 'actions': [ - { - 'code': 'ccc', - 'url': 'https://test' - } - ] + 'limit': '20', + 'totalCount': '4347', + 'currentPage': '1', + 'totalPageCount': '87' + }, + 'integrationModule': + { + 'success': 'true', + 'integrationModule': { + 'code': 'xxx', + 'integrationCode': 'xxx', + 'active': 'true', + 'freeze': 'false', + 'name': 'test', + 'native': 'false', + 'actions': {}, + 'availableCountries': [], + 'integrations': { + 'store': { + 'actions': [ + { + 'code': 'ccc', + 'url': 'https://test' + } + ] + } } } } - } } - ) + ) ) response = self.client.integration_module(code) @@ -2038,16 +2047,16 @@ class TestVersion5(unittest.TestCase): V5 Test method integration_module_edit """ - integration_module = {'code': 'xxx','integrationCode': 'xxx'} + integration_module = {'code': 'xxx', 'integrationCode': 'xxx'} uid = 'xxx' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/integration-modules/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('integrationModule', integration_module)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('integrationModule', integration_module)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.integration_module_edit(integration_module) pook.off() @@ -2070,14 +2079,14 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 2464, - 'currentPage': 1, - 'totalPageCount': 50 - }, + 'limit': 20, + 'totalCount': 2464, + 'currentPage': 1, + 'totalPageCount': 50 + }, 'orders': [self.__order] } - ) + ) ) response = self.client.orders({'city': 'Moscow', 'contragentType': 'individual'}) @@ -2095,14 +2104,11 @@ class TestVersion5(unittest.TestCase): order = {'id': 5604} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/combine') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body('technique=merge' + '&' + - self.dictionaryEncode('order', order) + '&' + - self.dictionaryEncode('resultOrder', order)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.orders_combine(order, order, 'merge') pook.off() @@ -2117,12 +2123,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('order', self.__order)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 8888, 'order': self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('order', self.__order)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 8888, 'order': self.__order}) + ) response = self.client.order_create(self.__order) pook.off() @@ -2137,12 +2143,12 @@ class TestVersion5(unittest.TestCase): """ (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/fix-external-ids') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orders', self.__order['externalId'])) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orders', self.__order['externalId'])) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.orders_fix_external_ids(self.__order['externalId']) pook.off() @@ -2153,18 +2159,18 @@ class TestVersion5(unittest.TestCase): @pook.on def test_orders_history(self): """ - V5 Test method orders_history + V5 Test method orders_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/orders/history') - .headers({'X-API-KEY' : os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .params( { 'filter[sinceId]': '1111', 'filter[startDate]': '2016-01-07', - 'filter[endDate]': '2020-04-12' + 'filter[endDate]': '2020-04-12' } - ) + ) .reply(200) .headers(self.__header) .json( @@ -2190,7 +2196,7 @@ class TestVersion5(unittest.TestCase): 'summ': 0, 'id': 9090, 'number': '9090A', - 'externalId': 'xxxxxxxs', + 'externalId': 'v4321', 'orderType': 'eshop-individual', 'orderMethod': 'shopping-cart', 'createdAt': '2018-04-11 09:01:29', @@ -2252,15 +2258,15 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.orders_history( - { - 'sinceId': '1111', - 'startDate': '2016-01-07', - 'endDate': '2020-04-12' - } + { + 'sinceId': '1111', + 'startDate': '2016-01-07', + 'endDate': '2020-04-12' + } ) pook.off() @@ -2290,7 +2296,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.orders_statuses([5604], [5603]) @@ -2314,14 +2320,14 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'uploadedOrders': [ - { + { 'id': 5604, 'externalId': '5603' } ], 'orders': [self.__order] } - ) + ) ) response = self.client.orders_upload(self.__order) @@ -2339,11 +2345,11 @@ class TestVersion5(unittest.TestCase): uid = str(self.__order['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/orders/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'orders' : self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'orders': self.__order}) + ) response = self.client.order(uid) pook.off() @@ -2358,50 +2364,50 @@ class TestVersion5(unittest.TestCase): """ link = { - "comment": "test", + "comment": "test", "orders": [ { - "id": 5604, - "externalId": 5603, + "id": 5604, + "externalId": 5603, "number": 1 - }, + }, { - "id": 5605, - "externalId": 5601, + "id": 5605, + "externalId": 5601, "number": 1 } ] } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/links/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('link', link)) - .reply(201) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('link', link)) + .reply(201) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_links_create(link) pook.off() self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) - + @pook.on def test_order_payment_create(self): """ V5 Test method payment_create """ - payment = {'order': {'externalId': '5603'},'type': 'bank-card'} - + payment = {'order': {'externalId': '5603'}, 'type': 'bank-card'} + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/payments/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('payment', payment)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7777}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('payment', payment)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7777}) + ) response = self.client.order_payment_create(payment) pook.off() @@ -2418,11 +2424,11 @@ class TestVersion5(unittest.TestCase): uid = '7777' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/payments/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_payment_delete(uid) pook.off() @@ -2437,25 +2443,25 @@ class TestVersion5(unittest.TestCase): """ payment = { - 'externalId': '5603', + 'externalId': '5603', 'order': [ { - 'id': 5604, - 'externalId': '5603', + 'id': 5604, + 'externalId': '5603', 'number': 1 - } + } ], 'type': 'bank-card' } uid = str(self.__order['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/payments/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('payment', payment)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'payment': payment}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('payment', payment)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'payment': payment}) + ) response = self.client.order_payment_edit(payment) pook.off() @@ -2486,7 +2492,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.orders_statuses([5604], [5603]) @@ -2510,14 +2516,14 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'uploadedOrders': [ - { + { 'id': 5604, 'externalId': '5603' } ], 'orders': [self.__order] } - ) + ) ) response = self.client.orders_upload(self.__order) @@ -2535,11 +2541,11 @@ class TestVersion5(unittest.TestCase): uid = str(self.__order['externalId']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/orders/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'orders' : self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'orders': self.__order}) + ) response = self.client.order(uid) pook.off() @@ -2556,12 +2562,12 @@ class TestVersion5(unittest.TestCase): uid = str(self.__order['externalId']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('order', self.__order)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5604, 'order': self.__order}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('order', self.__order)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5604, 'order': self.__order}) + ) response = self.client.order_edit(self.__order) pook.off() @@ -2584,14 +2590,14 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'pagination': { - 'limit': 20, - 'totalCount': 1, - 'currentPage': 1, - 'totalPageCount': 1 - }, - 'packs' : [self.__pack] + 'limit': 20, + 'totalCount': 1, + 'currentPage': 1, + 'totalPageCount': 1 + }, + 'packs': [self.__pack] } - ) + ) ) response = self.client.packs({'store': '7777z'}) @@ -2609,12 +2615,12 @@ class TestVersion5(unittest.TestCase): packs_create = {'store': '7777z', 'quantity': 1, 'itemId': 7632} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/packs/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('pack', packs_create)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 7777}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('pack', packs_create)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 7777}) + ) response = self.client.pack_create(packs_create) pook.off() @@ -2625,7 +2631,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_packs_history(self): """ - V5 Test method packs_history + V5 Test method packs_history """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/orders/packs/history') @@ -2647,23 +2653,23 @@ class TestVersion5(unittest.TestCase): 'code': 'zzz' }, 'pack': { - 'id': 678, - 'quantity': 1, - 'store': {'code': 'zzz'}, - 'item': { - 'id': 222, - 'order': {'id': 6677}, - 'offer': {'externalId': '333'} - } + 'id': 678, + 'quantity': 1, + 'store': {'code': 'zzz'}, + 'item': { + 'id': 222, + 'order': {'id': 6677}, + 'offer': {'externalId': '333'} + } }, 'source': 'api' } ] - } - ) + } + ) ) - response = self.client.packs_history({'startDate' : '2016-01-07', 'endDate' : '2020-04-12'}) + response = self.client.packs_history({'startDate': '2016-01-07', 'endDate': '2020-04-12'}) pook.off() self.assertTrue(response.is_successful(), True) @@ -2677,11 +2683,11 @@ class TestVersion5(unittest.TestCase): uid = str(self.__pack['id']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/orders/packs/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'pack': self.__pack}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'pack': self.__pack}) + ) response = self.client.pack(uid) pook.off() @@ -2698,11 +2704,11 @@ class TestVersion5(unittest.TestCase): uid = '7777' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/packs/' + uid + '/delete') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.pack_delete(uid) pook.off() @@ -2719,12 +2725,12 @@ class TestVersion5(unittest.TestCase): uid = str(self.__pack['id']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/orders/packs/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('pack', self.__pack)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': 5604}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('pack', self.__pack)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': 5604}) + ) response = self.client.pack_edit(self.__pack) pook.off() @@ -2741,12 +2747,12 @@ class TestVersion5(unittest.TestCase): check = {'invoiceUuid': '577', 'amount': 1, 'currency': 'RU'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/payment/check') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('check', check )) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'result': {'success': 'true'}}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('check', check)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'result': {'success': 'true'}}) + ) response = self.client.payment_check(check) pook.off() @@ -2760,15 +2766,15 @@ class TestVersion5(unittest.TestCase): V5 Test method payment_create_invoice """ - create_invoice = {'paymentId': 578, 'returnUrl' : 'https://test.ru'} + create_invoice = {'paymentId': 578, 'returnUrl': 'https://test.ru'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/payment/create-invoice') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('createInvoice', create_invoice)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'result': {'link': 'https://test.ru'}}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('createInvoice', create_invoice)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'result': {'link': 'https://test.ru'}}) + ) response = self.client.payment_create_invoice(create_invoice) pook.off() @@ -2785,12 +2791,12 @@ class TestVersion5(unittest.TestCase): update_invoice = {'invoiceUuid': '577', 'paymentId': '5304'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/payment/update-invoice') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('updateInvoice', update_invoice)) - .reply(201) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('updateInvoice', update_invoice)) + .reply(201) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.payment_update_invoice(update_invoice) pook.off() @@ -2801,9 +2807,9 @@ class TestVersion5(unittest.TestCase): @pook.on def test_cost_groups(self): """ - V5 Test method cost_groups + V5 Test method cost_groups """ - + (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/cost-groups') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(200) @@ -2813,8 +2819,8 @@ class TestVersion5(unittest.TestCase): 'success': 'true', 'costGroups': [ { - 'code': 'cost-gr-syda', - 'name': 'CostGroup-syda', + 'code': 'cost-gr-example', + 'name': 'CostGroup-example', 'ordering': 990, 'active': 'true', 'color': '#da5c98' @@ -2828,7 +2834,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.cost_groups() @@ -2843,15 +2849,15 @@ class TestVersion5(unittest.TestCase): V5 Test method cost_groups_edit """ - group = {'code': 'cost-gr-syda', 'color': '#da5c98', 'ordering': 990, 'name': 'CostGroup-lst7'} + group = {'code': 'cost-gr-example', 'color': '#da5c98', 'ordering': 990, 'name': 'CostGroup-lst7'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/cost-groups/' + group['code'] + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('costGroup', group)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('costGroup', group)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.cost_groups_edit(group) pook.off() @@ -2862,7 +2868,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_cost_items(self): """ - V5 Test method cost_items + V5 Test method cost_items """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/cost-items') @@ -2874,9 +2880,9 @@ class TestVersion5(unittest.TestCase): 'success': 'true', 'costItems': [ { - 'code': 'cost-it-syda', - 'name': 'CostItem-syda', - 'group': 'cost-gr-syda', + 'code': 'cost-it-example', + 'name': 'CostItem-example', + 'group': 'cost-gr-example', 'ordering': 990, 'active': 'true', 'appliesToOrders': 'true', @@ -2884,9 +2890,9 @@ class TestVersion5(unittest.TestCase): 'appliesToUsers': 'false' }, { - 'code': 'cost-it-gzqz', - 'name': 'CostItem-gzqz', - 'group': 'cost-gr-gzqz', + 'code': 'cost-it-1', + 'name': 'CostItem-1', + 'group': 'cost-gr-1', 'ordering': 990, 'active': 'true', 'appliesToOrders': 'true', @@ -2895,7 +2901,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.cost_items() @@ -2910,15 +2916,15 @@ class TestVersion5(unittest.TestCase): V5 Test method cost_items_edit """ - item = {'code': 'cost-it-syda', 'name': 'CostItem-syda', 'ordering': 990, 'active': 'true'} - + item = {'code': 'cost-it-example', 'name': 'CostItem-example', 'ordering': 990, 'active': 'true'} + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/cost-groups/' + item['code'] + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('costItem', item)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('costItem', item)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.cost_items_edit(item) pook.off() @@ -2929,15 +2935,15 @@ class TestVersion5(unittest.TestCase): @pook.on def test_countries(self): """ - V5 Test method countries + V5 Test method countries """ - + (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/countries') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'countriesIso': ['RU', 'UA', 'BY', 'KZ']}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'countriesIso': ['RU', 'UA', 'BY', 'KZ']}) + ) response = self.client.countries() pook.off() @@ -2948,7 +2954,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_couriers(self): """ - V5 Test method couriers + V5 Test method couriers """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/couriers') @@ -2957,27 +2963,27 @@ class TestVersion5(unittest.TestCase): .headers(self.__header) .json( { - 'success': 'true', + 'success': 'true', 'couriers': [ { 'id': 55, - 'firstName': '43bf5', - 'lastName': 'fzj3b', - 'patronymic': 'dbk88', + 'firstName': 'Jean', + 'lastName': 'Doe', + 'patronymic': 'M.', 'active': 'true', 'email': 'r9z4o@example.com' }, { 'id': 57, - 'firstName': 'h43qt', - 'lastName': 'moop7', - 'patronymic': '4pahc', + 'firstName': 'John', + 'lastName': 'Doe', + 'patronymic': 'H.', 'active': 'true', 'email': 'oflf9@example.com' } ] } - ) + ) ) response = self.client.couriers() @@ -2994,20 +3000,20 @@ class TestVersion5(unittest.TestCase): courier = { 'id': 55, - 'firstName': '43bf5', - 'lastName': 'fzj3b', - 'patronymic': 'dbk88', + 'firstName': 'John', + 'lastName': 'Doe', + 'patronymic': 'H.', 'active': 'true', 'email': 'r9z4o@example.com' } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/couriers/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('courier', courier)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': '8888'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('courier', courier)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': '8888'}) + ) response = self.client.couriers_create(courier) pook.off() @@ -3023,20 +3029,20 @@ class TestVersion5(unittest.TestCase): courier = { 'id': 55, - 'firstName': '43bf5', - 'lastName': 'fzj3b', - 'patronymic': 'dbk88', + 'firstName': 'John', + 'lastName': 'Doe', + 'patronymic': 'H.', 'active': 'true', 'email': 'r9z4o@example.com' } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/couriers/' + str(courier['id']) + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('courier', courier)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('courier', courier)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.couriers_edit(courier) pook.off() @@ -3047,7 +3053,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_delivery_services(self): """ - V5 Test method delivery_services + V5 Test method delivery_services """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/delivery-services') @@ -3064,13 +3070,13 @@ class TestVersion5(unittest.TestCase): 'active': 'true' }, 'hmo8s': { - 'name': 'kgkk3', + 'name': 'k1233', 'code': 'hmo8s', 'active': 'true' } } } - ) + ) ) response = self.client.delivery_services() @@ -3085,15 +3091,15 @@ class TestVersion5(unittest.TestCase): V5 Test method delivery_services_edit """ - service = {'code': 'hmo8s', 'name': 'kgkk3'} - + service = {'code': 'hmo8s', 'name': 'x345'} + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/delivery-services/' + service['code'] + '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryService', service)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryService', service)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_services_edit(service) pook.off() @@ -3104,11 +3110,11 @@ class TestVersion5(unittest.TestCase): @pook.on def test_delivery_types(self): """ - V5 Test method delivery_types + V5 Test method delivery_types """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/delivery-types') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(201) .headers(self.__header) .json( @@ -3116,8 +3122,8 @@ class TestVersion5(unittest.TestCase): 'success': 'true', 'deliveryTypes': { '1kp52': { - 'name': '1cxub', - 'code': '1kp52', + 'name': 'c435', + 'code': 'd345', 'defaultCost': 300, 'defaultNetCost': 0, 'paymentTypes': [ @@ -3127,9 +3133,9 @@ class TestVersion5(unittest.TestCase): 'deliveryServices': [], 'defaultForCrm': 'false' }, - 'xhxij': { + 'example-code': { 'name': '1s0ei', - 'code': 'xhxij', + 'code': 'example-code', 'defaultCost': 300, 'defaultNetCost': 0, 'paymentTypes': [ @@ -3141,7 +3147,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.delivery_types() @@ -3156,15 +3162,15 @@ class TestVersion5(unittest.TestCase): V5 Test method delivery_types_edit """ - delivery_type = {'code': 'xhxij', 'name': '1s0ei'} + delivery_type = {'code': 'example-code', 'name': '1s0ei'} - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/delivery-types/' + delivery_type['code']+ '/edit') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('deliveryType', delivery_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/delivery-types/' + delivery_type['code'] + '/edit') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('deliveryType', delivery_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.delivery_types_edit(delivery_type) pook.off() @@ -3175,7 +3181,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_legal_entities(self): """ - V5 Test method legal_entitiess + V5 Test method legal_entities """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/legal-entities') @@ -3200,7 +3206,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.legal_entities() @@ -3223,12 +3229,12 @@ class TestVersion5(unittest.TestCase): } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/legal-entities/' + legal['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('legalEntity', legal)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('legalEntity', legal)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.legal_entities_edit(legal) pook.off() @@ -3239,7 +3245,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_mg_channels(self): """ - V5 Test method mg_channels + V5 Test method mg_channels """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/mg-channels') @@ -3264,7 +3270,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.mg_channels() @@ -3276,7 +3282,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_order_methods(self): """ - V5 Test method order_methods + V5 Test method order_methods """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/order-methods') @@ -3288,22 +3294,22 @@ class TestVersion5(unittest.TestCase): 'success': 'true', 'orderMethods': { '44cmd': { - 'name': '1tdf4', - 'code': '44cmd', - 'defaultForCrm': 'false', - 'defaultForApi': 'false', - 'isFromPos': 'false' + 'name': '1tdf4', + 'code': '44cmd', + 'defaultForCrm': 'false', + 'defaultForApi': 'false', + 'isFromPos': 'false' }, 'zoc5q': { - 'name': '1y0cp', - 'code': 'zoc5q', - 'defaultForCrm': 'false', - 'defaultForApi': 'false', - 'isFromPos': 'false' + 'name': '1y0cp', + 'code': 'zoc5q', + 'defaultForCrm': 'false', + 'defaultForApi': 'false', + 'isFromPos': 'false' } } } - ) + ) ) response = self.client.order_methods() @@ -3321,12 +3327,12 @@ class TestVersion5(unittest.TestCase): method = {'code': 'zoc5q', 'name': '1y0cp'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/order-methods/' + method['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orderMethod', method)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orderMethod', method)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_methods_edit(method) pook.off() @@ -3348,9 +3354,9 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'orderTypes': { - 'tttt': { + 'example-code': { 'name': 'test', - 'code': 'tttt', + 'code': 'example-code', 'defaultForCrm': 'true', 'defaultForApi': 'true', 'ordering': 990 @@ -3364,7 +3370,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.order_types() @@ -3379,15 +3385,15 @@ class TestVersion5(unittest.TestCase): V5 Test method order_types_edit """ - order_type = {'code': 'tttt', 'name': 'test'} + order_type = {'code': 'example-code', 'name': 'test'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/order-types/' + order_type['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('orderType', order_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('orderType', order_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.order_types_edit(order_type) pook.off() @@ -3398,11 +3404,11 @@ class TestVersion5(unittest.TestCase): @pook.on def test_payment_statuses(self): """ - V5 Test method payment_statuses + V5 Test method payment_statuses """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/payment-statuses') - .headers({ 'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(200) .headers(self.__header) .json( @@ -3441,7 +3447,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.payment_statuses() @@ -3459,12 +3465,12 @@ class TestVersion5(unittest.TestCase): status = {'code': 'payment-start', 'name': 'Платеж проведен'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/payment-statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('paymentStatus', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('paymentStatus', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.payment_statuses_edit(status) pook.off() @@ -3475,7 +3481,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_payment_types(self): """ - V5 Test method payment_types + V5 Test method payment_types """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/payment-types') @@ -3504,7 +3510,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.payment_types() @@ -3522,12 +3528,12 @@ class TestVersion5(unittest.TestCase): payment_type = {'code': '238c06', 'name': 'TestPaymentType-238c06'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/payment-types/' + payment_type['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('paymentType', payment_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('paymentType', payment_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.payment_types_edit(payment_type) pook.off() @@ -3538,7 +3544,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_price_types(self): """ - V5 Test method price_types + V5 Test method price_types """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/price-types') @@ -3571,7 +3577,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.price_types() @@ -3598,12 +3604,12 @@ class TestVersion5(unittest.TestCase): } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/price-types/' + price_type['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('priceTypes', price_type)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('priceTypes', price_type)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.price_types_edit(price_type) pook.off() @@ -3614,7 +3620,7 @@ class TestVersion5(unittest.TestCase): @pook.on def test_product_statuses(self): """ - V5 Test method product_statuses + V5 Test method product_statuses """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/reference/product-statuses') @@ -3641,7 +3647,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.product_statuses() @@ -3659,12 +3665,12 @@ class TestVersion5(unittest.TestCase): status = {'code': 'in-reserve', 'name': 'В резерве'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/product-statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('productStatus', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('productStatus', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.product_statuses_edit(status) pook.off() @@ -3699,7 +3705,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.sites() @@ -3717,12 +3723,12 @@ class TestVersion5(unittest.TestCase): site = {'code': 'code', 'name': 'XXX'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/sites/' + site['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('site', site)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('site', site)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.sites_edit(site) pook.off() @@ -3768,7 +3774,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.status_groups() @@ -3805,7 +3811,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.statuses() @@ -3823,12 +3829,12 @@ class TestVersion5(unittest.TestCase): status = {'code': 'new', 'name': 'Новый'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/statuses/' + status['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('status', status)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('status', status)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.statuses_edit(status) pook.off() @@ -3860,11 +3866,11 @@ class TestVersion5(unittest.TestCase): 'type': 'store-type-warehouse', 'inventoryType': 'integer', 'code': 'q6w5i', - 'name': 'uutgj' + 'name': 's344' } ] } - ) + ) ) response = self.client.stores() @@ -3879,15 +3885,15 @@ class TestVersion5(unittest.TestCase): V5 Test method stores_edit """ - store = {'code': 'q6w5i', 'name': 'uutgj'} + store = {'code': 'q6w5i', 'name': 's234f'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/stores/' + store['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('store', store)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('store', store)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.stores_edit(store) pook.off() @@ -3925,7 +3931,7 @@ class TestVersion5(unittest.TestCase): } } } - ) + ) ) response = self.client.units() @@ -3949,12 +3955,12 @@ class TestVersion5(unittest.TestCase): } (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/reference/units/' + units['code'] + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('units', units)) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('units', units)) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.units_edit(units) pook.off() @@ -3979,7 +3985,7 @@ class TestVersion5(unittest.TestCase): 'segments': [ { 'id': 34, - 'code': 'pol-ne-ukazan', + 'code': 'no-sex', 'name': 'Пол не указан', 'createdAt': '2018-04-10 12:34:30', 'isDynamic': 'true', @@ -3988,8 +3994,8 @@ class TestVersion5(unittest.TestCase): }, { 'id': 33, - 'code': 'genshchini', - 'name': 'Женщины', + 'code': 'women', + 'name': 'Women', 'createdAt': '2018-04-10 12:34:30', 'isDynamic': 'true', 'customersCount': 0, @@ -3997,7 +4003,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.segments({'active': 'true'}) @@ -4014,7 +4020,7 @@ class TestVersion5(unittest.TestCase): (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/store/inventories') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .params({'filter[site]' : 'https://retailcrm.ru'}) + .params({'filter[site]': 'https://retailcrm.ru'}) .reply(200) .headers(self.__header) .json( @@ -4029,7 +4035,7 @@ class TestVersion5(unittest.TestCase): 'offers': [ { 'id': 33937, - 'externalId': 'werew', + 'externalId': '89387', 'site': 'https://retailcrm.ru', 'quantity': 102 }, @@ -4041,7 +4047,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.inventories({'site': 'https://retailcrm.ru'}) @@ -4056,7 +4062,7 @@ class TestVersion5(unittest.TestCase): V5 Test method inventories_upload """ - offer = {'externalId': 'werew', 'id': 33937} + offer = {'externalId': '89387', 'id': 33937} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/store/inventories/upload') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) @@ -4068,12 +4074,12 @@ class TestVersion5(unittest.TestCase): 'success': 'true', 'processedOffersCount': 0, 'notFoundOffers': { - 'externalId': 'werew', + 'externalId': '89387', 'id': 33937, 'xmlId': 9999 } } - ) + ) ) response = self.client.inventories_upload(offer) @@ -4088,7 +4094,7 @@ class TestVersion5(unittest.TestCase): V5 Test method prices_upload """ - price = [{'price': 999, 'externalId': 'werew'}] + price = [{'price': 999, 'externalId': '89387'}] (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/store/prices/upload') .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) @@ -4101,11 +4107,11 @@ class TestVersion5(unittest.TestCase): 'processedOffersCount': 0, 'notFoundOffers': [ { - 'externalId': 'xxxxx' + 'externalId': 'x2342' } ] } - ) + ) ) response = self.client.prices_upload(price) @@ -4151,7 +4157,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.product_groups({'active': 'true'}) @@ -4195,12 +4201,12 @@ class TestVersion5(unittest.TestCase): 'manufacturer': 'asdas', 'offers': [ { - 'name': 'sdfsdf', + 'name': 'example', 'price': 100, 'images': [], 'id': 33937, - 'externalId': 'werew', - 'article': 'ewrwrew', + 'externalId': '89387', + 'article': 'x3421', 'prices': [ { 'priceType': 'base', @@ -4225,7 +4231,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.products({'active': 'true'}) @@ -4285,7 +4291,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.products_properties({'active': 'true'}) @@ -4336,7 +4342,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.tasks({'performers': '15'}) @@ -4349,16 +4355,16 @@ class TestVersion5(unittest.TestCase): """ V5 Test method task_create """ - - (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/tasks/create') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('task', self.__task)) - .reply(201) - .headers(self.__header) - .json({'success': 'true', 'id': 434}) - ) - response = self.client.task_create( self.__task) + (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/tasks/create') + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('task', self.__task)) + .reply(201) + .headers(self.__header) + .json({'success': 'true', 'id': 434}) + ) + + response = self.client.task_create(self.__task) pook.off() self.assertTrue(response.is_successful(), True) @@ -4370,14 +4376,14 @@ class TestVersion5(unittest.TestCase): V5 Test method task """ - uid = str( self.__task['id']) + uid = str(self.__task['id']) (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/tasks/' + uid) - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'task' : self.__task}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'task': self.__task}) + ) response = self.client.task(uid) pook.off() @@ -4394,12 +4400,12 @@ class TestVersion5(unittest.TestCase): uid = str(self.__task['id']) (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/tasks/' + uid + '/edit') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('task', self.__task)) - .reply(200) - .headers(self.__header) - .json({'success': 'true', 'id': '433', 'task': self.__task}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('task', self.__task)) + .reply(200) + .headers(self.__header) + .json({'success': 'true', 'id': '433', 'task': self.__task}) + ) response = self.client.task_edit(self.__task) pook.off() @@ -4413,17 +4419,17 @@ class TestVersion5(unittest.TestCase): V5 Test method telephony_call_event """ - call_event = {'phone': '+799999999','type': 'out'} + call_event = {'phone': '+799999999', 'type': 'out'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/telephony/call/event') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('event', call_event)) - .reply(200) - .headers(self.__header) - .json({'success': 'false', 'errorMsg': 'Telephony not enabled'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('event', call_event)) + .reply(200) + .headers(self.__header) + .json({'success': 'false', 'errorMsg': 'Telephony not enabled'}) + ) - response = self.client.telephony_call_event(call_event) + response = self.client.telephony_call_event(call_event) pook.off() self.assertTrue(response.is_successful(), True) @@ -4438,15 +4444,15 @@ class TestVersion5(unittest.TestCase): call = {'phone': '79999999999', 'type': 'out'} (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/telephony/calls/upload') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body(self.dictionaryEncode('calls', call)) - .reply(200) - .headers(self.__header) - .json({'success': 'false', 'errorMsg': 'Telephony not enabled or not supports calls upload'} - ) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body(self.dictionaryEncode('calls', call)) + .reply(200) + .headers(self.__header) + .json({'success': 'false', 'errorMsg': 'Telephony not enabled or not supports calls upload'} + ) + ) - response = self.client.telephony_calls_upload(call) + response = self.client.telephony_calls_upload(call) pook.off() self.assertTrue(response.is_successful(), True) @@ -4467,19 +4473,19 @@ class TestVersion5(unittest.TestCase): { 'success': 'true', 'manager': { - 'id': 777, - 'firstName': 'yyy', - 'lastName': 'xxxx', - 'patronymic': 'qwer', + 'id': 777, + 'firstName': 'John', + 'lastName': 'Doe', + 'patronymic': 'H.', 'email': 'mail@retailcrm.ru', 'code': 'ccc7' }, 'customer': { 'id': 888, - 'externalId': '5406', - 'firstName': 'ccc', - 'lastName': 'zzzz', - 'patronymic': 'asdf', + 'externalId': '5406', + 'firstName': 'John', + 'lastName': 'Doe', + 'patronymic': 'H.', 'email': 'mail@retailcrm.ru', 'code': 'ccc7', 'phones': [{'number': '+71111111111'}] @@ -4489,9 +4495,9 @@ class TestVersion5(unittest.TestCase): 'lastOrderLink': 'https://lastOrderLink.ru', 'newCustomerLink': 'https://newCustomerLink.ru', 'customerLink': 'https://customerLink.ru', - } + } } - ) + ) ) response = self.client.telephony_manager('+79999999999') @@ -4528,6 +4534,8 @@ class TestVersion5(unittest.TestCase): 'isDeliveryMen': 'false', 'deliveryTypes': [], 'breakdownOrderTypes': ['xxx', 'yyy', 'zzz'], + }, + { 'name': 'Руководители', 'code': 'director', 'isManager': 'false', @@ -4541,7 +4549,7 @@ class TestVersion5(unittest.TestCase): } ] } - ) + ) ) response = self.client.user_groups() @@ -4584,9 +4592,9 @@ class TestVersion5(unittest.TestCase): 'isManager': 'false', 'groups': [] } - ] + ] } - ) + ) ) response = self.client.users({'status': 'online', 'isManager': 'false'}) @@ -4603,7 +4611,7 @@ class TestVersion5(unittest.TestCase): uid = '777' - (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/users/' +uid) + (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/users/' + uid) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .reply(200) .headers(self.__header) @@ -4624,7 +4632,7 @@ class TestVersion5(unittest.TestCase): 'groups': [] } } - ) + ) ) response = self.client.user(uid) @@ -4642,12 +4650,12 @@ class TestVersion5(unittest.TestCase): uid = '777' (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/users/' + uid + '/status') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .body('status=free') - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .body('status=free') + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.user_status(uid, 'free') pook.off() @@ -4662,11 +4670,11 @@ class TestVersion5(unittest.TestCase): """ (pook.get(os.getenv('RETAILCRM_URL') + '/api/v5/statistic/update') - .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) - .reply(200) - .headers(self.__header) - .json({'success': 'true'}) - ) + .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) + .reply(200) + .headers(self.__header) + .json({'success': 'true'}) + ) response = self.client.statistic_update() pook.off()