本文整理汇总了Python中DatabaseHandler.DatabaseHandler.get_address_generator方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseHandler.get_address_generator方法的具体用法?Python DatabaseHandler.get_address_generator怎么用?Python DatabaseHandler.get_address_generator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseHandler.DatabaseHandler
的用法示例。
在下文中一共展示了DatabaseHandler.get_address_generator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_address_without_route_returns_with_correct_id
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import get_address_generator [as 别名]
def test_get_address_without_route_returns_with_correct_id(self):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler.add_address(MapLocation(latitude=2, longitude=2, id=222))
address_generator = handler.get_address_generator()
self.assertEqual(MapLocation(latitude=2, longitude=2, id=222),
address_generator.next(),
"MapLocation should return correct id")
示例2: test_get_address_without_route_returns_address_when_routes_empty
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import get_address_generator [as 别名]
def test_get_address_without_route_returns_address_when_routes_empty(self):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler.add_address(location=MapLocation(latitude=5, longitude=6, id=1))
address_generator = handler.get_address_generator()
self.assertEqual(MapLocation(latitude=5, longitude=6, id=1),
address_generator.next(),
"Only MapLocation in addresses was not returned")
示例3: test_get_address_without_route_generator_new_address_second_time
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import get_address_generator [as 别名]
def test_get_address_without_route_generator_new_address_second_time(self):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler.add_address(location=MapLocation(latitude=1, longitude=1))
handler.add_address(location=MapLocation(latitude=2, longitude=2))
address_generator = handler.get_address_generator()
self.assertEqual(MapLocation(latitude=1, longitude=1, id=1),
address_generator.next(),
"first returned MapLocation was not correct")
self.assertEqual(MapLocation(latitude=2, longitude=2, id=2),
address_generator.next(),
"second returned MapLocation was not correct")
示例4: test_get_address_without_route_returns_address_without_route
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import get_address_generator [as 别名]
def test_get_address_without_route_returns_address_without_route(self):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler.add_address(location=MapLocation(latitude=1, longitude=2))
handler.add_address(location=MapLocation(latitude=3, longitude=4))
handler.add_stop(location=MapLocation(latitude=0, longitude=0))
c = handler.conn.cursor()
c.execute("INSERT INTO routes (address_id, stop_id, distance, time)"
"VALUES (1, 1, 1, 1)")
c.close()
address_generator = handler.get_address_generator()
self.assertEqual(MapLocation(latitude=3, longitude=4, id=2),
address_generator.next(),
"the MapLocation without route was not returned")
示例5: test_get_address_without_route_generator_yield_MapLocations
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import get_address_generator [as 别名]
def test_get_address_without_route_generator_yield_MapLocations(self):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler.add_address(location=MapLocation(latitude=1, longitude=1))
address_generator = handler.get_address_generator()
self.assertIsInstance(address_generator.next(), MapLocation)
示例6: test_get_address_without_route_generator_returns_generator
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import get_address_generator [as 别名]
def test_get_address_without_route_generator_returns_generator(self):
handler = DatabaseHandler('unit_test_db.sqlite3')
self.assertIsInstance(handler.get_address_generator(),
types.GeneratorType)