def setUp(self): self.client = app.test_client() db.create_all() # log in as viewer login_response = test_utils.create_user_and_login(username='******', password='******', role='viewer', client=self.client) login_response_dict = json.loads(login_response.data) self.viewer_token = login_response_dict['access_token'] # log in as writer login_response = test_utils.create_user_and_login(username='******', password='******', role='writer', client=self.client) login_response_dict = json.loads(login_response.data) self.writer_token = login_response_dict['access_token'] # log in as admin login_response = test_utils.create_user_and_login(username='******', password='******', role='admin', client=self.client) login_response_dict = json.loads(login_response.data) self.admin_token = login_response_dict['access_token']
def db_create(): """Creating database, if it not exists""" if not database_exists(db_credentials): create_database(db_credentials) db.create_all() db.session.commit() print "Successfully created database and tables." else: print "The database already exists!"
def app(): # setup _app = create_app(TestConfig) # create test tables with _app.app_context(): db.drop_all() db.create_all() yield _app # teardown with _app.app_context(): db.drop_all()
def init_database(): # Create the database and the database table db.create_all() # Insert user data user1 = UserModel('*****@*****.**', 'password1') user2 = UserModel('*****@*****.**', 'password2') user2 = UserModel('*****@*****.**', 'password') db.session.add(user1) db.session.add(user2) # Commit the changes for the users db.session.commit() yield db # This is where the testing happens! db.drop_all()
def init_database(): # Create the database and the database table db.create_all() # Insert user data user1 = User(email='*****@*****.**', plaintext_password='******') user2 = User(email='*****@*****.**', plaintext_password='******') db.session.add(user1) db.session.add(user2) # Commit the changes for the users db.session.commit() yield db # this is where the testing happens! db.drop_all()
def setUp(self): db.create_all()
def setUp(self): super().setUp() self.client = app.test_client() db.create_all()
def setUp(self): self.client = app.test_client() db.create_all()
def init_db(): # Еслм нужно пересоздавать БД, используй migrate or drop_all() # db.drop_all() db.create_all() db.session.commit()
def recreate_db(): db.drop_all() db.create_all() db.session.commit()
def reset_db(): """Drop the database and recreate it.""" db.drop_all() db.create_all()
def db_create_tables(): """Creating all tables.""" db.create_all() print "Successfully created tables."
from backend.app import db from backend.app import Domain, Platform # Create database db.create_all() # Create test domains d1: Domain = Domain(name="canberra") d1_p1: Platform(nbr=1, txt="[lake burley griffin] 8846", domain=d1) d2: Domain = Domain(name="adelaide") d2_p1: Platform(nbr=1, txt="[karrawirra] 12", domain=d2) d2_p2: Platform(nbr=2, txt="[heysen] 5152", domain=d2) d2_p4: Platform(nbr=4, txt="[cleland] 365", domain=d2) d3: Domain = Domain(name="perth") d3_p3: Platform(nbr=3, txt="[joondalup] 6027", domain=d3) d3_p5: Platform(nbr=5, txt="[monger] 144", domain=d3) # Add test domains to database db.session.add(d1) db.session.add(d2) db.session.add(d3) db.session.commit()