mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
set test_errors app fixture to session scope
we have one global metrics variable `metrics = GDSMetrics()`, and we then call `metrics.init_app` from within the flask application set up. The v2/test_errors.py app_for_test fixture calls create_app, would call metrics.init_app multiple times for the same metrics instance. This causes errors, so change the fixture to session level so it only calls once per test run.
This commit is contained in:
committed by
David McDonald
parent
faa8faa0c4
commit
cd9b80f415
@@ -368,9 +368,9 @@ def setup_sqlalchemy_events(app):
|
||||
# this will overwrite any previous checkout_at timestamp
|
||||
connection_record.info['checkout_at'] = time.monotonic()
|
||||
|
||||
# checkin runs after the request is already torn down so we'll need to capture request info earlier.
|
||||
# checkout runs when the connection is first used, ie: when we first make a query, so within the request or
|
||||
# task
|
||||
# checkin runs after the request is already torn down, therefore we add the request_data onto the
|
||||
# connection_record as otherwise it won't have that information when checkin actually runs.
|
||||
# Note: this is not a problem for checkouts as the checkout always happens within a web request or task
|
||||
|
||||
# web requests
|
||||
if has_request_context():
|
||||
|
||||
@@ -3,8 +3,8 @@ from flask import url_for
|
||||
from sqlalchemy.exc import DataError
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def app_for_test(mocker):
|
||||
@pytest.fixture(scope='session')
|
||||
def app_for_test():
|
||||
import flask
|
||||
from flask import Blueprint
|
||||
from app.authentication.auth import AuthError
|
||||
|
||||
Reference in New Issue
Block a user