def setUp(self): """Initialize test variables """ self.app = create_app(config_name="testing") self.client = self.app.test_client self.user_data = { 'name': 'guy', 'email': '*****@*****.**', 'password': '******' } self.bucketlist = { 'name': 'list1', 'date': '01012018', 'description': 'Some description' } self.bucketlist_item1 = { 'name': 'bucketlist_item1', 'description': 'Do stuff' } self.bucketlist_item2 = { 'name': 'bucketlist_item2', 'description': 'Do a little more stuff' } with self.app.app_context(): db.session.close() db.drop_all() db.create_all()
def tearDown(self): """Tear down initialized variables """ with self.app.app_context(): # drop all tables db.session.remove() db.drop_all()
def db(app): """Session-wide test database.""" _db.app = app _db.create_all() yield _db _db.drop_all()
def client(): basedir = os.path.abspath(os.path.dirname(__file__)) test_db_dir = os.path.join(basedir, "test.db") app = create_app("testing", "sqlite:///" + test_db_dir) test_client = app.test_client() with app.app_context(): db.create_all() yield test_client db.drop_all()
def setUp(self): ''' Define test variables and initialize app. ''' self.app = create_app(config_name="testing") self.client = self.app.test_client with self.app.app_context(): db.session.close() db.drop_all() db.create_all()
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = POSTGRESQL_TEST_DB self.app = app.test_client() db.drop_all() db.get_engine(app).connect().execute( 'DROP FUNCTION IF EXISTS post_search_vector_update();') db.create_all() self._populate_db_with_users()
def db(app): """A database for the tests.""" _db.app = app with app.app_context(): _db.create_all() yield _db # Explicitly close DB connection _db.session.close() _db.drop_all()
def session(application, docker_container): assert db.get_app().config['TESTING'] db.session.rollback() db.drop_all() db.create_all() try: yield db.session except Exception: raise finally: # Roll back any trasactions that are in place before continuing db.session.rollback() db.drop_all()
def setUp(self): self.app = create_app(config_name="testing") # Set up the test client self.client = self.app.test_client self.user_data = json.dumps( dict({ "username": "******", "email": "*****@*****.**", "password": "******" })) with self.app.app_context(): # create all tables db.session.close() db.drop_all() db.create_all()
def init_database(): #db = SQLAlchemy() # Create the database and the database table db.create_all() # Insert user data data = {'Name': 'Dog', 'Age': 5, 'Weight': 60, 'Human': False, 'Hat': None} character_schema = CharacterSchema() chara1 = Character(**data) db.session.add(chara1) # Commit the changes for the users db.session.commit() yield db db.session.close() db.drop_all()
def initdb(): db.drop_all(bind=None) db.create_all(bind=None) # add sample user user = User(username="******", email="*****@*****.**", active=True, password='******', confirmed=True) user_role = Role(name='user') db.session.add(user_role) admin_role = Role(name='admin') db.session.add(admin_role) user.roles.append(fetch_admin_role()) user.roles.append(fetch_user_role()) db.session.add(user) db.session.commit() config = BrowseConfig(name="config-test", address='ws://172.0.0.3:8888', user_id=user.id) db.session.add(config) db.session.commit()
def tearDown(self): db.session.remove() db.drop_all()
def refresh_db(): with app.app_context(): db.drop_all() db.create_all() create_sample_users() create_sample_vocabulary_memories(10)
def clear_mysql(app: fixture): """清理 mysql 数据""" yield with app.app_context(): db.session.commit() db.drop_all()
def tearDown(self): with self.app_context(): db.session.remove() db.drop_all()
def tearDown(self): with self.app.app_context(): # Drop all tables db.session.remove() db.drop_all()
def tearDown(self) -> None: """teardown all initialized variables.""" with self.app.app_context(): # drop all tables db.session.remove() db.drop_all()
def tearDown(self): db.drop_all() self.context.pop()
def drop(): db.drop_all() return "Database has been dropped"
def setUp(self): app = self.create_app() db.drop_all() db.create_all() db.session.commit()
erat volutpat. In in eros diam.</p> <p>Donec sollicitudin magna non nibh viverra, non finibus magna posuere. Curabitur pretium ligula lacus, quis cursus arcu ultricies elementum. In vitae dui sed magna feugiat facilisis eget a lorem. Mauris turpis dui, placerat ac massa sed, mollis commodo lorem. In suscipit nunc in neque lobortis, nec aliquam nulla ultricies. Donec dictum mi non tortor finibus porta. Morbi gravida, tortor sed consectetur mattis, neque nulla varius nisl, posuere tristique enim nisi nec quam. Aliquam in ex nulla. Duis gravida ut lacus in laoreet. Fusce non risus aliquet, consequat elit ut, pharetra neque. Donec vitae mollis lacus. In fringilla viverra nisi. Pellentesque tristique lectus nibh, ac sagittis quam mollis ac. Fusce mollis aliquet sapien, et finibus sem vestibulum quis.</p>""", ] db.drop_all() db.get_engine(app).connect().execute( 'DROP FUNCTION IF EXISTS post_search_vector_update();') db.configure_mappers() db.create_all() users = [ models.User('admin', '1', 'Administrator'), models.User('hal', '2', 'Hal Jordan'), ] for user in users: db.session.add(user) db.session.commit() user_1 = models.User.query.filter(models.User.login == 'admin').first()
def drop(): # 删除数据库 db.drop_all() return '数据库删除完成'
def drop_db(): db.drop_all()
def tearDown(self): print("Dropping all test tables") db.session.commit() db.drop_all()
def teardown(self): db.session.remove() db.drop_all() self.app_context.pop()
def testTearDown(cls, test): """Tear down the database per test case""" db.session.remove() db.drop_all()
def littleBobby(): db.drop_all()