Merge branch 'dev' into testing

# Conflicts:
#	.idea/workspace.xml
This commit is contained in:
pablomartincalvo 2018-10-19 19:18:14 +02:00
commit c40d39e558
3 changed files with 170 additions and 12 deletions

44
tests/geocoder_tests.py Normal file
View file

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
import sys
sys.path.append('..')
from geocoder.geocoder import Geocoder, GeocodingTask, GeocodingCache
def test_GeocodingTask():
good_address = 'Avinguda de la Republica Argentina 245, Barcelona'
bad_address = 'ASdasda, 123asd'
good_task = GeocodingTask(good_address)
good_task.geocode()
print(good_task.is_successfull())
print(good_task.get_results())
bad_address = GeocodingTask(bad_address)
bad_address.geocode()
print(bad_address.is_successfull())
print(bad_address.get_results())
def test_GeocodingCache():
cache = GeocodingCache()
test_record = {'address':'Calle Don Pepito',
'latitude': 12.1,
'longitude': 1.12,
'precision': 'absoluta'}
print(cache.address_in_cache(test_record['address']))
cache.add_address(test_record['address'],
test_record['latitude'],
test_record['longitude'],
test_record['precision'])
print(cache.address_in_cache(test_record['address']))
print(cache.get_coordinates(test_record['address']))
#test_GeocodingTask()
test_GeocodingCache()