Gh actions (#22)

This commit is contained in:
Alex Lushpai 2020-12-18 01:01:56 +03:00 committed by GitHub
parent e3e3de9e4b
commit d420bdb0b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 173 additions and 134 deletions

67
.github/workflows/ci.yml vendored Normal file
View 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

3
.gitignore vendored
View File

@ -6,3 +6,6 @@
/venv/ /venv/
/.vscode/ /.vscode/
/build/ /build/
.python-version
.coverage
coverage.xml

View File

@ -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)

View File

@ -504,11 +504,15 @@ class Client(Base):
if site is not None: if site is not None:
self.parameters['site'] = site self.parameters['site'] = site
return self.post('/customers-corporate/' + return self.post("".join(
str(uid_corporate) + [
'/addresses/' + '/customers-corporate/',
str(address[entity_by]) + str(uid_corporate),
'/edit') '/addresses/',
str(address[entity_by]),
'/edit'
]
))
def customer_corporate_companies(self, uid, uid_type='externalId', limit=20, page=1, filters=None, site=None): 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: if site is not None:
self.parameters['site'] = site self.parameters['site'] = site
return self.post('/customers-corporate/' + return self.post('/customers-corporate/' + str(uid_corporate) + '/companies/' + str(company[entity_by]) + '/edit')
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): 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: if site is not None:
self.parameters['site'] = site self.parameters['site'] = site
return self.post('/customers-corporate/' + return self.post('/customers-corporate/' + str(uid_corporate) + '/contacts/' + str(contact[entity_by]) + '/edit')
str(uid_corporate) + '/contacts/' + str(contact[entity_by]) + '/edit')
def customer_corporate_edit(self, customer_corporate, uid_type='externalId', site=None): def customer_corporate_edit(self, customer_corporate, uid_type='externalId', site=None):
""" """

View File

