def test_context(): ''' Test Configuration ''' app = create_app('testing') app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgres://*****:*****@localhost:5432/verse_testing' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.app_context().push() test_client = app.test_client() with app.app_context(): db.create_all() dummy_user = UserModel({ 'username': '******', 'email': '*****@*****.**', 'password': '******' }) dummy_user.save() token = Auth.generate_token(dummy_user.id) yield test_client, dummy_user, token db.session.close() db.drop_all()
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUG'] = False app.config['BASEDIR'] = os.getcwd() app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \ os.path.join(app.config['BASEDIR'], TEST_DB) self.client = app.test_client() db.drop_all() db.create_all() self.airport1 = Airport( **{ "name": "name1", "city": "city", "country": "country", "iata": "iata", "tz": "tz", "type": "type", "source": "source", }) self.airport2 = Airport( **{ "name": "name2", "city": "city1", "country": "country", "iata": "iata", "tz": "tz3", "type": "type", "source": "source", }) db.session.add(self.airport1) db.session.add(self.airport2) db.session.commit() self.handle = 'test'
def db(app): # Create the tables _db.app = app _db.create_all() yield _db _db.drop_all()
def client(): """Test client for Flask WSGI application""" app = create_app(TestConfig) with app.app_context(): t_client = app.test_client() db.create_all() yield t_client db.drop_all()
def init_dev_data(): """Initializes database with data for development and testing""" db.drop_all() db.create_all() print("Initialized Freelance-Tracker Database.") db.session.commit() print("Added dummy data.")
def setUpClass(self): """Excuted in the beginning of the test, the target of this test is that all tests run in order at once """ """Define test variables and initialize src.""" self.app = create_app() self.client = self.app.test_client self.database_name = "casting_agency_test" self.database_path = "postgresql://*****:*****@{}/{}".format('localhost:5432', self.database_name) # binds the src to the current context self.new_actor = {"name": "Markos24", "age": 23, "gender": "Male"} self.new_movie = {"title": "the real stuff", "release_date": "08/20/2020"} setup_db(self.app, self.database_path) with self.app.app_context(): db.init_app(self.app) # create all tables db.drop_all() db.create_all()
def teardown(): _db.drop_all()
def init_db(): db.drop_all() db.create_all()
def tearDown(self): with app.app_context(): db.session.remove() db.drop_all()
def create_db(): db.drop_all() db.create_all() db.session.commit() click.echo("\nDatabase created.\n")
def tearDownModule(): with app.app_context(): models_db.drop_all()
def teardown(): _db.drop_all() os.unlink(TESTDB_PATH)
def init_db(): """Initializes database and any model objects necessary for assignment""" db.drop_all() db.create_all() print("Initialized Freelance-Tracker Database.")
def db(app): _db.create_all() yield _db _db.drop_all()
def seed_all(): db.drop_all() db.create_all() phones = create_phones() _ = create_tasks(phones)
def tearDown(self): db.session.remove() db.drop_all()
def drop(): print "Dropping tables..." db.drop_all()
def tearDown(self): db.drop_all()