本文整理汇总了Python中test.geocoders.util.env.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUpClass
def setUpClass(cls):
if not credentials:
return
cls.geocoder = IGNFrance(
api_key=env.get('IGNFRANCE_KEY'),
username=env.get('IGNFRANCE_USERNAME'),
password=env.get('IGNFRANCE_PASSWORD'),
referer=env.get('IGNFRANCE_REFERER'),
timeout=10
)
cls.delta_exact = 0.2
开发者ID:jmb,项目名称:geopy,代码行数:11,代码来源:ignfrance.py
示例2: setUpClass
def setUpClass(cls):
cls.delta = 0.04
cls.geocoder = GeocodeFarm(
# None api_key will use free tier on GeocodeFarm.
api_key=env.get('GEOCODEFARM_KEY'),
timeout=10,
)
开发者ID:jmb,项目名称:geopy,代码行数:7,代码来源:geocodefarm.py
示例3: OpenMapQuestNoNetTestCase
from geopy.exc import ConfigurationError
from test.geocoders.nominatim import BaseNominatimTestCase
from test.geocoders.util import GeocoderTestBase, env
import unittest
class OpenMapQuestNoNetTestCase(GeocoderTestBase):
def test_user_agent_custom(self):
geocoder = OpenMapQuest(
api_key='DUMMYKEY1234',
user_agent='my_user_agent/1.0'
)
self.assertEqual(geocoder.headers['User-Agent'], 'my_user_agent/1.0')
def test_raises_without_apikey(self):
with self.assertRaises(ConfigurationError):
OpenMapQuest()
@unittest.skipUnless(
bool(env.get('OPENMAPQUEST_APIKEY')),
"No OPENMAPQUEST_APIKEY env variable set"
)
class OpenMapQuestTestCase(BaseNominatimTestCase, GeocoderTestBase):
@classmethod
def make_geocoder(cls, **kwargs):
return OpenMapQuest(api_key=env['OPENMAPQUEST_APIKEY'],
timeout=3, **kwargs)
开发者ID:jmb,项目名称:geopy,代码行数:30,代码来源:openmapquest.py
示例4: bool
import unittest
import types
from geopy import exc
from geopy.point import Point
from geopy.geocoders import GeocodeFarm
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless( # pylint: disable=R0904,C0111
bool(env.get("GEOCODEFARM_KEY")), "GEOCODEFARM_KEY env variable not set"
)
class GeocodeFarmTestCase(GeocoderTestBase): # pylint: disable=R0904,C0111
@classmethod
def setUpClass(cls):
cls.delta = 0.04
cls.geocoder = GeocodeFarm(api_key=env["GEOCODEFARM_KEY"], format_string="%s US")
def test_geocode(self):
"""
OpenCage.geocode
"""
self.geocode_run(
{"query": "435 north michigan ave, chicago il 60611 usa"}, {"latitude": 41.890, "longitude": -87.624}
)
def test_reverse_string(self):
"""
GeocodeFarm.reverse string
"""
self.reverse_run(
开发者ID:spatialbitz,项目名称:geopy,代码行数:31,代码来源:geocodefarm.py
示例5: BingTestCase
import unittest
from geopy.compat import u
from geopy.point import Point
from geopy.geocoders import Bing
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless(bool(env.get("BING_KEY")), "No BING_KEY env variable set") # pylint: disable=R0904,C0111
class BingTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = Bing(format_string="%s", scheme="http", api_key=env["BING_KEY"])
def test_geocode(self):
"""
Bing.geocode
"""
self.geocode_run(
{"query": "435 north michigan ave, chicago il 60611 usa"}, {"latitude": 41.890, "longitude": -87.624}
)
def test_unicode_name(self):
"""
Bing.geocode unicode
"""
self.geocode_run({"query": u("\u6545\u5bab")}, {"latitude": 39.916, "longitude": 116.390})
def test_reverse_point(self):
"""
Bing.reverse using point
开发者ID:spatialbitz,项目名称:geopy,代码行数:31,代码来源:bing.py
示例6: bool
import unittest
from geopy.geocoders import AzureMaps
from test.geocoders.util import GeocoderTestBase, env
from test.geocoders.tomtom import BaseTomTomTestCase
@unittest.skipUnless(
bool(env.get('AZURE_SUBSCRIPTION_KEY')),
"No AZURE_SUBSCRIPTION_KEY env variable set"
)
class AzureMapsTestCase(BaseTomTomTestCase, GeocoderTestBase):
@classmethod
def make_geocoder(cls, **kwargs):
return AzureMaps(env['AZURE_SUBSCRIPTION_KEY'], timeout=3,
**kwargs)
开发者ID:jmb,项目名称:geopy,代码行数:17,代码来源:azure.py
示例7: bool
import unittest
from geopy import exc
from geopy.compat import u
from geopy.point import Point
from geopy.geocoders import ArcGIS
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless( # pylint: disable=R0904,C0111
bool(env.get('ARCGIS_USERNAME')),
"No ARCGIS_USERNAME env variable set"
)
class ArcGISTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = ArcGIS(timeout=3)
def test_config_error(self):
"""
ArcGIS.__init__ invalid authentication
"""
with self.assertRaises(exc.ConfigurationError):
ArcGIS(username='a')
def test_scheme_config_error(self):
"""
ArcGIS.__init__ invalid scheme
"""
with self.assertRaises(exc.ConfigurationError):
开发者ID:rakeshsukla53,项目名称:geopy,代码行数:31,代码来源:arcgis.py
示例8: test_custom_wkid
def test_custom_wkid(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
# Custom wkid should be ignored and a warning should be issued.
location = self.reverse_run(
{"query": Point(40.753898, -73.985071), "wkid": 2000},
{"latitude": 40.75376406311989,
"longitude": -73.98489005863667},
)
self.assertIn('New York', location.address)
self.assertEqual(1, len(w))
@unittest.skipUnless(
(env.get('ARCGIS_USERNAME') is not None
or env.get('ARCGIS_PASSWORD') is not None
or env.get('ARCGIS_REFERER') is not None),
"No ARCGIS_USERNAME or ARCGIS_PASSWORD or ARCGIS_REFERER env variable set"
)
class ArcGISAuthenticatedTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = ArcGIS(
username=env['ARCGIS_USERNAME'],
password=env['ARCGIS_PASSWORD'],
referer=env['ARCGIS_REFERER'],
timeout=3
)
开发者ID:jmb,项目名称:geopy,代码行数:29,代码来源:arcgis.py
示例9: What3WordsTestCase
import unittest
from geopy.compat import u
from geopy.geocoders import What3Words
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless(bool(env.get('WHAT3WORDS_KEY')),
"No WHAT3WORDS_KEY env variable set"
)
class What3WordsTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = What3Words(
env['WHAT3WORDS_KEY'],
scheme='http',
timeout=3
)
cls.delta = 0.7
def test_geocode(self):
"""
What3Words.geocode - '3 Words' and 'OneWord'
"""
self.geocode_run(
{"query": u("piped.gains.jangle")},
{"latitude": 53.037611, "longitude": 11.565012},
)
self.geocode_run(
开发者ID:spatialbitz,项目名称:geopy,代码行数:31,代码来源:what3words.py
示例10: bool
import unittest
from geopy.geocoders import MapQuest
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless( # pylint: disable=R0904,C0111
bool(env.get('MAPQUEST_KEY')),
"No MAPQUEST_KEY env variable set"
)
class MapQuestTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = MapQuest(
env['MAPQUEST_KEY'],
scheme='http',
timeout=3
)
cls.delta = 0.7
def test_geocode(self):
"""
MapQuest.geocode
"""
self.geocode_run(
{"query": u"435 north michigan ave, chicago il 60611 usa"},
{"latitude": 41.890, "longitude": -87.624},
)
开发者ID:dodysw,项目名称:geopy,代码行数:29,代码来源:mapquest.py
示例11: HereTestCaseUnitTest
from test.geocoders.util import GeocoderTestBase, env
class HereTestCaseUnitTest(GeocoderTestBase):
def test_user_agent_custom(self):
geocoder = Here(
app_id='DUMMYID1234',
app_code='DUMMYCODE1234',
user_agent='my_user_agent/1.0'
)
self.assertEqual(geocoder.headers['User-Agent'], 'my_user_agent/1.0')
@unittest.skipUnless(
bool(env.get('HERE_APP_ID')),
"No HERE_APP_ID env variable set"
)
@unittest.skipUnless(
bool(env.get('HERE_APP_CODE')),
"No HERE_APP_CODE env variable set"
)
class HereTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = Here(
app_id=env['HERE_APP_ID'],
app_code=env['HERE_APP_CODE'],
timeout=10,
)
开发者ID:jmb,项目名称:geopy,代码行数:31,代码来源:here.py
示例12: bool
# -*- coding: utf8 -*-
import unittest
from geopy.exc import ConfigurationError, GeocoderQueryError
from geopy.geocoders import IGNFrance
from test.geocoders.util import GeocoderTestBase, env
credentials = bool(
(env.get('IGNFRANCE_KEY') and env.get('IGNFRANCE_USERNAME')
and env.get('IGNFRANCE_PASSWORD')) or (
env.get('IGNFRANCE_KEY') and env.get('IGNFRANCE_REFERER'))
)
class IGNFranceTestCaseUnitTest(GeocoderTestBase):
def test_user_agent_custom(self):
geocoder = IGNFrance(
api_key='DUMMYKEY1234',
username='MUSTERMANN',
password='tops3cr3t',
user_agent='my_user_agent/1.0'
)
self.assertEqual(geocoder.headers['User-Agent'], 'my_user_agent/1.0')
@unittest.skipUnless(
credentials,
"One or more of the env variables IGNFRANCE_KEY, IGNFRANCE_USERNAME "
"and IGNFRANCE_PASSWORD is not set"
)
开发者ID:jmb,项目名称:geopy,代码行数:31,代码来源:ignfrance.py
示例13: What3Words
with self.assertRaises(geopy.exc.ConfigurationError):
What3Words(
api_key=self.dummy_api_key,
scheme='http',
)
@patch.object(geopy.geocoders.options, 'default_scheme', 'http')
def test_default_scheme_is_ignored(self):
geocoder = What3Words(api_key=self.dummy_api_key)
self.assertEqual(geocoder.scheme, 'https')
geocoder = What3Words(api_key=self.dummy_api_key, scheme=None)
self.assertEqual(geocoder.scheme, 'https')
@unittest.skipUnless(
bool(env.get('WHAT3WORDS_KEY')),
"No WHAT3WORDS_KEY env variable set"
)
class What3WordsTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = What3Words(
env['WHAT3WORDS_KEY'],
scheme='https',
timeout=3
)
cls.delta = 0.7
def test_geocode(self):
self.geocode_run(
开发者ID:jmb,项目名称:geopy,代码行数:31,代码来源:what3words.py
示例14: bool
import unittest
from geopy.geocoders import LiveAddress
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless( # pylint: disable=R0904,C0111
bool(env.get('LIVESTREETS_AUTH_KEY')),
"No LIVESTREETS_AUTH_KEY env variable set"
)
class LiveAddressTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = LiveAddress(
auth_token=env['LIVESTREETS_AUTH_KEY'],
scheme='http'
)
cls.delta = 0.04
def test_geocode(self):
"""
LiveAddress.geocode
"""
self.geocode_run(
{"query": u"435 north michigan ave, chicago il 60611 usa"},
{"latitude": 41.890, "longitude": -87.624},
)
开发者ID:MultiRRomero,项目名称:manhattan-map,代码行数:28,代码来源:smartystreets.py
示例15: make_geocoder
def make_geocoder(cls, **kwargs):
return Pelias(env.get('PELIAS_DOMAIN'), api_key=env.get('PELIAS_KEY'),
**kwargs)
开发者ID:jmb,项目名称:geopy,代码行数:3,代码来源:pelias.py
示例16: test_reverse_point
def test_reverse_point(self):
"""
Baidu.reverse Point
"""
self.reverse_run(
{"query": Point(39.983615544507, 116.32295155093)},
{"latitude": 39.983615544507, "longitude": 116.32295155093},
)
self.reverse_run(
{"query": Point(39.983615544507, 116.32295155093), "exactly_one": False},
{"latitude": 39.983615544507, "longitude": 116.32295155093},
)
@unittest.skipUnless(
bool(env.get('BAIDU_KEY')),
"No BAIDU_KEY env variable set"
)
class BaiduTestCase(BaiduQueriesTestCaseMixin, GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = Baidu(
api_key=env['BAIDU_KEY'],
timeout=3,
)
def test_invalid_ak(self):
self.geocoder = Baidu(api_key='DUMMYKEY1234')
with self.assertRaises(GeocoderAuthenticationFailure) as cm:
self.geocode_run({"query": u("baidu")}, None)
开发者ID:jmb,项目名称:geopy,代码行数:31,代码来源:baidu.py
示例17: test_default_scheme_is_ignored
auth_id=self.dummy_id,
auth_token=self.dummy_token,
scheme='http',
)
@patch.object(geopy.geocoders.options, 'default_scheme', 'http')
def test_default_scheme_is_ignored(self):
geocoder = LiveAddress(auth_id=self.dummy_id, auth_token=self.dummy_token)
self.assertEqual(geocoder.scheme, 'https')
geocoder = LiveAddress(auth_id=self.dummy_id, auth_token=self.dummy_token,
scheme=None)
self.assertEqual(geocoder.scheme, 'https')
@unittest.skipUnless(
env.get('LIVESTREETS_AUTH_ID') and env.get('LIVESTREETS_AUTH_TOKEN'),
"No LIVESTREETS_AUTH_ID AND LIVESTREETS_AUTH_TOKEN env variables set"
)
class LiveAddressTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = LiveAddress(
auth_id=env['LIVESTREETS_AUTH_ID'],
auth_token=env['LIVESTREETS_AUTH_TOKEN'],
)
cls.delta = 0.04
def test_geocode(self):
"""
LiveAddress.geocode
开发者ID:jmb,项目名称:geopy,代码行数:31,代码来源:smartystreets.py
示例18: GeocoderDotUSTestCaseUnitTest
from geopy.compat import py3k
from geopy.geocoders import GeocoderDotUS
from test.geocoders.util import GeocoderTestBase, env
class GeocoderDotUSTestCaseUnitTest(GeocoderTestBase):
def test_user_agent_custom(self):
geocoder = GeocoderDotUS(
user_agent='my_user_agent/1.0'
)
self.assertEqual(geocoder.headers['User-Agent'], 'my_user_agent/1.0')
@unittest.skipUnless( # pylint: disable=R0904,C0111
bool(env.get('GEOCODERDOTUS_USERNAME')) and \
bool(env.get('GEOCODERDOTUS_PASSWORD')),
"No GEOCODERDOTUS_USERNAME and GEOCODERDOTUS_PASSWORD env variables set"
)
class GeocoderDotUSTestCase(GeocoderTestBase): # pylint: disable=R0904,C0111
@classmethod
def setUpClass(cls):
cls.geocoder = GeocoderDotUS(
username=env['GEOCODERDOTUS_USERNAME'],
password=env['GEOCODERDOTUS_PASSWORD'],
timeout=3
)
def test_dot_us_auth(self):
"""
开发者ID:0x836,项目名称:geopy,代码行数:31,代码来源:dotus.py
示例19: bool
# -*- coding: UTF-8 -*-
import unittest
from geopy.compat import u
from geopy.geocoders import GeoNames
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless( # pylint: disable=R0904,C0111
bool(env.get('GEONAMES_USERNAME')),
"No GEONAMES_USERNAME env variable set"
)
class GeoNamesTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.delta = 0.04
def test_unicode_name(self):
"""
GeoNames.geocode unicode
"""
# work around ConfigurationError raised in GeoNames init
self.geocoder = GeoNames(username=env['GEONAMES_USERNAME'])
self.geocode_run(
{"query": u("Mus\xe9e du Louvre")},
{"latitude": 48.8610, "longitude": 2.335},
)
def test_reverse(self):
"""
开发者ID:mwtoews,项目名称:geopy,代码行数:31,代码来源:geonames.py
示例20: OpenCageTestCase
import unittest
from geopy.compat import u
from geopy.geocoders import OpenCage
from test.geocoders.util import GeocoderTestBase, env
@unittest.skipUnless(bool(env.get("OPENCAGE_KEY")), "No OPENCAGE_KEY env variables set") # pylint: disable=R0904,C0111
class OpenCageTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
cls.geocoder = OpenCage(api_key=env["OPENCAGE_KEY"], timeout=20)
cls.delta_exact = 0.2
def test_geocode(self):
"""
OpenCage.geocode
"""
self.geocode_run(
{"query": "435 north michigan ave, chicago il 60611 usa"}, {"latitude": 41.890, "longitude": -87.624}
)
def test_unicode_name(self):
"""
OpenCage.geocode unicode
"""
self.geocode_run({"query": u("\u6545\u5bab")}, {"latitude": 39.916, "longitude": 116.390})
def test_geocode_empty_result(self):
"""
Empty OpenCage.geocode results should be graciously handled.
开发者ID:spatialbitz,项目名称:geopy,代码行数:31,代码来源:opencage.py
注:本文中的test.geocoders.util.env.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论