@ -15,7 +15,7 @@ def read(filename):
setup( setup(
name='retailcrm', name='retailcrm',
version='5.1.0', version='5.1.1',
description='RetailCRM API client', description='RetailCRM API client',
long_description=read('README'), long_description=read('README'),
url='https://github.com/retailcrm/api-client-python', url='https://github.com/retailcrm/api-client-python',
@ -34,7 +34,6 @@ setup(
'Operating System :: OS Independent', 'Operating System :: OS Independent',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.7',

View File

@ -111,8 +111,7 @@ class TestVersion3(unittest.TestCase):
Setup Setup
""" """
self.client = retailcrm.v3( self.client = retailcrm.v3(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
@staticmethod @staticmethod
def dictionaryEncode(key, dictionary): def dictionaryEncode(key, dictionary):
@ -1509,13 +1508,7 @@ class TestVersion3(unittest.TestCase):
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/call/event') (pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/call/event')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(urlencode( .body(urlencode({'hangupStatus': 'busy', 'phone': '+799999999', 'code': 'c2321', 'type': 'hangup'}))
{
'hangupStatus': 'busy',
'phone': '+799999999',
'code': 'c2321',
'type': 'hangup'
}))
.reply(200) .reply(200)
.headers(self.__header) .headers(self.__header)
.json({'success': 'true'}) .json({'success': 'true'})
@ -1609,17 +1602,16 @@ class TestVersion3(unittest.TestCase):
code = 'xxx' code = 'xxx'
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/settings/' + code) (
pook.post(os.getenv('RETAILCRM_URL') + '/api/v3/telephony/settings/' + code)
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(urlencode( .body(urlencode({
{
'code': code, 'code': code,
'clientId': '123x', 'clientId': '123x',
'makeCallUrl': 'url', 'makeCallUrl': 'url',
'active': 'active', 'active': 'active',
'name': 'name', 'name': 'name',
'image': 'url_image' 'image': 'url_image'}))
}))
.reply(201) .reply(201)
.headers(self.__header) .headers(self.__header)
.json({'success': 'true'}) .json({'success': 'true'})

View File

@ -107,8 +107,7 @@ class TestVersion4(unittest.TestCase):
Setup Setup
""" """
self.client = retailcrm.v4( self.client = retailcrm.v4(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
@staticmethod @staticmethod
def dictionaryEncode(key, dictionary): def dictionaryEncode(key, dictionary):

View File

@ -1,6 +1,5 @@
# coding=utf-8 # coding=utf-8
""" """
RetailCRM API client v5 tests RetailCRM API client v5 tests
""" """
@ -189,8 +188,7 @@ class TestVersion5(unittest.TestCase):
Setup Setup
""" """
self.client = retailcrm.v5( self.client = retailcrm.v5(os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
os.getenv('RETAILCRM_URL'), os.getenv('RETAILCRM_KEY'))
@staticmethod @staticmethod
def dictionaryEncode(key, dictionary): def dictionaryEncode(key, dictionary):
@ -413,7 +411,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True) self.assertTrue(response.get_status_code() < 400, True)
@pook.on @pook.on
def test_costs_delete(self): def test_costs_delete_v5(self):
""" """
V5 Test method costs_delete V5 Test method costs_delete
""" """
@ -617,17 +615,18 @@ class TestVersion5(unittest.TestCase):
'elements': [{'name': 'fear', 'code': 'e456'}] 'elements': [{'name': 'fear', 'code': 'e456'}]
} }
(pook.post( (pook.post("".join(
os.getenv('RETAILCRM_URL') + [
'/api/v5/custom-fields/dictionaries/' + os.getenv('RETAILCRM_URL'),
custom_dictionary['code'] + '/api/v5/custom-fields/dictionaries/',
'/edit') custom_dictionary['code'],
'/edit'
]))
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('customDictionary', custom_dictionary)) .body(self.dictionaryEncode('customDictionary', custom_dictionary))
.reply(200) .reply(200)
.headers(self.__header) .headers(self.__header)
.json({'success': 'true', 'code': 'test'}) .json({'success': 'true', 'code': 'test'}))
)
response = self.client.custom_dictionary_edit(custom_dictionary) response = self.client.custom_dictionary_edit(custom_dictionary)
pook.off() pook.off()
@ -889,6 +888,7 @@ class TestVersion5(unittest.TestCase):
'endDate': '2020-04-12' 'endDate': '2020-04-12'
} }
) )
pook.off() pook.off()
self.assertTrue(response.is_successful(), True) self.assertTrue(response.is_successful(), True)
@ -1145,7 +1145,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True) self.assertTrue(response.get_status_code() < 400, True)
@pook.on @pook.on
def test_customers_history(self): def test_customers_history_v5(self):
""" """
V5 Test method customers_corporate_history V5 Test method customers_corporate_history
""" """
@ -1364,7 +1364,7 @@ class TestVersion5(unittest.TestCase):
'success': 'true', 'success': 'true',
'addresses': [{ 'addresses': [{
'id': 3995, 'id': 3995,
'text': '123123, Russian Federation, Moscow, Kutuzovski 14', 'text': '123123, Russian Federation, Moscow, Kubuntu 14',
'isMain': 'true', 'isMain': 'true',
'name': 'Test' 'name': 'Test'
}], }],
@ -1392,15 +1392,12 @@ class TestVersion5(unittest.TestCase):
address = {'isMain': 'true', 'name': 'Test', 'externalId': 'cc_9'} address = {'isMain': 'true', 'name': 'Test', 'externalId': 'cc_9'}
(pook.post( (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + address['externalId'] + '/addresses/create')
os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + address[
'externalId'] + '/addresses/create')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('address', address)) .body(self.dictionaryEncode('address', address))
.reply(200) .reply(200)
.headers(self.__header) .headers(self.__header)
.json({'success': 'true', 'id': 9717}) .json({'success': 'true', 'id': 9717}))
)
response = self.client.customer_corporate_addresses_create(address) response = self.client.customer_corporate_addresses_create(address)
pook.off() pook.off()
@ -1496,9 +1493,7 @@ class TestVersion5(unittest.TestCase):
company = {'isMain': 'true', 'name': 'TestN', 'externalId': 'cc_9'} company = {'isMain': 'true', 'name': 'TestN', 'externalId': 'cc_9'}
(pook.post( (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + company['externalId'] + '/companies/create')
os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + company[
'externalId'] + '/companies/create')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('company', company)) .body(self.dictionaryEncode('company', company))
.reply(200) .reply(200)
@ -1588,9 +1583,7 @@ class TestVersion5(unittest.TestCase):
contact = {'isMain': 'true', 'name': 'TestM', 'externalId': 'cc_9'} contact = {'isMain': 'true', 'name': 'TestM', 'externalId': 'cc_9'}
(pook.post( (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + contact['externalId'] + '/contacts/create')
os.getenv('RETAILCRM_URL') + '/api/v5/customers-corporate/' + contact[
'externalId'] + '/contacts/create')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode('contact', contact)) .body(self.dictionaryEncode('contact', contact))
.reply(200) .reply(200)
@ -1670,8 +1663,7 @@ class TestVersion5(unittest.TestCase):
(pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/delivery/generic/' + code + '/tracking') (pook.post(os.getenv('RETAILCRM_URL') + '/api/v5/delivery/generic/' + code + '/tracking')
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.body(self.dictionaryEncode( .body(self.dictionaryEncode('statusUpdate', delivery_id))
'statusUpdate', delivery_id))
.reply(200) .reply(200)
.headers(self.__header) .headers(self.__header)
.json({'success': 'true'}) .json({'success': 'true'})
@ -2007,8 +1999,7 @@ class TestVersion5(unittest.TestCase):
'currentPage': '1', 'currentPage': '1',
'totalPageCount': '87' 'totalPageCount': '87'
}, },
'integrationModule': 'integrationModule': {
{
'success': 'true', 'success': 'true',
'integrationModule': { 'integrationModule': {
'code': 'xxx', 'code': 'xxx',
@ -2470,7 +2461,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True) self.assertTrue(response.get_status_code() < 400, True)
@pook.on @pook.on
def test_orders_statuses(self): def test_orders_statuses_v5(self):
""" """
V5 Test method orders_statuses V5 Test method orders_statuses
""" """
@ -2502,7 +2493,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True) self.assertTrue(response.get_status_code() < 400, True)
@pook.on @pook.on
def test_orders_upload(self): def test_orders_upload_v5(self):
""" """
V5 Test method orders_upload V5 Test method orders_upload
""" """
@ -2533,7 +2524,7 @@ class TestVersion5(unittest.TestCase):
self.assertTrue(response.get_status_code() < 400, True) self.assertTrue(response.get_status_code() < 400, True)
@pook.on @pook.on
def test_order(self): def test_order_v5(self):
""" """
V5 Test method order V5 Test method order
""" """
@ -4673,8 +4664,7 @@ class TestVersion5(unittest.TestCase):
.headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')}) .headers({'X-API-KEY': os.getenv('RETAILCRM_KEY')})
.reply(200) .reply(200)
.headers(self.__header) .headers(self.__header)
.json({'success': 'true'}) .json({'success': 'true'}))
)
response = self.client.statistic_update() response = self.client.statistic_update()
pook.off() pook.off()