Example #1
0
 def tearDown(self):
     """
     Tear Down
     """
     with self.app.app_context():
         db.session.remove()
         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 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()
Example #4
0
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
Example #5
0
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()
Example #6
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Example #7
0
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)
Example #8
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Example #9
0
def resource(app):
    db.create_all()
    Role.insert_roles()
    yield resource
    db.session.remove()
    db.drop_all()
Example #10
0
def drop_all_tables():
    db.drop_all()
Example #11
0
def create_db():
    db.init_app(app)
    db.drop_all()
    db.create_all()
    db.session.commit()
Example #12
0
def drop_db():
    db.init_app(app=app)
    db.drop_all()
Example #13
0
def drop_db():
    """Drop database tables."""
    db.drop_all()
Example #14
0
def drop_db():
    db.drop_all()
Example #15
0
def drop_schema_and_tables():
    db.drop_all()