當前位置: 首頁>>代碼示例>>Python>>正文


Python Database.destroy_tables方法代碼示例

本文整理匯總了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()
開發者ID:Zacharoo,項目名稱:riot-api,代碼行數:28,代碼來源:test_table_existence.py

示例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    
開發者ID:Zacharoo,項目名稱:riot-api,代碼行數:63,代碼來源:test_obj_initialization.py


注:本文中的model.database.Database.destroy_tables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。