mirror of
https://github.com/retailcrm/api-client-python.git
synced 2024-11-21 12:36:02 +03:00
Gh actions (#22)
This commit is contained in:
parent
e3e3de9e4b
commit
d420bdb0b3
67
.github/workflows/ci.yml
vendored
Normal file
67
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags-ignore:
|
||||
- '*.*'
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
RETAILCRM_URL: https://test.retailcrm.pro
|
||||
RETAILCRM_KEY: key
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.5, 3.6, 3.7]
|
||||
include:
|
||||
- python-version: '3.8'
|
||||
coverage: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --ignore=F401
|
||||
- name: Tests
|
||||
env:
|
||||
COVERAGE: ${{ matrix.coverage }}
|
||||
if: env.COVERAGE != 1
|
||||
run: nosetests -v
|
||||
- name: Tests with coverage
|
||||
env:
|
||||
COVERAGE: ${{ matrix.coverage }}
|
||||
if: env.COVERAGE == 1
|
||||
run: |
|
||||
nosetests -v --with-coverage --cover-xml
|
||||
- name: Coverage
|
||||
env:
|
||||
COVERAGE: ${{ matrix.coverage }}
|
||||
if: env.COVERAGE == 1
|
||||
run: |
|
||||
bash <(curl -s https://codecov.io/bash)
|
||||
rm .coverage coverage.xml
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -5,4 +5,7 @@
|
||||
/dist/
|
||||
/venv/
|
||||
/.vscode/
|
||||
/build/
|
||||
/build/
|
||||
.python-version
|
||||
.coverage
|
||||
coverage.xml
|
13
.travis.yml
13
.travis.yml
@ -1,13 +0,0 @@
|
||||
language: python
|
||||
python:
|
||||
- '3.4'
|
||||
- '3.5'
|
||||
- '3.6'
|
||||
- '3.7'
|
||||
- '3.8'
|
||||
before_install:
|
||||
- pip install -r requirements.txt
|
||||
script:
|
||||
- nosetests -v --with-coverage --cover-xml
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
@ -2,4 +2,4 @@
|
||||
|
||||
"""
|
||||
Init
|
||||
"""
|
||||
"""
|
||||
|
@ -469,7 +469,7 @@ class Client(Base):
|
||||
"""
|
||||
if site is not None:
|
||||
self.parameters['site'] = site
|
||||
|
||||
|
||||
self.parameters['offers'] = json.dumps(offers)
|
||||
|
||||
return self.post('/store/inventories/upload')
|
||||
@ -532,5 +532,5 @@ class Client(Base):
|
||||
"""
|
||||
:return: Response
|
||||
"""
|
||||
|
||||
|
||||
return self.get('/statistic/update')
|
||||
|
@ -504,11 +504,15 @@ class Client(Base):
|
||||
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("".join(
|
||||
[
|
||||
'/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):
|
||||
"""
|
||||
@ -575,8 +579,7 @@ class Client(Base):
|
||||
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):
|
||||
"""
|
||||
@ -643,8 +646,7 @@ class Client(Base):
|
||||
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):
|
||||
"""
|
||||
|
3
setup.py
3
setup.py
@ -15,7 +15,7 @@ def read(filename):
|
||||
|
||||
setup(
|
||||
name='retailcrm',
|
||||
version='5.1.0',
|
||||
version='5.1.1',
|
||||
description='RetailCRM API client',
|
||||
long_description=read('README'),
|
||||
url='https://github.com/retailcrm/api-client-python',
|
||||
@ -34,7 +34,6 @@ setup(
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
|
@ -111,8 +111,7 @@ class TestVersion3(unittest.TestCase):
|
||||
Setup
|
||||
"""
|
||||
|
||||
self.client = retailcrm.v3(
|
||||
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
|
||||
self.client = retailcrm.v3(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
|
||||
|
||||
@staticmethod
|
||||
def dictionaryEncode(key, dictionary):
|
||||
@ -1509,13 +1508,7 @@ 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(
|
||||
{
|
||||
'hangupStatus': 'busy',
|
||||
'phone': '+799999999',
|
||||
'code': 'c2321',
|
||||
'type': 'hangup'
|
||||
}))
|
||||
.body(urlencode({'hangupStatus': 'busy', 'phone': '+799999999', 'code': 'c2321', 'type': 'hangup'}))
|
||||
.reply(200)
|
||||
.headers(self.__header)
|
||||
.json({'success': 'true'})
|
||||
@ -1609,21 +1602,20 @@ 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(
|
||||
{
|
||||
'code': code,
|
||||
'clientId': '123x',
|
||||
'makeCallUrl': 'url',
|
||||
'active': 'active',
|
||||
'name': 'name',
|
||||
'image': 'url_image'
|
||||
}))
|
||||
.reply(201)
|
||||
.headers(self.__header)
|
||||
.json({'success': 'true'})
|
||||
)
|
||||
(
|
||||
pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/settings/' + code)
|
||||
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
|
||||
.body(urlencode({
|
||||
'code': code,
|
||||
'clientId': '123x',
|
||||
'makeCallUrl': 'url',
|
||||
'active': 'active',
|
||||
'name': 'name',
|
||||
'image': 'url_image'}))
|
||||
.reply(201)
|
||||
.headers(self.__header)
|
||||
.json({'success': 'true'})
|
||||
)
|
||||
|
||||
response = self.client.telephony_settings(code, '123x', 'url', 'active', 'name', 'url_image')
|
||||
pook.off()
|
||||
|
@ -107,8 +107,7 @@ class TestVersion4(unittest.TestCase):
|
||||
Setup
|
||||
"""
|
||||
|
||||
self.client = retailcrm.v4(
|
||||
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
|
||||
self.client = retailcrm.v4(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
|
||||
|
||||
@staticmethod
|
||||
def dictionaryEncode(key, dictionary):
|
||||
@ -310,11 +309,11 @@ 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()
|
||||
|
||||
@ -710,11 +709,11 @@ 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()
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
|
||||
"""
|
||||
RetailCRM API client v5 tests
|
||||
"""
|
||||
@ -189,8 +188,7 @@ class TestVersion5(unittest.TestCase):
|
||||
Setup
|
||||
"""
|
||||
|
||||
self.client = retailcrm.v5(
|
||||
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
|
||||
self.client = retailcrm.v5(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
|
||||
|
||||
@staticmethod
|
||||
def dictionaryEncode(key, dictionary):
|
||||
@ -413,7 +411,7 @@ class TestVersion5(unittest.TestCase):
|
||||
self.assertTrue(response.get_status_code() < 400, True)
|
||||
|
||||
@pook.on
|
||||
def test_costs_delete(self):
|
||||
def test_costs_delete_v5(self):
|
||||
"""
|
||||
V5 Test method costs_delete
|
||||
"""
|
||||
@ -617,17 +615,18 @@ class TestVersion5(unittest.TestCase):
|
||||
'elements': [{'name': 'fear', 'code': 'e456'}]
|
||||
}
|
||||
|
||||
(pook.post(
|
||||
os.getenv('RETAILCRM_URL') +
|
||||
'/api/v5/custom-fields/dictionaries/' +
|
||||
custom_dictionary['code'] +
|
||||
'/edit')
|
||||
(pook.post("".join(
|
||||
[
|
||||
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'})
|
||||
)
|
||||
.json({'success': 'true', 'code': 'test'}))
|
||||
|
||||
response = self.client.custom_dictionary_edit(custom_dictionary)
|
||||
pook.off()
|
||||
@ -883,12 +882,13 @@ 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()
|
||||
|
||||
self.assertTrue(response.is_successful(), True)
|
||||
@ -1145,7 +1145,7 @@ class TestVersion5(unittest.TestCase):
|
||||
self.assertTrue(response.get_status_code() < 400, True)
|
||||
|
||||
@pook.on
|
||||
def test_customers_history(self):
|
||||
def test_customers_history_v5(self):
|
||||
"""
|
||||
V5 Test method customers_corporate_history
|
||||
"""
|
||||
@ -1199,11 +1199,11 @@ 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()
|
||||
|
||||
@ -1364,7 +1364,7 @@ class TestVersion5(unittest.TestCase):
|
||||
'success': 'true',
|
||||
'addresses': [{
|
||||
'id': 3995,
|
||||
'text': '123123, Russian Federation, Moscow, Kutuzovski 14',
|
||||
'text': '123123, Russian Federation, Moscow, Kubuntu 14',
|
||||
'isMain': 'true',
|
||||
'name': 'Test'
|
||||
}],
|
||||
@ -1392,15 +1392,12 @@ 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')
|
||||
(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})
|
||||
)
|
||||
.json({'success': 'true', 'id': 9717}))
|
||||
|
||||
response = self.client.customer_corporate_addresses_create(address)
|
||||
pook.off()
|
||||
@ -1496,9 +1493,7 @@ 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')
|
||||
(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)
|
||||
@ -1588,9 +1583,7 @@ 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')
|
||||
(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)
|
||||
@ -1670,8 +1663,7 @@ 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(
|
||||
'statusUpdate', delivery_id))
|
||||
.body(self.dictionaryEncode('statusUpdate', delivery_id))
|
||||
.reply(200)
|
||||
.headers(self.__header)
|
||||
.json({'success': 'true'})
|
||||
@ -2007,30 +1999,29 @@ class TestVersion5(unittest.TestCase):
|
||||
'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'
|
||||
}
|
||||
]
|
||||
}
|
||||
'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'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
@ -2262,11 +2253,11 @@ 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()
|
||||
|
||||
@ -2470,7 +2461,7 @@ class TestVersion5(unittest.TestCase):
|
||||
self.assertTrue(response.get_status_code() < 400, True)
|
||||
|
||||
@pook.on
|
||||
def test_orders_statuses(self):
|
||||
def test_orders_statuses_v5(self):
|
||||
"""
|
||||
V5 Test method orders_statuses
|
||||
"""
|
||||
@ -2502,7 +2493,7 @@ class TestVersion5(unittest.TestCase):
|
||||
self.assertTrue(response.get_status_code() < 400, True)
|
||||
|
||||
@pook.on
|
||||
def test_orders_upload(self):
|
||||
def test_orders_upload_v5(self):
|
||||
"""
|
||||
V5 Test method orders_upload
|
||||
"""
|
||||
@ -2533,7 +2524,7 @@ class TestVersion5(unittest.TestCase):
|
||||
self.assertTrue(response.get_status_code() < 400, True)
|
||||
|
||||
@pook.on
|
||||
def test_order(self):
|
||||
def test_order_v5(self):
|
||||
"""
|
||||
V5 Test method order
|
||||
"""
|
||||
@ -4670,11 +4661,10 @@ 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()
|
||||
|
Loading…
Reference in New Issue
Block a user