当前位置: 首页>>代码示例>>Python>>正文


Python State.drop_table方法代码示例

本文整理汇总了Python中app.models.state.State.drop_table方法的典型用法代码示例。如果您正苦于以下问题:Python State.drop_table方法的具体用法?Python State.drop_table怎么用?Python State.drop_table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.models.state.State的用法示例。


在下文中一共展示了State.drop_table方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import drop_table [as 别名]
 def tearDown(self):
     """
     Remove city table from airbnb_test database upon completion of test
     case.
     """
     # drop tables from database
     City.drop_table()
     State.drop_table()
开发者ID:WilliamMcCann,项目名称:airbnb_clone,代码行数:10,代码来源:city.py

示例2: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import drop_table [as 别名]
 def tearDown(self):
     """
     Remove place table from airbnb_test database upon completion of test
     case.
     """
     Place.drop_table()
     City.drop_table()
     State.drop_table()
     User.drop_table()
开发者ID:WilliamMcCann,项目名称:airbnb_clone,代码行数:11,代码来源:place.py

示例3: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import drop_table [as 别名]
 def tearDown(self):
     """
     Remove placebook table from airbnb_test database upon completion of
     test case.
     """
     # drop tables from database
     PlaceBook.drop_table()
     Place.drop_table()
     City.drop_table()
     State.drop_table()
     User.drop_table()
开发者ID:WilliamMcCann,项目名称:airbnb_clone,代码行数:13,代码来源:place_book.py

示例4: test_create

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import drop_table [as 别名]
    def test_create(self):
        """
        Test proper creation (or non-creation) of state records upon POST
        requests to API.
        """
        # test creation of state with all parameters provided in POST request

        State.drop_table()
        database.create_tables([State], safe=True)

        POST_request1 = self.app.post('/states', data=dict(
            name='namestring'
        ))

        self.assertEqual(POST_request1.status[:3], '200')

        now = datetime.now().strftime('%d/%m/%Y %H:%M')

        self.assertEqual(State.get(State.id == 1).name, 'namestring')
        self.assertEqual(State.get(State.id == 1).created_at.strftime('%d/%m/%Y %H:%M'), now)
        self.assertEqual(State.get(State.id == 1).updated_at.strftime('%d/%m/%Y %H:%M'), now)

        # test creation of state in all cases of a parameter missing in POST request
        POST_request2 = self.app.post('/states', data=dict())
        self.assertEqual(POST_request2.status[:3], '400')

        # test that state ID for sole record in database is correct
        self.assertEqual(State.select().get().id, 1)

        # test that a post request with a duplicate name value is rejected
        POST_request3 = self.app.post('/states', data=dict(
            name='namestring'
        ))

        self.assertEqual(POST_request3.status[:3], '409')
        self.assertEqual(json.loads(POST_request3.data), {'code': 10001, 'msg': 'State already exists'})
开发者ID:WilliamMcCann,项目名称:airbnb_clone,代码行数:38,代码来源:state.py

示例5: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import drop_table [as 别名]
 def tearDown(self):
     """
     Remove state table from airbnb_test database upon completion of test
     case.
     """
     State.drop_table()  # drop state table from database
开发者ID:WilliamMcCann,项目名称:airbnb_clone,代码行数:8,代码来源:state.py

示例6: tearDown

# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import drop_table [as 别名]
 def tearDown(self):
     State.drop_table()
开发者ID:papamuziko,项目名称:sample_airbnb_clone,代码行数:4,代码来源:state.py


注:本文中的app.models.state.State.drop_table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。