Skip to content

Commit 46ef14c

Browse files
committed
fixed tests to pass linting
1 parent b942ee3 commit 46ef14c

File tree

11 files changed

+37
-47
lines changed

11 files changed

+37
-47
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
pip install flake8
2727
# stop the build if there are Python syntax errors or undefined names
2828
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
29+
# the GitHub editor is 127 chars wide
30+
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
3131
- name: Test with pytest
3232
run: |
3333
pip install pytest

CONTRIBUTING.md

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

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

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

2836
To run the tests,

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

1510
BASE_HOST = "http://test-url.example"
@@ -24,7 +19,11 @@ def setUp(self):
2419
def test_get_line_item(self):
2520
with open('./tests/test_files/get_line_item.json', 'r') as line_item_file:
2621
line_item_json = json.load(line_item_file)
27-
responses.add(responses.GET, '{}/sample/v1/projects/1/lineItems/100'.format(BASE_HOST), json=line_item_json, status=200)
22+
responses.add(
23+
responses.GET,
24+
'{}/sample/v1/projects/1/lineItems/100'.format(BASE_HOST),
25+
json=line_item_json,
26+
status=200)
2827
self.api.get_line_item(1, 100)
2928
self.assertEqual(len(responses.calls), 1)
3029
self.assertEqual(responses.calls[0].response.json(), line_item_json)
@@ -42,7 +41,11 @@ def test_get_line_items(self):
4241
def test_get_line_item_detailed_report(self):
4342
with open('./tests/test_files/get_line_item_detailed_report.json', 'r') as line_item_detailed_report_file:
4443
line_item_detailed_report_json = json.load(line_item_detailed_report_file)
45-
responses.add(responses.GET, '{}/sample/v1/projects/1/lineItems/100/detailedReport'.format(BASE_HOST), json=line_item_detailed_report_json, status=200)
44+
responses.add(
45+
responses.GET,
46+
'{}/sample/v1/projects/1/lineItems/100/detailedReport'.format(BASE_HOST),
47+
json=line_item_detailed_report_json,
48+
status=200)
4649
self.api.get_line_item_detailed_report(1, 100)
4750
self.assertEqual(len(responses.calls), 1)
4851
self.assertEqual(responses.calls[0].response.json(), line_item_detailed_report_json)

tests/test_projects.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

1510
BASE_HOST = "http://test-url.example"
@@ -42,7 +37,11 @@ def test_get_projects(self):
4237
def test_get_project_detailed_report(self):
4338
with open('./tests/test_files/get_project_detailed_report.json', 'r') as project_detailed_report_file:
4439
project_detailed_report_json = json.load(project_detailed_report_file)
45-
responses.add(responses.GET, '{}/sample/v1/projects/1/detailedReport'.format(BASE_HOST), json=project_detailed_report_json, status=200)
40+
responses.add(
41+
responses.GET,
42+
'{}/sample/v1/projects/1/detailedReport'.format(BASE_HOST),
43+
json=project_detailed_report_json,
44+
status=200)
4645
self.api.get_project_detailed_report(1)
4746
self.assertEqual(len(responses.calls), 1)
4847
self.assertEqual(responses.calls[0].response.json(), project_detailed_report_json)
@@ -52,6 +51,10 @@ def test_create_project(self):
5251
# Tests creating a project. This also tests validating the project data as part of `api.create_project`.
5352
with open('./tests/test_files/examples/project_new.json', 'r') as new_project_file:
5453
new_project_data = json.load(new_project_file)
55-
responses.add(responses.POST, '{}/sample/v1/projects'.format(BASE_HOST), json={'status': {'message': 'success'}}, status=200)
54+
responses.add(
55+
responses.POST,
56+
'{}/sample/v1/projects'.format(BASE_HOST),
57+
json={'status': {'message': 'success'}},
58+
status=200)
5659
self.api.create_project(new_project_data)
5760
self.assertEqual(len(responses.calls), 1)

0 commit comments

Comments
 (0)