def setUp(self): app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" with app.app_context(): db.init_app(app) db.create_all() self.app = app.test_client() self.app_context = app.app_context
def setUp(self): with app.app_context(): db.create_all() self.app = app.test_client self.app_context = app.app_context
def setUp(self): # Make sure database exists with app.app_context(): db.create_all() # Get a test client self.app = app.test_client self.app_context = app.app_context
def setUp(self): # Make sure database exists - executes for each test method with app.app_context(): db.create_all() # Get a new test client for each test self.app = app.test_client() self.app_context = app.app_context
def setUp(self): # Make sure database exists app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' with app.app_context(): db.init_app(app) db.create_all() # Get a test client self.app = app.test_client() self.app_context = app.app_context
def test_crud(self): with app.app_context(): user = UserModel('mahsan', 'm1234') self.assertIsNone(UserModel.find_by_username('mahsan')) self.assertIsNone(UserModel.find_by_id(1)) user.save_to_db() self.assertIsNotNone(UserModel.find_by_username('mahsan')) self.assertIsNotNone(UserModel.find_by_id(1))
def tearDown(self): # Database is blank with app.app_context(): db.session.remove() db.drop_all()
def tearDown(self): with app.app_context(): db.session.remove() db.drop_all()
def setUpClass(cls): app.config[ 'SQLALCHEMY_DATABASE_URI'] = BaseTest.SQLALCHEMY_DATABASE_URI app.config['DEBUG'] = False with app.app_context(): db.init_app(app)
def setUpClass(cls): app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' with app.app_context(): db.init_app(app)
def setUpClass(cls): app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' app.config['DEBUG'] = False app.config['PROPAGATION_EXCEPTION'] = True with app.app_context(): db.init_app(app)