def setUp(self):
     db.create_all()
     
     fixture = SQLAlchemyFixture( env=models,
         style=TrimmedNameStyle(suffix="Data"),
         session=db.session)
     try:
         self.data = fixture.data(*self.fixtures)
     except TypeError:
         raise Error('You need overide "fixtures = None" with the name of some real fixtures')
     self.data.setup()
Пример #2
0
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()
Пример #3
0
def create_db():
    db.create_all()
    if not User.query.filter(User.username == 'admin').first():
        user = User('Pimat',
                    'Web',
                    'admin',
                    'pbkdf2:sha256:50000$QZildwvb$ec2954dfe34d5a540d1aa9b64ce8628ab34b4f8d64a04208f15082a431bc5631',
                    '*****@*****.**',
                    'admin')
        db.session.add(user)
        db.session.commit()
Пример #4
0
def load_fixtures():
    # Re-create all tables
    db.drop_all()
    db.create_all()

    game = Game(
        id="hackvan",
        title="Hackvan Trivia",
        description="This is the hackvan game",
        rounds=[
            Round(
                round_number=0,
                answer="lego",
                hints=[
                    Hint(
                        position=2,
                        hint="I have my own theme park in Denmark. Over 200 billion of me have been produced",
                    ),
                    Hint(position=0, hint="I was invented in 1949 By Ole Christianson"),
                    Hint(position=1, hint="I'm made of molded plastic and come in 1700 shapes and every color"),
                ],
            ),
            Round(
                round_number=1,
                answer="everest",
                hints=[
                    Hint(position=2, hint="It is a landmark in Nepal"),
                    Hint(position=0, hint="It is known as Chomolungma in its native language"),
                    Hint(position=1, hint="It is the purpose of life for Edmund Hillary"),
                ],
            ),
            Round(
                round_number=2,
                answer="toes",
                hints=[
                    Hint(position=2, hint="They hide in your shoes and you have 10 of them"),
                    Hint(position=0, hint="They come in different sizes"),
                    Hint(position=1, hint="They are with you since you are born and help you walk"),
                ],
            ),
        ],
    )

    db.session.add_all([game])
    db.session.commit()
Пример #5
0
 def setUp(self):
     db.create_all()