Skip to content

Commit 9738892

Browse files
committed
Merge branch 'dev' into POP-2278
2 parents 15ec48f + 1e0684c commit 9738892

12 files changed

+72
-45
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
exclude=.git,.pytest_cache,venv

.github/workflows/pythonpackage.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: python-tests
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
max-parallel: 4
11+
matrix:
12+
python-version: [2.7, 3.5, 3.6, 3.7]
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -r requirements.txt
24+
- name: Lint with flake8
25+
run: |
26+
pip install flake8
27+
# stop the build if there are Python syntax errors or undefined names
28+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29+
# the GitHub editor is 127 chars wide
30+
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
31+
- name: Test with pytest
32+
run: |
33+
pip install pytest
34+
pytest

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ Linting software is strongly recommended to improve code quality and maintain re
2424

2525
Read more [here](http://flake8.pycqa.org/en/latest/)
2626

27+
To lint the files,
28+
29+
virtualenv venv
30+
. venv/bin/activate
31+
pip install flake8
32+
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
33+
deactivate
34+
2735
### Testing
2836

2937
To run the tests,

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# python-demandapi-client
2+
3+
<a href="https://github.com/dynata/python-demandapi-client"><img alt="GitHub Actions status" src="https://github.com/dynata/python-demandapi-client/workflows/python-tests/badge.svg"></a>
4+
25
A Python client library for the [Dynata Demand API](https://developers.dynata.com/)
36
## Setup
47

tests/test_attributes.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
import unittest
66
import responses
77

8-
try:
9-
from unittest.mock import patch
10-
except ImportError:
11-
from mock import patch
12-
138
from dynatademand.api import DemandAPIClient
149

1510
BASE_HOST = "http://test-url.example"

tests/test_categories.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
import unittest
66
import responses
77

8-
try:
9-
from unittest.mock import patch
10-
except ImportError:
11-
from mock import patch
12-
138
from dynatademand.api import DemandAPIClient
149

1510
BASE_HOST = "http://test-url.example"
@@ -24,7 +19,11 @@ def setUp(self):
2419
def test_get_survey_topics(self):
2520
with open('./tests/test_files/get_survey_topics.json', 'r') as survey_topics_file:
2621
survey_topics_json = json.load(survey_topics_file)
27-
responses.add(responses.GET, '{}/sample/v1/categories/surveyTopics'.format(BASE_HOST), json=survey_topics_json, status=200)
22+
responses.add(
23+
responses.GET,
24+
'{}/sample/v1/categories/surveyTopics'.format(BASE_HOST),
25+
json=survey_topics_json,
26+
status=200)
2827
self.api.get_survey_topics()
2928
self.assertEqual(len(responses.calls), 1)
3029
self.assertEqual(responses.calls[0].response.json(), survey_topics_json)

tests/test_countries.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
import unittest
66
import responses
77

8-
try:
9-
from unittest.mock import patch
10-
except ImportError:
11-
from mock import patch
12-
138
from dynatademand.api import DemandAPIClient
149

1510
BASE_HOST = "http://test-url.example"

tests/test_events.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
import unittest
66
import responses
77

8-
try:
9-
from unittest.mock import patch
10-
except ImportError:
11-
from mock import patch
12-
138
from dynatademand.api import DemandAPIClient
149

1510
BASE_HOST = "http://test-url.example"

tests/test_feasibility_pricing.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
import unittest
66
import responses
77

8-
try:
9-
from unittest.mock import patch
10-
except ImportError:
11-
from mock import patch
12-
138
from dynatademand.api import DemandAPIClient
149

1510
BASE_HOST = "http://test-url.example"

tests/test_line_items.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
import unittest
66
import responses
77

8-
try:
9-
from unittest.mock import patch
10-
except ImportError:
11-
from mock import patch
12-
138
from dynatademand.api import DemandAPIClient
149
from dynatademand.errors import DemandAPIError
1510

@@ -25,7 +20,11 @@ def setUp(self):
2520
def test_get_line_item(self):
2621
with open('./tests/test_files/get_line_item.json', 'r') as line_item_file:
2722
line_item_json = json.load(line_item_file)
28-
responses.add(responses.GET, '{}/sample/v1/projects/1/lineItems/100'.format(BASE_HOST), json=line_item_json, status=200)
23+
responses.add(
24+
responses.GET,
25+
'{}/sample/v1/projects/1/lineItems/100'.format(BASE_HOST),
26+
json=line_item_json,
27+
status=200)
2928
self.api.get_line_item(1, 100)
3029
self.assertEqual(len(responses.calls), 1)
3130
self.assertEqual(responses.calls[0].response.json(), line_item_json)
@@ -43,7 +42,11 @@ def test_get_line_items(self):
4342
def test_get_line_item_detailed_report(self):
4443
with open('./tests/test_files/get_line_item_detailed_report.json', 'r') as line_item_detailed_report_file:
4544
line_item_detailed_report_json = json.load(line_item_detailed_report_file)
46-
responses.add(responses.GET, '{}/sample/v1/projects/1/lineItems/100/detailedReport'.format(BASE_HOST), json=line_item_detailed_report_json, status=200)
45+
responses.add(
46+
responses.GET,
47+
'{}/sample/v1/projects/1/lineItems/100/detailedReport'.format(BASE_HOST),
48+
json=line_item_detailed_report_json,
49+
status=200)
4750
self.api.get_line_item_detailed_report(1, 100)
4851
self.assertEqual(len(responses.calls), 1)
4952
self.assertEqual(responses.calls[0].response.json(), line_item_detailed_report_json)

0 commit comments

Comments
 (0)