Skip to content

Commit 3fb78ce

Browse files
authored
Merge pull request hzlmn#6 from hzlmn/patch_2
Added initial testing
2 parents fb4a58f + d9099be commit 3fb78ce

File tree

6 files changed

+20
-99
lines changed

6 files changed

+20
-99
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ sudo: false
55
language: python
66

77
python:
8-
- "3.5"
98
- "3.6"
109

1110
install:
@@ -14,6 +13,7 @@ install:
1413

1514
script:
1615
- flake8 aiogmaps/
16+
- pytest tests/
1717

1818
cache:
1919
directories:

requirements-dev.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aiohttp==3.0.9
1+
aiohttp==3.1.0
22
async-timeout==1.4.0
33
attrs==17.4.0
44
autopep8==1.3.4
@@ -20,6 +20,8 @@ pyflakes==1.6.0
2020
pytest==3.4.2
2121
pytest-aiohttp==0.3.0
2222
pytest-cov==2.5.1
23+
pytest-asyncio==0.9.0
24+
aresponses===1.1.1
2325
requests==2.18.4
2426
six==1.11.0
2527
urllib3==1.22

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def api_key():
2323

2424

2525
@pytest.fixture
26-
def client(loop, api_key):
27-
client = Client(api_key, loop=loop)
26+
async def client(loop, api_key):
27+
client = Client(api_key, verify_ssl=False, loop=loop)
2828
yield client
29-
loop.run_until_complete(client.close())
29+
await client.close()

tests/test_client.py

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

tests/test_places.py

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,25 @@
55

66

77
async def test_autocomplete(aresponses, client, api_key):
8-
location = (-33.86746, 151.207090)
9-
language = 'en-AU'
10-
region = 'AU'
11-
radius = 100
12-
13-
query = {
14-
'key': api_key,
15-
'intput': 'Google',
16-
'offset': 3,
17-
'location': '-33.86746,151.20709',
18-
'radius': 100,
19-
'language': 'en-AU',
20-
'types': 'geocode',
21-
'components': 'country:au',
22-
'strictbounds': 'true',
23-
}
24-
258
patched_url = URL.build(
26-
scheme='https',
27-
host='maps.googleapis.com',
289
path='/maps/api/place/autocomplete/json',
29-
query=query,
10+
query={
11+
'key': api_key,
12+
'input': 'Google',
13+
},
3014
)
3115

3216
aresponses.add(
33-
patched_url.host,
34-
patched_url.path_qs,
17+
'maps.googleapis.com',
18+
patched_url.human_repr(),
3519
'get',
3620
aresponses.Response(
37-
body='{"status": "OK", "predictions": []}',
21+
body='{"status": "OK", "predictions": ["foo"]}',
3822
status=200,
3923
content_type='application/json',
40-
)
24+
),
25+
match_querystring=True
4126
)
4227

43-
places = await client.places_autocomplete(
44-
'Google', offset=3,
45-
location=location,
46-
radius=radius,
47-
language=language,
48-
types='geocode',
49-
components={'country': 'au'},
50-
strict_bounds=True,
51-
)
52-
assert places is not None
28+
places = await client.places_autocomplete('Google')
29+
assert places == ["foo"]

tests/test_timezone.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ async def test_timezone(aresponses, client, api_key):
2727
match_querystring=True,
2828
)
2929

30-
timezone = await client.timezone(location, timestamp)
31-
assert timezone is not None
30+
resp = await client.timezone(location, timestamp)
31+
assert resp['status'] == 'OK'

0 commit comments

Comments
 (0)