Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Commit 71b7c20

Browse files
authored
Merge pull request #19 from hellofresh/feature/python-3
Add support to python 3.7
2 parents be741f2 + 61f2ab7 commit 71b7c20

File tree

10 files changed

+90
-40
lines changed

10 files changed

+90
-40
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
language: python
2+
sudo: required
3+
dist: xenial
24
python:
35
- "2.7"
4-
- "3.3"
56
- "3.4"
67
- "3.5"
78
- "3.6"
9+
- "3.7"
810

911
install:
10-
- make build
12+
- make setup
1113

1214
script:
13-
- make test
14-
- codecov
15+
- make test-unit

Makefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
help:
22
@echo "Please use \`make <target>' where <target> is one of"
33
@echo " test to run unit tests"
4-
@echo " build to install requirements for development"
4+
@echo " setup to install requirements for development"
5+
@echo " build to create a build directory for deployment"
56

6-
build: requirements test-requirements
7+
build:
8+
@printf "$(OK_COLOR)==> Building$(NO_COLOR)\n"
9+
@mkdir -p "${BUILD_DIR}"
10+
@for SOURCE in crossengage setup.py; do \
11+
cp -r "$${SOURCE}" "${BUILD_DIR}/$${SOURCE}"; \
12+
done
713

8-
test: unittests
14+
setup: clean virtualenv requirements test-requirements
915

10-
unittests:
11-
PYTHONPATH=$(CURDIR) nosetests -d -w tests -v --with-coverage --cover-package ./crossengage
16+
test-unit:
17+
. $(CURDIR)/env/bin/activate; \
18+
tox
19+
20+
virtualenv:
21+
virtualenv $(CURDIR)/env
22+
23+
clean:
24+
rm -rf $(CURDIR)/env
1225

1326
requirements:
14-
pip install -r requirements.txt
27+
$(CURDIR)/env/bin/python setup.py develop
1528

1629
test-requirements:
17-
pip install -r test-requirements.txt
30+
$(CURDIR)/env/bin/pip install tox

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Library supports next methods:
3939

4040
### How to install
4141

42-
Make sure you have Python 2.7.11+ installed and run:
42+
Make sure you have Python 2.7.11+ or Python 3.4+ installed and run:
4343

4444
```
4545
$ git clone git@github.com:hellofresh/crossengage-python-client.git
@@ -66,9 +66,9 @@ response = client.update_user(user={
6666
})
6767

6868
if response['success']:
69-
print 'Create / Update Successful!'
69+
print('Create / Update Successful!')
7070
else:
71-
print response['errors']
71+
print(response['errors'])
7272

7373
```
7474
For more examples, check `examples.py`.
@@ -77,4 +77,4 @@ For more examples, check `examples.py`.
7777

