forked from vishakha-lall/MapBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_googleMapsApiModule.py
70 lines (58 loc) · 2.71 KB
/
test_googleMapsApiModule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import googleMapsApiModule
import config
import pytest
from googlemaps.exceptions import ApiError
class TestClass:
def test_direction_with_valid_input(self):
result = googleMapsApiModule.direction("paris", "brussels")
assert (
result
== "https://www.google.com/maps/dir/?api=1&origin=paris&destination=brussels"
)
def test_direction_with_invalid_input(self):
with pytest.raises(ApiError):
result = googleMapsApiModule.direction("kjajw", "qwiuq")
assert (
result
== "https://www.google.com/maps/dir/?api=1&origin=kjajw&destination=qwiuq"
)
def test_geocoding_with_valid_input(self):
result = googleMapsApiModule.geocoding("denver")
assert result == "https://www.google.com/maps/search/?api=1&query=denver"
def test_geocoding_with_invalid_input(self):
with pytest.raises(IndexError):
result = googleMapsApiModule.geocoding("kahakd...")
assert result == "https://www.google.com/maps/search/?api=1&query=kahakd..."
def test_mapsstatic_with_valid_input(self):
result = googleMapsApiModule.mapsstatic("sydney")
assert (
result
== "https://maps.googleapis.com/maps/api/staticmap?center=sydney&zoom=13&scale=1&size=600x350&maptype=roadmap&key="
+ config.key
+ "&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xff0000%7Clabel:L%7Csydney"
)
def test_elevation_with_valid_input(self):
result = googleMapsApiModule.elevation("moscow")
assert type(result) is float
def test_elevation_with_invalid_input(self):
with pytest.raises(IndexError):
result = googleMapsApiModule.elevation("hihih")
assert type(result) is float
def test_places_with_valid_input(self):
result = googleMapsApiModule.places("princeton university")
assert result == "ChIJ6baYzdjmw4kRTwKQ-tZ-ugI"
def test_places_with_invalid_input(self):
with pytest.raises(IndexError):
result = googleMapsApiModule.places("esffsf")
assert (
result
== "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CmRaAAAA8o1VGVvds8zkqh745Pa6t2KcBbMA&key=" # noqa: E501
+ config.key
)
def test_timezone_with_valid_input(self):
result = googleMapsApiModule.timezone("ohio", "2000 11 21 11 41")
assert result == "America/New_York"
def test_timezone_with_invalid_input(self):
with pytest.raises(ValueError):
result = googleMapsApiModule.timezone("wijd..", "2000 18 21 11 41")
assert result == "America/New_York"