108536234: created users and roles data and domain model.

You will need to run the /scripts/bootstrap.sh to create the database for test and the app.
This commit is contained in:
Rebecca Law
2015-11-25 15:29:12 +00:00
parent be6b89eea7
commit abe1d8ae17
24 changed files with 519 additions and 89 deletions

39
tests/conftest.py Normal file
View File

@@ -0,0 +1,39 @@
import pytest
from sqlalchemy.schema import MetaData, DropConstraint
from app import create_app, db
from app.models import Roles
@pytest.fixture(scope='module')
def notifications_admin(request):
app = create_app('test')
ctx = app.app_context()
ctx.push()
def teardown():
ctx.pop()
request.addfinalizer(teardown)
return app
@pytest.fixture(scope='module')
def notifications_admin_db(notifications_admin, request):
metadata = MetaData(db.engine)
metadata.reflect()
for table in metadata.tables.values():
for fk in table.foreign_keys:
db.engine.execute(DropConstraint(fk.constraint))
metadata.drop_all()
# Create the tables based on the current model
db.create_all()
# Add base data here
role = Roles(id=1, role='test_role')
db.session.add(role)
db.session.commit()
db.session.flush()
db.session.expunge_all()
db.session.commit()