2021-07-20 08:01:56 +02:00
|
|
|
import pytest
|
|
|
|
|
2021-07-20 17:32:04 +02:00
|
|
|
from flask import g
|
|
|
|
|
|
|
|
import app as myapp
|
|
|
|
from app import db, create_app
|
2021-07-20 08:01:56 +02:00
|
|
|
from app.auth.models import User, Role, Permission
|
2021-07-20 17:32:04 +02:00
|
|
|
from app.scodoc import sco_bulletins_standard
|
|
|
|
from app.scodoc import notesdb as ndb
|
2021-07-20 08:01:56 +02:00
|
|
|
|
|
|
|
|
2021-07-20 17:32:04 +02:00
|
|
|
@pytest.fixture()
|
2021-07-20 08:01:56 +02:00
|
|
|
def test_client():
|
|
|
|
# Setup
|
2021-07-20 17:32:04 +02:00
|
|
|
myapp.Config.TESTING = True
|
|
|
|
myapp.Config.SQLALCHEMY_DATABASE_URI = "sqlite://"
|
|
|
|
apptest = create_app()
|
2021-07-20 08:01:56 +02:00
|
|
|
# Run tests:
|
2021-07-20 17:32:04 +02:00
|
|
|
with apptest.test_client() as client:
|
|
|
|
with apptest.app_context():
|
2021-07-20 08:01:56 +02:00
|
|
|
db.create_all()
|
|
|
|
Role.insert_roles()
|
2021-07-20 17:32:04 +02:00
|
|
|
g.scodoc_dept = "RT"
|
|
|
|
g.db_conn = ndb.open_dept_connection()
|
2021-07-20 08:01:56 +02:00
|
|
|
yield client
|
2021-07-20 17:32:04 +02:00
|
|
|
ndb.close_dept_connection()
|
|
|
|
# Teardown:
|
|
|
|
db.session.remove()
|
|
|
|
db.drop_all()
|