Skip to content

Commit fb99fdd

Browse files
committed
Added more tests
1 parent d482f15 commit fb99fdd

File tree

6 files changed

+169
-2
lines changed

6 files changed

+169
-2
lines changed

aiogmaps/distance_matrix.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ async def distance_matrix(client, origins, destinations,
1313
mode=mode, language=language, avoid=avoid, units=units,
1414
departure_time=departure_time, arrival_time=arrival_time,
1515
transit_routing_preference=transit_routing_preference,
16-
traffic_model=traffic_model, region=region,
17-
transit_mode=transit_mode,
16+
traffic_model=traffic_model, transit_mode=transit_mode,
1817
)

tests/test_directions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from aiohttp import web
2+
3+
4+
async def test_directions(aresponses, client):
5+
aresponses.add(
6+
'maps.googleapis.com',
7+
'/maps/api/directions/json',
8+
'get',
9+
aresponses.Response(
10+
body='{"status": "OK", "routes": ["foo"]}',
11+
status=web.HTTPOk.status_code,
12+
content_type='application/json',
13+
),
14+
)
15+
16+
resp = await client.directions(
17+
origin=(10, 10),
18+
destination=(10, 12),
19+
)
20+
assert resp

tests/test_distance_matrix.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from aiohttp import web
2+
3+
4+
async def test_distance_matrix(aresponses, client):
5+
aresponses.add(
6+
'maps.googleapis.com',
7+
'/maps/api/distancematrix/json',
8+
'get',
9+
aresponses.Response(
10+
body='{"status": "OK"}',
11+
status=web.HTTPOk.status_code,
12+
content_type='application/json',
13+
),
14+
)
15+
16+
resp = await client.distance_matrix([], [])
17+
assert resp

tests/test_elevation.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from aiohttp import web
2+
3+
4+
async def test_elevation(aresponses, client):
5+
aresponses.add(
6+
'maps.googleapis.com',
7+
'/maps/api/elevation/json',
8+
'get',
9+
aresponses.Response(
10+
body='{"status": "OK", "results": ["foo"]}',
11+
status=web.HTTPOk.status_code,
12+
content_type='application/json',
13+
),
14+
)
15+
16+
resp = await client.elevation([])
17+
assert resp == ['foo']
18+
19+
20+
async def test_elevation_along_path(aresponses, client):
21+
aresponses.add(
22+
'maps.googleapis.com',
23+
'/maps/api/elevation/json',
24+
'get',
25+
aresponses.Response(
26+
body='{"status": "OK", "results": ["foo"]}',
27+
status=web.HTTPOk.status_code,
28+
content_type='application/json',
29+
),
30+
)
31+
32+
resp = await client.elevation_along_path('', '')
33+
assert resp == ['foo']

tests/test_geocoding.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from aiohttp import web
2+
3+
4+
async def test_geocode(aresponses, client):
5+
aresponses.add(
6+
'maps.googleapis.com',
7+
'/maps/api/geocode/json',
8+
'get',
9+
aresponses.Response(
10+
body='{"status": "OK", "results": ["foo"]}',
11+
status=web.HTTPOk.status_code,
12+
content_type='application/json',
13+
),
14+
)
15+
16+
resp = await client.geocode()
17+
assert resp == ['foo']
18+
19+
20+
async def test_reverse_geocode(aresponses, client):
21+
aresponses.add(
22+
'maps.googleapis.com',
23+
'/maps/api/geocode/json',
24+
'get',
25+
aresponses.Response(
26+
body='{"status": "OK", "results": ["foo"]}',
27+
status=web.HTTPOk.status_code,
28+
content_type='application/json',
29+
),
30+
)
31+
32+
resp = await client.reverse_geocode((10, 10))
33+
assert resp == ['foo']

tests/test_roads.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from aiohttp import web
2+
3+
4+
async def test_snap_to_roads(aresponses, client):
5+
aresponses.add(
6+
'roads.googleapis.com',
7+
'/v1/snapToRoads',
8+
'get',
9+
aresponses.Response(
10+
body='{"status": "OK", "snappedPoints": ["foo"]}',
11+
status=web.HTTPOk.status_code,
12+
content_type='application/json',
13+
),
14+
)
15+
16+
resp = await client.snap_to_roads('')
17+
assert resp == ['foo']
18+
19+
20+
async def test_nearest_roads(aresponses, client):
21+
aresponses.add(
22+
'roads.googleapis.com',
23+
'/v1/nearestRoads',
24+
'get',
25+
aresponses.Response(
26+
body='{"status": "OK", "snappedPoints": ["foo"]}',
27+
status=web.HTTPOk.status_code,
28+
content_type='application/json',
29+
),
30+
)
31+
32+
resp = await client.nearest_roads('')
33+
assert resp == ['foo']
34+
35+
36+
async def test_speed_limits(aresponses, client):
37+
aresponses.add(
38+
'roads.googleapis.com',
39+
'/v1/speedLimits',
40+
'get',
41+
aresponses.Response(
42+
body='{"status": "OK", "speedLimits": ["foo"]}',
43+
status=web.HTTPOk.status_code,
44+
content_type='application/json',
45+
),
46+
)
47+
48+
resp = await client.speed_limits('')
49+
assert resp == ["foo"]
50+
51+
52+
async def test_snapped_speed_limits(aresponses, client):
53+
aresponses.add(
54+
'roads.googleapis.com',
55+
'/v1/speedLimits',
56+
'get',
57+
aresponses.Response(
58+
body='{"status": "OK", "speedLimits": ["foo"]}',
59+
status=web.HTTPOk.status_code,
60+
content_type='application/json',
61+
),
62+
)
63+
64+
resp = await client.snapped_speed_limits('')
65+
assert resp

0 commit comments

Comments
 (0)