kopia lustrzana https://github.com/glidernet/ogn-python
Added GeocoderTimedOut exception
rodzic
b135a9dfd0
commit
03ea96c71e
|
@ -1,4 +1,5 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
import unittest.mock as mock
|
||||||
|
|
||||||
from ogn.utils import get_ddb, get_trackable, get_country_code, haversine_distance
|
from ogn.utils import get_ddb, get_trackable, get_country_code, haversine_distance
|
||||||
from ogn.model import AddressOrigin
|
from ogn.model import AddressOrigin
|
||||||
|
@ -44,6 +45,15 @@ class TestStringMethods(unittest.TestCase):
|
||||||
country_code = get_country_code(latitude, longitude)
|
country_code = get_country_code(latitude, longitude)
|
||||||
self.assertEqual(country_code, None)
|
self.assertEqual(country_code, None)
|
||||||
|
|
||||||
|
@mock.patch('ogn.utils.Nominatim')
|
||||||
|
def test_gec_country_code_exception(self, nominatim_mock):
|
||||||
|
from geopy.exc import GeocoderTimedOut
|
||||||
|
instance = nominatim_mock.return_value
|
||||||
|
|
||||||
|
instance.reverse.side_effect = GeocoderTimedOut('Too busy')
|
||||||
|
country_code = get_country_code(0, 0)
|
||||||
|
self.assertIsNone(country_code)
|
||||||
|
|
||||||
def test_haversine_distance(self):
|
def test_haversine_distance(self):
|
||||||
# delta: one latitude degree
|
# delta: one latitude degree
|
||||||
location0 = (0, 0)
|
location0 = (0, 0)
|
||||||
|
|
Ładowanie…
Reference in New Issue