def setUp(self):
'''Creates a test client, disables logging, connects to the database
and creates state and city tables for temporary testing purposes.
'''
self.app = app.test_client()
logging.disable(logging.CRITICAL)
BaseModel.database.connect()
BaseModel.database.create_tables([User, City, Place, State, PlaceBook])
'''Create items in tables for ForeignKeyField requirements'''
self.app.post('/states', data=dict(name="test"))
self.app.post('/states/1/cities', data=dict(
name="test",
state=1
))
self.app.post('/users', data=dict(
first_name="test",
last_name="test",
email="test",
password="test"
))
'''Create two places.'''
for i in range(1, 3):
self.create_place('/places', 'test_' + str(i))
'''Create a book on place 1, belonging to user 1.'''
self.app.post('/places/1/books', data=dict(
place=1,
user=1,
date_start="2000/1/1 00:00:00",
description="test",
number_nights=10,
latitude=0,
longitude=0
))
评论列表
文章目录