Merge pull request #146 from jmathai/geolocate-test
Add geolocation tests
This commit is contained in:
commit
3f1efe96ad
|
@ -196,15 +196,26 @@ class FileSystem(object):
|
||||||
print('Could not get checksum for %s. Skipping...' % _file)
|
print('Could not get checksum for %s. Skipping...' % _file)
|
||||||
return
|
return
|
||||||
|
|
||||||
# If duplicates are not allowed and this hash exists in the db then we
|
# If duplicates are not allowed then we check if we've seen this file
|
||||||
# return
|
# before via checksum. We also check that the file exists at the
|
||||||
if(allow_duplicate is False and db.check_hash(checksum) is True):
|
# location we believe it to be.
|
||||||
if(constants.debug is True):
|
# If we find a checksum match but the file doesn't exist where we
|
||||||
print('%s already exists at %s. Skipping...' % (
|
# believe it to be then we write a debug log and proceed to import.
|
||||||
_file,
|
checksum_file = db.get_hash(checksum)
|
||||||
db.get_hash(checksum)
|
if(allow_duplicate is False and checksum_file is not None):
|
||||||
))
|
if(os.path.isfile(checksum_file)):
|
||||||
return
|
if(constants.debug is True):
|
||||||
|
print('%s already exists at %s. Skipping...' % (
|
||||||
|
_file,
|
||||||
|
checksum_file
|
||||||
|
))
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if(constants.debug is True):
|
||||||
|
print('%s matched checksum but file not found at %s. Importing again...' % ( # noqa
|
||||||
|
_file,
|
||||||
|
checksum_file
|
||||||
|
))
|
||||||
|
|
||||||
self.create_directory(dest_directory)
|
self.create_directory(dest_directory)
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ from __future__ import division
|
||||||
from future import standard_library
|
from future import standard_library
|
||||||
from past.utils import old_div
|
from past.utils import old_div
|
||||||
|
|
||||||
|
standard_library.install_aliases() # noqa
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
|
||||||
standard_library.install_aliases() # noqa
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
|
@ -101,6 +101,16 @@ def test_lookup_with_invalid_location():
|
||||||
res = geolocation.lookup(location='foobar dne')
|
res = geolocation.lookup(location='foobar dne')
|
||||||
assert res is None, res
|
assert res is None, res
|
||||||
|
|
||||||
|
def test_lookup_with_invalid_location():
|
||||||
|
res = geolocation.lookup(location='foobar dne')
|
||||||
|
assert res is None, res
|
||||||
|
|
||||||
|
def test_lookup_with_valid_key():
|
||||||
|
res = geolocation.lookup(location='Sunnyvale, CA')
|
||||||
|
latLng = res['results'][0]['locations'][0]['latLng']
|
||||||
|
assert latLng['lat'] == 37.36883, latLng
|
||||||
|
assert latLng['lng'] == -122.03635, latLng
|
||||||
|
|
||||||
@mock.patch('elodie.geolocation.__KEY__', 'invalid_key')
|
@mock.patch('elodie.geolocation.__KEY__', 'invalid_key')
|
||||||
def test_lookup_with_invalid_key():
|
def test_lookup_with_invalid_key():
|
||||||
res = geolocation.lookup(location='Sunnyvale, CA')
|
res = geolocation.lookup(location='Sunnyvale, CA')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-r ../../requirements.txt
|
-r ../../requirements.txt
|
||||||
flake8>=2.2.5,<3.0
|
flake8==2.6.2
|
||||||
mock>=1.3.0,<2.0
|
mock==1.3.0
|
||||||
nose>=1.3.7,<2.0
|
nose==1.3.7
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
click>=6.2,<7.0
|
click==6.6
|
||||||
requests>=2.9.1,<3.0
|
requests==2.11.1
|
||||||
send2trash>=1.3.0,<2.0
|
Send2Trash==1.3.0
|
||||||
future
|
future==0.16.0
|
||||||
|
configparser==3.5.0
|
||||||
|
|
Loading…
Reference in New Issue