Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Updated urllib and config files (#8)
Browse files Browse the repository at this point in the history
* Updated urllib and config files

* Version 1.2.1
  • Loading branch information
roedesh authored Apr 21, 2019
1 parent ba0c0b1 commit 53a6a55
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 25 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "pypi"

[packages]
requests = "*"
"urllib3" = "*"

[dev-packages]
pytest = "*"
Expand Down
24 changes: 12 additions & 12 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion postcodeapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def __init__(self, api_key):
:param api_key: Postcode API V2 key
"""
self._headers = {"x-api-key": api_key, "accept": "application/hal+json"}
self._headers = {
"x-api-key": api_key,
"accept": "application/hal+json",
}

def _do_request(self, endpoint, querystring=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="postcodeapi",
version="1.2.0",
version="1.2.1",
description="An unofficial Python wrapper around the Postcode API v2",
long_description=open("README.rst").read(),
url="http://github.com/roedesh/postcodeapi",
Expand Down
8 changes: 6 additions & 2 deletions tests/unit_tests/test_addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def test_get_all_addresses_with_postal_code_and_number(api_client):
get_api_url("addresses?postcode=6545CA&number=5"),
text=read_file("address_list_postal_code_and_number.json"),
)
data = api_client.get_all_addresses(postal_code="6545CA", number=5)["results"]
data = api_client.get_all_addresses(postal_code="6545CA", number=5)[
"results"
]
assert data[0]["postcode"] == "6545CA"
assert data[0]["number"] == 5

Expand All @@ -45,7 +47,9 @@ def test_get_all_addresses_from_id(api_client):
get_api_url("addresses?from[id]=0503200000060096"),
text=read_file("address_list_from_id.json"),
)
data = api_client.get_all_addresses(from_id="0503200000060096")["results"]
data = api_client.get_all_addresses(from_id="0503200000060096")[
"results"
]
assert data[0]["id"] == "0553200000001332"


Expand Down
15 changes: 11 additions & 4 deletions tests/unit_tests/test_postal_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@

def test_get_all_postal_codes(api_client):
with requests_mock.mock() as m:
m.get(get_api_url("postcodes"), text=read_file("postal_code_list.json"))
m.get(
get_api_url("postcodes"), text=read_file("postal_code_list.json")
)
data = api_client.get_all_postal_codes()["results"]
assert data[0]["postcode"] == "7315AA"


def test_get_all_postal_codes_from_postal_code(api_client):
with requests_mock.mock() as m:
m.get(
get_api_url("postcodes?from[postcode]=7315AA&from[postcodeArea]=7315"),
get_api_url(
"postcodes?from[postcode]=7315AA&from[postcodeArea]=7315"
),
text=read_file("postal_code_list_from_postal_code.json"),
)
data = api_client.get_all_postal_codes(from_postal_code="7315AA")["results"]
data = api_client.get_all_postal_codes(from_postal_code="7315AA")[
"results"
]
assert data[0]["postcode"] == "7315BB"


Expand All @@ -41,7 +47,8 @@ def test_get_all_postal_codes_area(api_client):
def test_get_postal_code(api_client):
with requests_mock.mock() as m:
m.get(
get_api_url("postcodes/7315AD"), text=read_file("single_postal_code.json")
get_api_url("postcodes/7315AD"),
text=read_file("single_postal_code.json"),
)
data = api_client.get_postal_code(postal_code="7315AD")
assert data["postcode"] == "7315AD"
Expand Down
9 changes: 4 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[flake8]
max-line-length = 80
select = C,E,F,W,B,B950
ignore = E501
[isort]
line_length = 79
skip = migrations, node_modules, snapshots

[pytest]
addopts = --cov=postcodeapi --cov-report html
addopts = --cov=postcodeapi --cov-report html

0 comments on commit 53a6a55

Please sign in to comment.