Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 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()
Ejemplo n.º 4
0
 def tearDown(self):
     """Remove tables from airbnb_test database upon completion of test."""
     ReviewUser.drop_table()
     ReviewPlace.drop_table()
     Review.drop_table()
     Place.drop_table()
     City.drop_table()
     State.drop_table()
     User.drop_table()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
 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()
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
    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'})
Ejemplo n.º 9
0
 def tearDown(self):
     """
     Remove state table from airbnb_test database upon completion of test
     case.
     """
     State.drop_table()  # drop state table from database
Ejemplo n.º 10
0
 def tearDown(self):
     State.drop_table()