-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.py
More file actions
executable file
·42 lines (30 loc) · 1.75 KB
/
tests.py
File metadata and controls
executable file
·42 lines (30 loc) · 1.75 KB
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
from unittest import TestCase, main
from rigeocoder import *
class test_rigeocoder(TestCase):
def setUp(self):
self.street = "82 Smith Street"
self.city = "Providence"
self.zip_code = "02903"
def test_uri_geocoder(self):
result = geocode_address_uri(self.street, self.city, self.zip_code)
self.assertEqual(result,
[{'lat': 41.83109769968133, 'lng': -71.41494403284543, 'address': u'82 SMITH ST, PROVIDENCE 02908'}, {'lat': 41.84791036607282, 'lng': -71.45576688783409, 'address': u'82 SMITH ST, PROVIDENCE 02911'}])
def test_uri_geocoder_fail(self):
result = geocode_address_uri(self.street, "Nebraska", self.zip_code)
self.assertEqual(result, [])
def test_google_geocoder(self):
result = geocode_address_google(self.street, self.city, self.zip_code)
self.assertEqual(result, [{u'lat': 41.831098,
u'lng': -71.41494399999999,
'address': u'82 Smith Street, Providence, RI 02903, USA'}])
def test_dotus_geocoder(self):
result = geocode_address_dotus(self.street, self.city, self.zip_code, "RI")
self.assertEqual(result,
[{'lat': 41.8312, 'lng': -71.413701, 'address': u'82 Smith St, Providence, RI 02908'}])
def test_full_geocoder(self):
""" This test should return the uri results"""
result = geocode_address(self.street, self.city, self.zip_code)
self.assertEqual(result,
[{'lat': 41.83109769968133, 'lng': -71.41494403284543, 'address': u'82 SMITH ST, PROVIDENCE 02908'}, {'lat': 41.84791036607282, 'lng': -71.45576688783409, 'address': u'82 SMITH ST, PROVIDENCE 02911'}])
if __name__ == '__main__':
main()