本文整理汇总了Python中model.database.Database.destroy_tables方法的典型用法代码示例。如果您正苦于以下问题:Python Database.destroy_tables方法的具体用法?Python Database.destroy_tables怎么用?Python Database.destroy_tables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.database.Database
的用法示例。
在下文中一共展示了Database.destroy_tables方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTableExistence
# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import destroy_tables [as 别名]
class TestTableExistence(unittest.TestCase):
@classmethod
def setUpClass(self):
self.db = Database('TEST')
self.db.make_tables()
@classmethod
def tearDownClass(self):
self.db.destroy_tables()
def tearDown(self):
self.db.truncate_tables()
def test_when_all_tables_exist(self):
assert 'game_stats' in self.db.Meta.tables.keys()
assert 'game' in self.db.Meta.tables.keys()
assert 'summoner' in self.db.Meta.tables.keys()
assert 'summoner_name' in self.db.Meta.tables.keys()
def test_all_tables_have_rigth_columns(self):
t = TableTester(self.db)
test = t.has_next_table()
while test:
test()
test = t.has_next_table()
示例2: TestObjectInitialization
# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import destroy_tables [as 别名]
class TestObjectInitialization(unittest.TestCase):
@classmethod
def setUpClass(self):
self.db = Database()
self.db.make_tables()
@classmethod
def tearDownClass(self):
self.db.destroy_tables()
def tearDown(self):
self.db.truncate_tables()
def test_when_game_is_made(self):
session = self.db.SessionMaker()
def query_for_game(session):
return session.query(Game).first()
expected = add_a_game(session)
observed = query_for_game(session)
session.close()
assert expected is observed, 'Observed:\t{0}\nExpected:\t{1}'.format(observed, expected)
def test_when_game_stats_is_made(self):
session = self.db.SessionMaker()
def query_for_game_stats():
return session.query(GameStats).filter_by(summoner_name='Bjerson').first()
expected = add_game_stats(session)
observed = query_for_game_stats()
session.close()
assert expected is observed, 'Observed:\t{0}\nExpected:\t{1}'.format(observed, expected)
def test_when_summoner_is_made(self):
session = self.db.SessionMaker()
def query_for_summoner():
return session.query(Summoner).first()
expected = add_a_summoner(session)
observed = query_for_summoner()
session.close()
assert expected is observed, 'Observed:\t{0}\nExpected:\t{1}'.format(observed, expected)
def test_when_summoner_name_is_made(self):
session = self.db.SessionMaker()
def query_for_summoner_name():
return session.query(SummonerName).first()
expected = add_a_summoner_name(session)
observed = query_for_summoner_name()
session.close()
assert expected is observed, 'Observed:\t{0}\nExpected:\t{1}'.format(observed, expected)
def test_when_they_work_together(self):
pass