This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
forked from christopherwright/pyplacefinder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
48 lines (37 loc) · 1.54 KB
/
tests.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
import unittest
import pyplacefinder
from pprint import pprint
from private_settings import APP_ID
class BaseTest(unittest.TestCase):
def setUp(self):
self.client = pyplacefinder.PlaceFinder(APP_ID)
class GeocoderTest(BaseTest):
def test_location(self):
self.result = self.client.geocode(
location='220 W. 1st Street, Los Angeles, CA, 90012'
)
self.assertEquals(len(self.result), 1)
self.assertEquals(type(self.result), type([]))
self.assertEquals(self.result[0]['quality_type'], 'Point')
self.assertEquals(
self.result[0]['quality_description'],
'Address match with street match'
)
self.result = self.client.geocode(location='Winnetka')
self.assertEquals(len(self.result), 2)
def test_state_bias(self):
self.result = self.client.geocode(city='Winnetka', state='CA')
self.assertEquals(len(self.result), 1)
def test_country_bias(self):
self.result = self.client.geocode(city='Toledo', country='SPAIN')
self.assertEquals(len(self.result), 1)
self.result = self.client.geocode(city='Toledo', locale='es_ES')
self.assertEquals(len(self.result), 1)
def test_reverse_geocode(self):
self.result = self.client.reverseGeocode(
location="34.05254386312157,-118.24548482894897"
)
self.assertEquals(len(self.result), 1)
self.assertEquals(self.result[0]['street'], 'S Spring St')
if __name__ == '__main__':
unittest.main()