本文整理汇总了Python中DatabaseHandler.DatabaseHandler._add_addresses_table方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseHandler._add_addresses_table方法的具体用法?Python DatabaseHandler._add_addresses_table怎么用?Python DatabaseHandler._add_addresses_table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseHandler.DatabaseHandler
的用法示例。
在下文中一共展示了DatabaseHandler._add_addresses_table方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_addresses_table_adds_table
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import _add_addresses_table [as 别名]
def test_add_addresses_table_adds_table(self,
mock_init_db):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler._add_addresses_table()
c = handler.conn.cursor()
c.execute("SELECT NAME FROM sqlite_master WHERE "
"TYPE='table' and NAME='addresses'")
self.assertTrue(c.fetchone(), "addresses table not created")
示例2: test_add_address_uses_MapLocation_id_if_nonzero
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import _add_addresses_table [as 别名]
def test_add_address_uses_MapLocation_id_if_nonzero(self,
mock_init_db):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler._add_addresses_table()
address_location = MapLocation(latitude=0.33, longitude=4, id=100)
handler.add_address(address_location)
c = handler.conn.cursor()
c.execute("SELECT * FROM addresses")
self.assertEqual(100, c.fetchone()[0])
示例3: test_add_address_adds_to_address_table
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import _add_addresses_table [as 别名]
def test_add_address_adds_to_address_table(self,
mock_init_db):
handler = DatabaseHandler('unit_test_db.sqlite3')
handler._add_addresses_table()
handler.add_address(location=MapLocation(latitude=0.56, longitude=9.5))
c = handler.conn.cursor()
c.execute("SELECT latitude, longitude FROM addresses")
row = c.fetchone()
self.assertEqual((0.56, 9.5), row)
示例4: test_construct_db_calls_add_stop_table
# 需要导入模块: from DatabaseHandler import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler.DatabaseHandler import _add_addresses_table [as 别名]
def test_construct_db_calls_add_stop_table(self):
handler = DatabaseHandler('unit_test_db.sqlite3')
mock_add_addresses = Mock()
handler._add_addresses_table = mock_add_addresses
mock_add_stops = Mock()
handler._add_stops_table = mock_add_stops
handler.initialize_db()
self.assertTrue(mock_add_stops.called,
"initialize_db did not call _add_stops_table")