7878
To run the unit tests, make sure you have the [nose](http://nose.readthedocs.org/) module instaled and run the following from the repository root directory:
7979

80-
`$ make build && make test`
80+
`$ make setup && make test`

crossengage/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import absolute_import
2+
13
import json
24
import logging
35

@@ -6,6 +8,7 @@
68

79
from crossengage.utils import update_dict
810

11+
912
class CrossengageClient(object):
1013
"""
1114
Client for Crossengage public API. Support create_user, update_user, delete_user, create_attribute,

examples.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
})
1515

1616
if response['success']:
17-
print 'Create / Update Successful!'
17+
print('Create / Update Successful!')
1818
else:
19-
print response['errors']
19+
print(response['errors'])
2020

2121
# 2. Bulk create - update
2222
user1 = {
@@ -43,17 +43,17 @@
4343
response = client.update_users_bulk(users=users)
4444
for data in response['updated']:
4545
if data['success']:
46-
print 'BULK #' + data['id'] + ' success'
46+
print('BULK #' + data['id'] + ' success')
4747
else:
48-
print 'BULK #' + data['id'] + ' FAIL'
49-
print data['errors']
48+
print('BULK #' + data['id'] + ' FAIL')
49+
print(data['errors'])
5050

5151
# 3. Delete user
5252
response = client.delete_user(user={'id': '1'})
5353
if response['status_code'] == 204:
54-
print '#1 Deleted successful!'
54+
print('#1 Deleted successful!')
5555
else:
56-
print 'Something went wrong via DELETE request'
56+
print('Something went wrong via DELETE request')
5757

5858
# 4. Trying to update with invalid field, API should return error
5959
response = client.update_user(user={
@@ -68,25 +68,25 @@
6868
})
6969

7070
if response['success']:
71-
print '# 1 Updated with invalid fields successful!'
71+
print('# 1 Updated with invalid fields successful!')
7272
else:
73-
print response['errors']
73+
print(response['errors'])
7474

7575
# 5. Add new user attributes
7676
response = client.add_user_attribute('silos', client.ATTRIBUTE_ARRAY, client.ATTRIBUTE_STRING)
7777

7878
if response['success']:
79-
print 'Added user attribute `silos` successful!'
79+
print('Added user attribute `silos` successful!')
8080
else:
81-
print response['errors']
81+
print(response['errors'])
8282

8383
# 6. List user attributes
8484
response = client.list_user_attributes(offset=37, limit=10)
8585
if response['status_code'] == 200:
86-
print 'Got list user attributes successful!'
87-
print response['attributes']
86+
print('Got list user attributes successful!')
87+
print(response['attributes'])
8888
else:
89-
print response['errors']
89+
print(response['errors'])
9090

9191
# 7. Add nested attribute
92-
print client.add_nested_user_attribute('nested_attribute', 'main_attribute', client.ATTRIBUTE_STRING)
92+
print(client.add_nested_user_attribute('nested_attribute', 'main_attribute', client.ATTRIBUTE_STRING))

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
from setuptools import setup, find_packages
22

33
NAME = "crossengage-client"
4-
VERSION = "1.1.1"
4+
VERSION = "1.2.0"
55

6-
REQUIRES = []
6+
REQUIRES = [
7+
'requests==2.20.1',
8+
]
9+
10+
EXTRAS = {
11+
'dev': [
12+
'tox',
13+
],
14+
}
715

816
setup(
917
name=NAME,
1018
version=VERSION,
11-
description="Crossengage python client",
19+
description="Crossengage Python Client",
1220
author_email="azh@hellofresh.com",
1321
keywords=["HelloFresh", "Crossengage", "CRM"],
1422
install_requires=REQUIRES,
15-
packages=find_packages()
23+
extras_require=EXTRAS,
24+
packages=find_packages(exclude=('tests',)),
25+
license='MIT',
26+
classifiers=[
27+
'License :: OSI Approved :: MIT License',
28+
'Programming Language :: Python',
29+
'Programming Language :: Python :: 2.7',
30+
'Programming Language :: Python :: 3.7',
31+
],
1632
)

test-requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from crossengage.utils import update_dict
44

5+
56
class TestUtils(unittest.TestCase):
67

78
def test_update_dict(self):
@@ -11,4 +12,3 @@ def test_update_dict(self):
1112

1213
self.assertEqual(dict(a=1, b=2), old_dict)
1314
self.assertEqual(dict(a=2, b=3, c=4), new_dict)
14-

tox.ini

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[tox]
2+
envlist = style, unit
3+
4+
# Configs
5+
[pytest]
6+
addopts = -p no:warnings
7+
8+
# Local Unit
9+
[testenv:unit]
10+
deps =
11+
codecov
12+
mock
13+
pytest
14+
pytest-cov
15+
pytest-mock
16+
commands =
17+
pytest tests
18+
19+
# Codestyle
20+
[testenv:style]
21+
deps = flake8
22+
commands = flake8 --max-line-length=120 crossengage

0 commit comments

Comments
 (0)