mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
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:
39
tests/conftest.py
Normal file
39
tests/conftest.py
Normal 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()
|
||||
Reference in New Issue
Block a user