place.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:airbnb_clone 作者: bennettbuchanan 项目源码 文件源码
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
        ))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号