本文整理汇总了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()
示例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()
示例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()
示例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'})
示例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
示例6: tearDown
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import drop_table [as 别名]
def tearDown(self):
State.drop_table()