def setUp(self): """Defines test variables and initializes app""" self.app = create_app( "testing") # initializes app with testing environment variable self.client = self.app.test_client # initialized test client with self.app.app_context(): # binds the app to the current context db.create_all() # create all tables
def setUp(self): app = create_app() app.config.from_object(app_config['testing']) ctx = app.app_context() ctx.push() db.create_all() self.client = app.test_client()
def test_client(): app = create_app() app.config.from_object('config.TestConfig') with app.app_context(): db.create_all() yield app.test_client() db.drop_all()
def setup_db(): app = create_app() app.config.from_object('config.TestConfig') with app.app_context(): db.create_all() yield app db.drop_all()
def app(): app = create_app('testing') with app.app_context(): db.create_all() yield app # Note that we changed return for yield, see below for why db.session.remove() db.drop_all() return app
def setUp(self): self.app = create_app("testing") self.client = self.app.test_client self.movie1 = {'title': 'Star Wars'} self.movie2 = {'title': 'Singularity'} with self.app.app_context(): # create all tables db.create_all()
def setUp(self): self.app = create_app("testing") self.client = self.app.test_client self.genre1 = {'name': 'Horror'} self.genre2 = {'name': 'Comedy'} with self.app.app_context(): # create all tables db.create_all()
def setUp(self): self.user = { 'name': 'Tester', 'username': '******', 'email': '*****@*****.**', 'password': '******', 'bio': 'About me' } db.create_all()
def setUp(self): self.app = create_app("testing") self.client = self.app.test_client self.user = { 'name': 'user', 'email': '*****@*****.**', 'password': '******' } with self.app.app_context(): # create all tables db.create_all()
def test_db(test_app): # pylint: disable=redefined-outer-name """ test db fixture """ # with app context with test_app.app_context(): # create database tables db.create_all() # yield session yield db # drop all tables created db.drop_all()
def create_db(): remaining_retries = 10 success = False while not success and remaining_retries > 0: try: time.sleep(10) db.create_all() success = True except OperationalError: remaining_retries -= 1 logger.info( "OperationalError during create_db. Database might not yet be online. Retry in 10 seconds. " + str(remaining_retries) + " remaining retries.")
def setUp(self): self.app = create_app("testing") self.client = self.app.test_client self.user = UserModel({ 'name': 'user', 'email': '*****@*****.**', 'password': '******' }) self.movie = MovieModel({'title': 'Star Wars'}) with self.app.app_context(): # create all tables db.create_all() self.user.save() self.movie.save()
def setUp(self): """ Test Setup """ self.app = create_app("test") self.client = self.app.test_client self.endpoint = '/semantive/img/' self.content_type = 'application/json' self.body = { 'name': 'semantive_blog_page', 'url': 'https://semantive.com' } with self.app.app_context(): # create all tables db.create_all()
def setUp(self): self.app = create_app("testing") self.client = self.app.test_client self.user1 = { 'name': 'user', 'email': '*****@*****.**', 'password': '******' } self.rental1 = {'movie_id': 1, 'user_id': 1} with self.app.app_context(): # create all tables db.create_all() movie = MovieModel(movie_schema.load({'title': 'test'})) movie.save() user = UserModel(user_schema.load(self.user1)) user.save()
def setUp(self): self.app = app.test_client() if not database_exists(app.config['SQLALCHEMY_DATABASE_URI']): create_database(app.config['SQLALCHEMY_DATABASE_URI']) db.create_all()
def create_db(): db.init_app(app) db.drop_all() db.create_all() db.session.commit()
def setUp(self): db.create_all() self.week_start = now().replace(hour=5, minute=0, second=0, microsecond=0) self.week_end = self.week_start.replace(hour=10)
#!flask/bin/python from migrate.versioning import api from config import SQLALCHEMY_DATABASE_URI from config import SQLALCHEMY_MIGRATE_REPO from src.app import db import os.path db.create_all() if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository') api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) else: api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
def setUp(self): app.config["SECRET_KEY"] = "key" db.create_all()
def buat_db(): """Buat database""" db.create_all()
def create_tables(): db.create_all()
def resource(app): db.create_all() Role.insert_roles() yield resource db.session.remove() db.drop_all()
def create_db(): db.init_app(app=app) db.create_all()
def setUp(self): db.create_all() db.session.commit()
def setUp(self): self.app = create_app('test') self.app_context = self.app.app_context() self.app_context.push() db.create_all() self.client = self.app.test_client()
from src.app import db, create_app from src.orm_models import Player, PlayerScore, GameType, Tournament, Game, Leaderboard from sqlalchemy.sql import func import datetime '''This is used to create an example populated database. Can be run from the root folder of the project with 'python -m src.example' ''' #Setup the database app = create_app('development') app_context = app.app_context() app_context.push() db.drop_all() db.create_all() #This function creates example data in the database def first_example(): #GAME 1 - A chess game with 3 players #Players player_1 = Player(name="Alice") player_2 = Player(name="Bob") player_3 = Player(name="Charles") #Example game type game_type = GameType(name="chess", max_players=3) #Create a chess tournament (created_at defaults to func.now() but is here as an example)
def setUp(self): db.create_all()
def create_schema_and_tables(): db.create_all()
def init_test_database(): app.config.from_pyfile(f'main/settings/test.py') db.create_all()
from src.app.models import Prediction from src.app import db, app db.create_all(app=app)