def setUp(self): self.app = app.test_client() logging.disable(logging.CRITICAL) database.connect() database.create_tables([City, State], safe=True) rv = self.app.post("/states", data=state_1) self.assertEqual(rv.status_code, 201)
def setUp(self): self.app = app.test_client() logging.disable(logging.CRITICAL) database.connect() database.create_tables([User, State, City, Place, Review, ReviewUser, ReviewPlace], safe=True) #Creating user rv = self.app.post("/users", data=user_1) self.assertEqual(rv.status_code, 201)
def setUp(self): """ Overload def setUp(self): to create a test client of airbnb app, and create amenity table in airbnb_test database. """ self.app = app.test_client() # set up test client self.app.testing = True # set testing to True logging.disable(logging.CRITICAL) # disable logs database.connect() # connect to airbnb_test db database.create_tables([Amenity], safe=True) # create amenity table
def setUp(self): """ Overload def setUp(self): to create a test client of airbnb app, and create state table in airbnb_test database. """ self.app = app.test_client() # set up test client self.app.testing = True # set testing to True logging.disable(logging.CRITICAL) # disable logs database.connect() # connect to airbnb_test db database.create_tables([State], safe=True) # create state table
def setUp(self): self.app = app.test_client() logging.disable(logging.CRITICAL) database.connect() database.create_tables( [User, State, City, Place, Review, ReviewUser, ReviewPlace], safe=True) #Creating user rv = self.app.post("/users", data=user_1) self.assertEqual(rv.status_code, 201)
def setUp(self): """ Overload def setUp(self): to create a test client of airbnb app, and create placebook table in airbnb_test database. """ self.app = app.test_client() # set up test client self.app.testing = True # set testing to True logging.disable(logging.CRITICAL) # disable logs # connect to airbnb_test database and create tables database.connect() database.create_tables([User, State, City, Place, PlaceBook], safe=True) # create user record for route user_record = User(email='anystring', password='******', first_name='anystring2', last_name='anystring3') user_record.save() # create state record for route state_record = State(name="foo-state") state_record.save() # create city record for route city_record = City(name="foo-city", state="1") city_record.save() # create place records for route place_record = Place(owner=1, city=1, name="foo", description="foo description", number_rooms=1, number_bathrooms=1, max_guest=1, price_by_night=1, latitude=20.0, longitude=22.0) place_record.save() place_record2 = Place(owner=1, city=1, name="foo", description="foo description", number_rooms=1, number_bathrooms=1, max_guest=1, price_by_night=1, latitude=20.0, longitude=22.0) place_record2.save()
def setUp(self): """ Overload def setUp(self): to create a test client of airbnb app, and create placebook table in airbnb_test database. """ self.app = app.test_client() # set up test client self.app.testing = True # set testing to True logging.disable(logging.CRITICAL) # disable logs # connect to airbnb_test database and create tables database.connect() database.create_tables([User, State, City, Place, PlaceBook], safe=True) # create user record for route user_record = User( email='anystring', password='******', first_name='anystring2', last_name='anystring3' ) user_record.save() # create state record for route state_record = State(name="foo-state") state_record.save() # create city record for route city_record = City(name="foo-city", state="1") city_record.save() # create place records for route place_record = Place( owner=1, city=1, name="foo", description="foo description", number_rooms=1, number_bathrooms=1, max_guest=1, price_by_night=1, latitude=20.0, longitude=22.0 ) place_record.save() place_record2 = Place( owner=1, city=1, name="foo", description="foo description", number_rooms=1, number_bathrooms=1, max_guest=1, price_by_night=1, latitude=20.0, longitude=22.0 ) place_record2.save()
def setUp(self): self.app = app.test_client() logging.disable(logging.CRITICAL) database.connect() database.create_tables([City, State, Place, User, PlaceBook], safe=True) rv = self.app.post('/states', data=state_1) self.assertEqual(rv.status_code, 201) rv = self.app.post('/states/1/cities', data=city_1) self.assertEqual(rv.status_code, 201) rv = self.app.post('/users', data=user_1) self.assertEqual(rv.status_code, 201)
def setUp(self): """ Overload def setUp(self): to create a test client of airbnb app, and create review table in airbnb_test database. """ self.app = app.test_client() # set up test client self.app.testing = True # set testing to True logging.disable(logging.CRITICAL) # disable logs database.connect() # connect to airbnb_test db database.create_tables( # create tables [User, State, City, Place, Review, ReviewUser, ReviewPlace], safe=True ) # create user record for routes user_record = User( email='anystring', password='******', first_name='anystring2', last_name='anystring3' ) user_record.save() user_record2 = User( email='anystring-2', password='******', first_name='anystring2', last_name='anystring3' ) user_record2.save() # create place records (and dependencies) for routes state_record = State(name='foo-statee') state_record.save() city_record = City(name='foo-city', state=1) city_record.save() place_record = Place( owner_id=1, city_id=1, name="foo", description="foo description", number_rooms=1, number_bathrooms=1, max_guest=1, price_by_night=1, latitude=20.0, longitude=22.0 ) place_record.save()
def setUp(self): """ Overload def setUp(self): to create a test client of airbnb app, and create city table in airbnb_test database. """ self.app = app.test_client() # set up test client self.app.testing = True # set testing to True logging.disable(logging.CRITICAL) # disable logs # connect to airbnb_test db and create tables database.connect() database.create_tables([State, City], safe=True) # create state record for route state_record = State(name='namestring') state_record.save()
def init_database(): database.connect() database.create_tables([Post, User]) User.truncate_table() Post.truncate_table() repos = load_json('repos.json') for repo in repos: user, created = build_user(repo['owner']['login']) Post.create(title=repo['name'], slug=repo['full_name'], body=repo['description'], user=user) database.close()
def setUp(self): self.app = app.test_client() logging.disable(logging.CRITICAL) database.connect() database.create_tables([State], safe=True)
def before_request(): database.connect()
def setUp(self): self.app = app.test_client() logging.disable(logging.CRITICAL) database.connect() database.create_tables([Amenity, PlaceAmenities, Place, State, User, City], safe=True)
from app.models.base import database from app.models.user import User from app.models.city import City from app.models.state import State from app.models.place import Place from app.models.place_book import PlaceBook from app.models.amenity import Amenity from app.models.place_amenity import PlaceAmenities from app.models.review import Review from app.models.review_user import ReviewUser from app.models.review_place import ReviewPlace database.connect() database.create_tables([User, State, City, Place, Amenity, PlaceBook, PlaceAmenities, Review, ReviewUser, ReviewPlace], safe = True) database.close()
def create_tables(): database.connect() database.create_tables([User, State, City, Place, PlaceBook, Amenity, PlaceAmenities])
from app.models.base import database from app.models.user import User from app.models.city import City from app.models.state import State from app.models.place import Place from app.models.place_book import PlaceBook from app.models.amenity import Amenity from app.models.place_amenity import PlaceAmenities from app.models.review import Review from app.models.review_place import ReviewPlace from app.models.review_user import ReviewUser ''' Initializes each table in the database ''' database.connect() database.create_tables([User, State, City, Place, Amenity, PlaceBook, PlaceAmenities, Review, ReviewUser, ReviewPlace], safe=True) database.close()