Compare commits

..

1 Commits

Author SHA1 Message Date
David McDonald
c58afe2e75 jaeger wip 2020-06-11 10:59:38 +01:00
12 changed files with 92 additions and 214 deletions

View File

@@ -1,23 +1,21 @@
import time
import os
import random
import string
import uuid
from celery import current_task
from flask import _request_ctx_stack, request, g, jsonify, make_response, current_app, has_request_context
from flask import _request_ctx_stack, request, g, jsonify, make_response
from flask_sqlalchemy import SQLAlchemy as _SQLAlchemy
from flask_marshmallow import Marshmallow
from flask_migrate import Migrate
from flask_opentracing import FlaskTracer
from gds_metrics import GDSMetrics
from gds_metrics.metrics import Gauge, Histogram
from jaeger_client import Config as JaegerConfig
from time import monotonic
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
from notifications_utils.clients.statsd.statsd_client import StatsdClient
from notifications_utils.clients.redis.redis_client import RedisClient
from notifications_utils.clients.encryption.encryption_client import Encryption
from notifications_utils import logging, request_helper
from sqlalchemy import event
from werkzeug.exceptions import HTTPException as WerkzeugHTTPException
from werkzeug.local import LocalProxy
@@ -67,11 +65,7 @@ clients = Clients()
api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user)
authenticated_service = LocalProxy(lambda: _request_ctx_stack.top.authenticated_service)
CONCURRENT_REQUESTS = Gauge(
'concurrent_web_request_count',
'How many concurrent requests are currently being served',
)
flask_tracer = FlaskTracer(initialize_tracer, False)
def create_app(application):
@@ -113,13 +107,13 @@ def create_app(application):
register_blueprint(application)
register_v2_blueprints(application)
flask_tracer = FlaskTracer(initialize_tracer, True, application)
# avoid circular imports by importing this file later
from app.commands import setup_commands
setup_commands(application)
# set up sqlalchemy events
setup_sqlalchemy_events(application)
return application
@@ -267,22 +261,17 @@ def register_v2_blueprints(application):
def init_app(app):
@app.before_request
def record_user_agent():
statsd_client.incr("user-agent.{}".format(process_user_agent(request.headers.get('User-Agent', None))))
@app.before_request
def record_request_details():
CONCURRENT_REQUESTS.inc()
g.start = monotonic()
g.endpoint = request.endpoint
@app.after_request
def after_request(response):
CONCURRENT_REQUESTS.dec()
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
@@ -329,82 +318,11 @@ def process_user_agent(user_agent_string):
else:
return "unknown"
def setup_sqlalchemy_events(app):
TOTAL_DB_CONNECTIONS = Gauge(
'db_connection_total_connected',
'How many db connections are currently held (potentially idle) by the server',
def initialize_tracer():
config = JaegerConfig(
config={
"sampler": {"type": "const", "param": 1}
},
service_name="notify-api"
)
TOTAL_CHECKED_OUT_DB_CONNECTIONS = Gauge(
'db_connection_total_checked_out',
'How many db connections are currently checked out by web requests',
)
DB_CONNECTION_OPEN_DURATION_SECONDS = Histogram(
'db_connection_open_duration_seconds',
'How long db connections are held open for in seconds',
['method', 'host', 'path']
)
# need this or db.engine isn't accessible
with app.app_context():
@event.listens_for(db.engine, 'connect')
def connect(dbapi_connection, connection_record):
# connection first opened with db
TOTAL_DB_CONNECTIONS.inc()
@event.listens_for(db.engine, 'close')
def close(dbapi_connection, connection_record):
# connection closed (probably only happens with overflow connections)
TOTAL_DB_CONNECTIONS.dec()
@event.listens_for(db.engine, 'checkout')
def checkout(dbapi_connection, connection_record, connection_proxy):
# connection given to a web worker
TOTAL_CHECKED_OUT_DB_CONNECTIONS.inc()
# this will overwrite any previous checkout_at timestamp
connection_record.info['checkout_at'] = time.monotonic()
# 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():
connection_record.info['request_data'] = {
'method': request.method,
'host': request.host,
'url_rule': request.url_rule.rule if request.url_rule else 'No endpoint'
}
# celery apps
elif current_task:
connection_record.info['request_data'] = {
'method': 'celery',
'host': current_app.config['NOTIFY_APP_NAME'], # worker name
'url_rule': current_task.name, # task name
}
# anything else. migrations possibly.
else:
current_app.logger.warning('Checked out sqlalchemy connection from outside of request/task')
connection_record.info['request_data'] = {
'method': 'unknown',
'host': 'unknown',
'url_rule': 'unknown',
}
@event.listens_for(db.engine, 'checkin')
def checkin(dbapi_connection, connection_record):
# connection returned by a web worker
TOTAL_CHECKED_OUT_DB_CONNECTIONS.dec()
# duration that connection was held by a single web request
duration = time.monotonic() - connection_record.info['checkout_at']
DB_CONNECTION_OPEN_DURATION_SECONDS.labels(
connection_record.info['request_data']['method'],
connection_record.info['request_data']['host'],
connection_record.info['request_data']['url_rule']
).observe(duration)
return config.initialize_tracer()

View File

@@ -6,18 +6,12 @@ from notifications_python_client.errors import (
from notifications_utils import request_helper
from sqlalchemy.exc import DataError
from sqlalchemy.orm.exc import NoResultFound
from gds_metrics import Histogram
from app.dao.services_dao import dao_fetch_service_by_id_with_api_keys
GENERAL_TOKEN_ERROR_MESSAGE = 'Invalid token: make sure your API token matches the example at https://docs.notifications.service.gov.uk/rest-api.html#authorisation-header' # noqa
AUTH_DB_CONNECTION_DURATION_SECONDS = Histogram(
'auth_db_connection_duration_seconds',
'Time taken to get DB connection and fetch service from database',
)
class AuthError(Exception):
def __init__(self, message, code, service_id=None, api_key_id=None):
@@ -93,8 +87,7 @@ def requires_auth():
issuer = __get_token_issuer(auth_token) # ie the `iss` claim which should be a service ID
try:
with AUTH_DB_CONNECTION_DURATION_SECONDS.time():
service = dao_fetch_service_by_id_with_api_keys(issuer)
service = dao_fetch_service_by_id_with_api_keys(issuer)
except DataError:
raise AuthError("Invalid token: service id is not the right data type", 403)
except NoResultFound:

View File

@@ -1,6 +1,5 @@
import time
from gds_metrics.metrics import Histogram
from celery import Celery, Task
from celery.signals import worker_process_shutdown
from flask import g, request
@@ -20,12 +19,6 @@ def log_on_worker_shutdown(sender, signal, pid, exitcode, **kwargs):
def make_task(app):
SQS_APPLY_ASYNC_DURATION_SECONDS = Histogram(
'sqs_apply_async_duration_seconds',
'Time taken to put task on queue',
['task_name']
)
class NotifyTask(Task):
abstract = True
start = None
@@ -59,8 +52,7 @@ def make_task(app):
if has_request_context() and hasattr(request, 'request_id'):
kwargs['request_id'] = request.request_id
with SQS_APPLY_ASYNC_DURATION_SECONDS.labels(self.name).time():
return super().apply_async(args, kwargs, task_id, producer, link, link_error, **options)
return super().apply_async(args, kwargs, task_id, producer, link, link_error, **options)
return NotifyTask

View File

@@ -1,6 +1,6 @@
from sqlalchemy.sql.expression import func
from app import db
from app import db, flask_tracer
from app.dao.dao_utils import VersionOptions, transactional, version_class
from app.models import (
Organisation,
@@ -17,6 +17,7 @@ def dao_get_organisations():
).all()
@flask_tracer.trace()
def dao_count_organisations_with_live_services():
return db.session.query(Organisation.id).join(Organisation.services).filter(
Service.active.is_(True),

View File

@@ -72,8 +72,8 @@ def send_sms_to_provider(notification):
notification.billable_units = template.fragment_count
update_notification_to_sending(notification, provider)
delta_seconds = (datetime.utcnow() - notification.created_at).total_seconds()
statsd_client.timing("sms.total-time", delta_seconds)
delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000
statsd_client.timing("sms.total-time", delta_milliseconds)
def send_email_to_provider(notification):
@@ -118,8 +118,8 @@ def send_email_to_provider(notification):
notification.reference = reference
update_notification_to_sending(notification, provider)
delta_seconds = (datetime.utcnow() - notification.created_at).total_seconds()
statsd_client.timing("email.total-time", delta_seconds)
delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000
statsd_client.timing("email.total-time", delta_milliseconds)
def update_notification_to_sending(notification, provider):

View File

@@ -34,15 +34,6 @@ from app.dao.notifications_dao import (
from app.v2.errors import BadRequestError
from gds_metrics import Histogram
REDIS_GET_AND_INCR_DAILY_LIMIT_DURATION_SECONDS = Histogram(
'redis_get_and_incr_daily_limit_duration_seconds',
'Time taken to get and possibly incremement the daily limit cache key',
)
def create_content_for_notification(template, personalisation):
template_object = template._as_utils_template_with_personalisation(personalisation)
check_placeholders(template_object)
@@ -124,9 +115,8 @@ def persist_notification(
if not simulated:
dao_create_notification(notification)
if key_type != KEY_TYPE_TEST:
with REDIS_GET_AND_INCR_DAILY_LIMIT_DURATION_SECONDS.time():
if redis_store.get(redis.daily_limit_cache_key(service.id)):
redis_store.incr(redis.daily_limit_cache_key(service.id))
if redis_store.get(redis.daily_limit_cache_key(service.id)):
redis_store.incr(redis.daily_limit_cache_key(service.id))
current_app.logger.info(
"{} {} created at {}".format(notification_type, notification_id, notification_created_at)

View File

@@ -22,24 +22,15 @@ from app.utils import get_public_notify_type_text
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
from app.dao.service_letter_contact_dao import dao_get_letter_contact_by_id
from gds_metrics.metrics import Histogram
REDIS_EXCEEDED_RATE_LIMIT_DURATION_SECONDS = Histogram(
'redis_exceeded_rate_limit_duration_seconds',
'Time taken to check rate limit',
)
def check_service_over_api_rate_limit(service, api_key):
if current_app.config['API_RATE_LIMIT_ENABLED'] and current_app.config['REDIS_ENABLED']:
cache_key = rate_limit_cache_key(service.id, api_key.key_type)
rate_limit = service.rate_limit
interval = 60
with REDIS_EXCEEDED_RATE_LIMIT_DURATION_SECONDS.time():
if redis_store.exceeded_rate_limit(cache_key, rate_limit, interval):
current_app.logger.info("service {} has been rate limited for throughput".format(service.id))
raise RateLimitError(rate_limit, interval, api_key.key_type)
if redis_store.exceeded_rate_limit(cache_key, rate_limit, interval):
current_app.logger.info("service {} has been rate limited for throughput".format(service.id))
raise RateLimitError(rate_limit, interval, api_key.key_type)
def check_service_over_daily_message_limit(key_type, service):

View File

@@ -12,7 +12,7 @@ from marshmallow import (
pre_dump,
post_dump
)
from marshmallow_sqlalchemy import auto_field
from marshmallow_sqlalchemy import field_for
from notifications_utils.recipients import (
validate_email_address,
@@ -58,7 +58,7 @@ def _validate_datetime_not_in_past(dte, msg="Date cannot be in the past"):
raise ValidationError(msg)
class BaseSchema(ma.SQLAlchemyAutoSchema):
class BaseSchema(ma.ModelSchema):
def __init__(self, load_json=False, *args, **kwargs):
self.load_json = load_json
@@ -75,17 +75,13 @@ class BaseSchema(ma.SQLAlchemyAutoSchema):
return data
return super(BaseSchema, self).make_instance(data)
class Meta:
include_relationships = True
load_instance = True
class UserSchema(BaseSchema):
permissions = fields.Method("user_permissions", dump_only=True)
password_changed_at = auto_field(format=DATETIME_FORMAT_NO_TIMEZONE)
created_at = auto_field(format=DATETIME_FORMAT_NO_TIMEZONE)
auth_type = auto_field()
password_changed_at = field_for(models.User, 'password_changed_at', format=DATETIME_FORMAT_NO_TIMEZONE)
created_at = field_for(models.User, 'created_at', format=DATETIME_FORMAT_NO_TIMEZONE)
auth_type = field_for(models.User, 'auth_type')
def user_permissions(self, usr):
retval = {}
@@ -96,7 +92,7 @@ class UserSchema(BaseSchema):
retval[service_id].append(x.permission)
return retval
class Meta(BaseSchema.Meta):
class Meta:
model = models.User
exclude = (
"updated_at",
@@ -131,9 +127,9 @@ class UserSchema(BaseSchema):
class UserUpdateAttributeSchema(BaseSchema):
auth_type = auto_field()
auth_type = field_for(models.User, 'auth_type')
class Meta(BaseSchema.Meta):
class Meta:
model = models.User
exclude = (
'id', 'updated_at', 'created_at', 'user_to_service',
@@ -170,7 +166,7 @@ class UserUpdateAttributeSchema(BaseSchema):
class UserUpdatePasswordSchema(BaseSchema):
class Meta(BaseSchema.Meta):
class Meta:
model = models.User
only = ('password')
strict = True
@@ -185,7 +181,7 @@ class UserUpdatePasswordSchema(BaseSchema):
class ProviderDetailsSchema(BaseSchema):
created_by = fields.Nested(UserSchema, only=['id', 'name', 'email_address'], dump_only=True)
class Meta(BaseSchema.Meta):
class Meta:
model = models.ProviderDetails
exclude = ("provider_rates", "provider_stats")
strict = True
@@ -194,7 +190,7 @@ class ProviderDetailsSchema(BaseSchema):
class ProviderDetailsHistorySchema(BaseSchema):
created_by = fields.Nested(UserSchema, only=['id', 'name', 'email_address'], dump_only=True)
class Meta(BaseSchema.Meta):
class Meta:
model = models.ProviderDetailsHistory
exclude = ("provider_rates", "provider_stats")
strict = True
@@ -202,15 +198,15 @@ class ProviderDetailsHistorySchema(BaseSchema):
class ServiceSchema(BaseSchema):
created_by = auto_field(required=True)
organisation_type = auto_field()
created_by = field_for(models.Service, 'created_by', required=True)
organisation_type = field_for(models.Service, 'organisation_type')
letter_logo_filename = fields.Method(dump_only=True, serialize='get_letter_logo_filename')
permissions = fields.Method("service_permissions")
email_branding = auto_field()
organisation = auto_field()
email_branding = field_for(models.Service, 'email_branding')
organisation = field_for(models.Service, 'organisation')
override_flag = False
letter_contact_block = fields.Method(serialize="get_letter_contact")
go_live_at = auto_field(format=DATETIME_FORMAT_NO_TIMEZONE)
go_live_at = field_for(models.Service, 'go_live_at', format=DATETIME_FORMAT_NO_TIMEZONE)
def get_letter_logo_filename(self, service):
return service.letter_branding and service.letter_branding.filename
@@ -221,7 +217,7 @@ class ServiceSchema(BaseSchema):
def get_letter_contact(self, service):
return service.get_default_letter_contact()
class Meta(BaseSchema.Meta):
class Meta:
model = models.Service
dump_only = ['letter_contact_block']
exclude = (
@@ -267,9 +263,9 @@ class ServiceSchema(BaseSchema):
class DetailedServiceSchema(BaseSchema):
statistics = fields.Dict()
organisation_type = auto_field()
organisation_type = field_for(models.Service, 'organisation_type')
class Meta(BaseSchema.Meta):
class Meta:
model = models.Service
exclude = (
'api_keys',
@@ -298,7 +294,7 @@ class DetailedServiceSchema(BaseSchema):
class NotificationModelSchema(BaseSchema):
class Meta(BaseSchema.Meta):
class Meta:
model = models.Notification
strict = True
exclude = ('_personalisation', 'job', 'service', 'template', 'api_key',)
@@ -316,7 +312,7 @@ class BaseTemplateSchema(BaseSchema):
def get_reply_to_text(self, template):
return template.get_reply_to_text()
class Meta(BaseSchema.Meta):
class Meta:
model = models.Template
exclude = ("service_id", "jobs", "service_letter_contact_id")
strict = True
@@ -324,8 +320,8 @@ class BaseTemplateSchema(BaseSchema):
class TemplateSchema(BaseTemplateSchema):
created_by = auto_field(required=True)
process_type = auto_field()
created_by = field_for(models.Template, 'created_by', required=True)
process_type = field_for(models.Template, 'process_type')
redact_personalisation = fields.Method("redact")
def redact(self, template):
@@ -345,7 +341,7 @@ class TemplateHistorySchema(BaseSchema):
reply_to_text = fields.Method("get_reply_to_text", allow_none=True)
created_by = fields.Nested(UserSchema, only=['id', 'name', 'email_address'], dump_only=True)
created_at = auto_field(format=DATETIME_FORMAT_NO_TIMEZONE)
created_at = field_for(models.Template, 'created_at', format=DATETIME_FORMAT_NO_TIMEZONE)
def get_reply_to(self, template):
return template.reply_to
@@ -353,16 +349,16 @@ class TemplateHistorySchema(BaseSchema):
def get_reply_to_text(self, template):
return template.get_reply_to_text()
class Meta(BaseSchema.Meta):
class Meta:
model = models.TemplateHistory
class ApiKeySchema(BaseSchema):
created_by = auto_field(required=True)
key_type = auto_field(required=True)
created_by = field_for(models.ApiKey, 'created_by', required=True)
key_type = field_for(models.ApiKey, 'key_type', required=True)
class Meta(BaseSchema.Meta):
class Meta:
model = models.ApiKey
exclude = ("service", "_secret")
strict = True
@@ -371,9 +367,9 @@ class ApiKeySchema(BaseSchema):
class JobSchema(BaseSchema):
created_by_user = fields.Nested(UserSchema, attribute="created_by",
dump_to="created_by", only=["id", "name"], dump_only=True)
created_by = auto_field(required=True, load_only=True)
created_by = field_for(models.Job, 'created_by', required=True, load_only=True)
job_status = auto_field("name", model=models.JobStatus, required=False)
job_status = field_for(models.JobStatus, 'name', required=False)
scheduled_for = fields.DateTime()
service_name = fields.Nested(
@@ -381,7 +377,7 @@ class JobSchema(BaseSchema):
template_name = fields.Method('get_template_name', dump_only=True)
template_type = fields.Method('get_template_type', dump_only=True)
contact_list_id = auto_field()
contact_list_id = field_for(models.Job, 'contact_list_id')
def get_template_name(self, job):
return job.template.name
@@ -394,7 +390,7 @@ class JobSchema(BaseSchema):
_validate_datetime_not_in_past(value)
_validate_datetime_not_more_than_96_hours_in_future(value)
class Meta(BaseSchema.Meta):
class Meta:
model = models.Job
exclude = (
'notifications',
@@ -406,7 +402,7 @@ class JobSchema(BaseSchema):
class NotificationSchema(ma.Schema):
class Meta(BaseSchema.Meta):
class Meta:
strict = True
status = fields.String(required=False)
@@ -447,7 +443,7 @@ class SmsTemplateNotificationSchema(SmsNotificationSchema):
class NotificationWithTemplateSchema(BaseSchema):
class Meta(BaseSchema.Meta):
class Meta:
model = models.Notification
strict = True
exclude = ('_personalisation', 'scheduled_notification')
@@ -470,7 +466,7 @@ class NotificationWithTemplateSchema(BaseSchema):
created_by = fields.Nested(UserSchema, only=['id', 'name', 'email_address'], dump_only=True)
status = fields.String(required=False)
personalisation = fields.Dict(required=False)
key_type = auto_field(required=True)
key_type = field_for(models.Notification, 'key_type', required=True)
key_name = fields.String()
@pre_dump
@@ -524,9 +520,9 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
class InvitedUserSchema(BaseSchema):
auth_type = auto_field()
auth_type = field_for(models.InvitedUser, 'auth_type')
class Meta(BaseSchema.Meta):
class Meta:
model = models.InvitedUser
strict = True
@@ -540,7 +536,7 @@ class InvitedUserSchema(BaseSchema):
class EmailDataSchema(ma.Schema):
class Meta(BaseSchema.Meta):
class Meta:
strict = True
email = fields.Str(required=True)
@@ -561,7 +557,7 @@ class EmailDataSchema(ma.Schema):
class NotificationsFilterSchema(ma.Schema):
class Meta(BaseSchema.Meta):
class Meta:
strict = True
template_type = fields.Nested(BaseTemplateSchema, only=['template_type'], many=True)
@@ -629,7 +625,7 @@ class ApiKeyHistorySchema(ma.Schema):
class EventSchema(BaseSchema):
class Meta(BaseSchema.Meta):
class Meta:
model = models.Event
strict = True

View File

@@ -7,7 +7,6 @@ from boto.exception import SQSError
from flask import request, jsonify, current_app, abort
from notifications_utils.postal_address import PostalAddress
from notifications_utils.recipients import try_validate_and_format_phone_number
from gds_metrics import Histogram
from app import (
api_user,
@@ -75,12 +74,6 @@ from app.v2.notifications.notification_schemas import (
from app.v2.utils import get_valid_json
POST_NOTIFICATION_JSON_PARSE_DURATION_SECONDS = Histogram(
'post_notification_json_parse_duration_seconds',
'Time taken to parse and validate post request json',
)
@v2_notification_blueprint.route('/{}'.format(LETTER_TYPE), methods=['POST'])
def post_precompiled_letter_notification():
request_json = get_valid_json()
@@ -123,17 +116,16 @@ def post_precompiled_letter_notification():
@v2_notification_blueprint.route('/<notification_type>', methods=['POST'])
def post_notification(notification_type):
with POST_NOTIFICATION_JSON_PARSE_DURATION_SECONDS.time():
request_json = get_valid_json()
request_json = get_valid_json()
if notification_type == EMAIL_TYPE:
form = validate(request_json, post_email_request)
elif notification_type == SMS_TYPE:
form = validate(request_json, post_sms_request)
elif notification_type == LETTER_TYPE:
form = validate(request_json, post_letter_request)
else:
abort(404)
if notification_type == EMAIL_TYPE:
form = validate(request_json, post_email_request)
elif notification_type == SMS_TYPE:
form = validate(request_json, post_sms_request)
elif notification_type == LETTER_TYPE:
form = validate(request_json, post_letter_request)
else:
abort(404)
check_service_has_permission(notification_type, authenticated_service.permissions)

View File

@@ -5,7 +5,7 @@ cffi==1.14.0
celery[sqs]==3.1.26.post2 # pyup: <4
docopt==0.6.2
Flask-Bcrypt==0.7.1
flask-marshmallow==0.12.0
flask-marshmallow==0.11.0
Flask-Migrate==2.5.3
git+https://github.com/mitsuhiko/flask-sqlalchemy.git@500e732dd1b975a56ab06a46bd1a20a21e682262#egg=Flask-SQLAlchemy==2.3.2.dev20190108
Flask==1.1.2
@@ -20,14 +20,14 @@ marshmallow==2.21.0 # pyup: <3 # v3 throws errors
psycopg2-binary==2.8.5
PyJWT==1.7.1
SQLAlchemy==1.3.17
Flask-Opentracing==1.1.0
jaeger-client==4.3.0
notifications-python-client==5.5.1
# PaaS
awscli-cwlogs>=1.4,<1.5
git+https://github.com/alphagov/notifications-utils.git@39.4.4#egg=notifications-utils==39.4.4
git+https://github.com/alphagov/notifications-utils.git@39.4.3#egg=notifications-utils==39.4.3
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
prometheus-client==0.7.1
gds-metrics==0.2.0

View File

@@ -7,7 +7,7 @@ cffi==1.14.0
celery[sqs]==3.1.26.post2 # pyup: <4
docopt==0.6.2
Flask-Bcrypt==0.7.1
flask-marshmallow==0.12.0
flask-marshmallow==0.11.0
Flask-Migrate==2.5.3
git+https://github.com/mitsuhiko/flask-sqlalchemy.git@500e732dd1b975a56ab06a46bd1a20a21e682262#egg=Flask-SQLAlchemy==2.3.2.dev20190108
Flask==1.1.2
@@ -22,16 +22,16 @@ marshmallow==2.21.0 # pyup: <3 # v3 throws errors
psycopg2-binary==2.8.5
PyJWT==1.7.1
SQLAlchemy==1.3.17
Flask-Opentracing==1.1.0
jaeger-client==4.3.0
notifications-python-client==5.5.1
# PaaS
awscli-cwlogs>=1.4,<1.5
git+https://github.com/alphagov/notifications-utils.git@39.4.4#egg=notifications-utils==39.4.4
git+https://github.com/alphagov/notifications-utils.git@39.4.3#egg=notifications-utils==39.4.3
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
prometheus-client==0.7.1
gds-metrics==0.2.0
## The following requirements were added by pip freeze:
@@ -39,14 +39,14 @@ alembic==1.4.2
amqp==1.4.9
anyjson==0.3.3
attrs==19.3.0
awscli==1.18.75
awscli==1.18.76
bcrypt==3.1.7
billiard==3.3.0.23
bleach==3.1.4
blinker==1.4
boto==2.49.0
boto3==1.10.38
botocore==1.16.25
botocore==1.16.26
certifi==2020.4.5.2
chardet==3.0.4
click==7.1.2
@@ -66,8 +66,10 @@ Mako==1.1.3
MarkupSafe==1.1.1
mistune==0.8.4
monotonic==1.5
opentracing==2.3.0
orderedset==2.0.1
phonenumbers==8.11.2
prometheus-client==0.2.0
pyasn1==0.4.8
pycparser==2.20
PyPDF2==1.26.0
@@ -84,6 +86,9 @@ s3transfer==0.3.3
six==1.15.0
smartypants==2.0.1
statsd==3.3.0
threadloop==1.0.2
thrift==0.13.0
tornado==6.0.4
urllib3==1.25.9
webencodings==0.5.1
Werkzeug==1.0.1

View File

@@ -4,7 +4,7 @@ from sqlalchemy.exc import DataError
@pytest.fixture(scope='function')
def app_for_test():
def app_for_test(mocker):
import flask
from flask import Blueprint
from app.authentication.auth import AuthError