本文整理汇总了Python中txtorcon.router.Router.get_location方法的典型用法代码示例。如果您正苦于以下问题:Python Router.get_location方法的具体用法?Python Router.get_location怎么用?Python Router.get_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.router.Router
的用法示例。
在下文中一共展示了Router.get_location方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_location_unknown
# 需要导入模块: from txtorcon.router import Router [as 别名]
# 或者: from txtorcon.router.Router import get_location [as 别名]
def test_get_location_unknown(self):
class CountryCodeController(object):
def get_info_raw(self, i):
raise RuntimeError("shouldn't happen")
controller = CountryCodeController()
r = Router(controller)
loc = yield r.get_location()
self.assertEqual(loc.countrycode, None)
示例2: test_get_location_something
# 需要导入模块: from txtorcon.router import Router [as 别名]
# 或者: from txtorcon.router.Router import get_location [as 别名]
def test_get_location_something(self):
class CountryCodeController(object):
def get_info_raw(self, i):
return defer.succeed(
'250-ip-to-country/8.8.8.8=US\r\n250 OK'
)
controller = CountryCodeController()
r = Router(controller)
r.update('routername', 'deadbeef', 'orhash', 'modified', '8.8.8.8', '', '')
loc = yield r.get_location()
self.assertNotEqual(loc.countrycode, None)
示例3: test_get_location_private
# 需要导入模块: from txtorcon.router import Router [as 别名]
# 或者: from txtorcon.router.Router import get_location [as 别名]
def test_get_location_private(self):
class CountryCodeController(object):
def get_info_raw(self, i):
return defer.succeed(
'250-ip-to-country/192.168.0.1=ZZ\r\n250 OK'
)
controller = CountryCodeController()
r = Router(controller)
r.update('routername', 'deadbeef', 'orhash', 'modified', '192.168.0.1', '', '')
loc0 = yield r.get_location()
loc1 = yield r.get_location()
self.assertEqual(loc0.countrycode, 'ZZ')
self.assertEqual(loc1.countrycode, 'ZZ')