def app(): _app = create_app(TestConfig) ctx = _app.test_request_context() ctx.push() yield _app ctx.pop()
for line in open('.env'): var = [item.strip() for item in line.strip().split('=')] if len(var) == 2: os.environ[var[0]] = var[1] # pick a configuration object if os.environ.get("COMPORT_ENV") == 'prod': config_object = ProdConfig else: # No Slack webhook URL for testing if 'SLACK_WEBHOOK_URL' in os.environ: del(os.environ['SLACK_WEBHOOK_URL']) config_object = DevConfig # create the app app = create_app(config_object) HERE = os.path.abspath(os.path.dirname(__file__)) TEST_PATH = os.path.join(HERE, 'tests') manager = Manager(app) def _make_context(): """Return context dict for a shell session so you can access app, db, and the User model by default. """ return {'app': app, 'db': db, 'User': User, 'Department': Department, 'Extractor': Extractor, 'UseOfForceIncident': UseOfForceIncident, "CitizenComplaint": CitizenComplaint, "OfficerInvolvedShooting": OfficerInvolvedShooting} @manager.command def test():
for line in open('.env'): var = [item.strip() for item in line.strip().split('=')] if len(var) == 2: os.environ[var[0]] = var[1] # pick a configuration object if os.environ.get("COMPORT_ENV") == 'prod': config_object = ProdConfig else: # No Slack webhook URL for testing if 'SLACK_WEBHOOK_URL' in os.environ: del (os.environ['SLACK_WEBHOOK_URL']) config_object = DevConfig # create the app app = create_app(config_object) HERE = os.path.abspath(os.path.dirname(__file__)) TEST_PATH = os.path.join(HERE, 'tests') manager = Manager(app) def _make_context(): ''' Return context dict for a shell session. ''' # generate a list of all the incident classes short_names = ["IMPD", "BPD"] incident_prefixes = [ "UseOfForceIncident", "AssaultOnOfficer", "CitizenComplaint", "OfficerInvolvedShooting"
from comport.app import create_app from comport.user.models import User, Role from comport.department.models import Department, Extractor from comport.settings import DevConfig, ProdConfig, Config from comport.database import db from comport.utils import parse_csv_date from comport.data.models import UseOfForceIncident, CitizenComplaint, DenominatorValue, DemographicValue, OfficerInvolvedShooting import glob import csv import hashlib from testclient.JSON_test_client import JSONTestClient if os.environ.get("COMPORT_ENV") == 'prod': app = create_app(ProdConfig) else: app = create_app(DevConfig) HERE = os.path.abspath(os.path.dirname(__file__)) TEST_PATH = os.path.join(HERE, 'tests') manager = Manager(app) def _make_context(): """Return context dict for a shell session so you can access app, db, and the User model by default. """ return {'app': app, 'db': db, 'User': User, 'Department': Department, 'Extractor': Extractor, 'UseOfForceIncident': UseOfForceIncident, "CitizenComplaint": CitizenComplaint, "OfficerInvolvedShooting": OfficerInvolvedShooting}