update dependencies

This commit is contained in:
Leo Hemsted
2017-08-18 15:39:39 +01:00
parent 953e2ae5bd
commit c36e50bef1
10 changed files with 90 additions and 82 deletions

View File

@@ -5,7 +5,7 @@ import uuid
from flask import Flask, _request_ctx_stack
from flask import request, g, jsonify
from flask.ext.sqlalchemy import SQLAlchemy
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
from monotonic import monotonic
from notifications_utils.clients.statsd.statsd_client import StatsdClient

View File

@@ -1,7 +1,7 @@
import uuid
from datetime import datetime
from decimal import Decimal
from flask.ext.script import Command, Manager, Option
from flask_script import Command, Manager, Option
from app import db
from app.dao.monthly_billing_dao import (

View File

@@ -1,4 +1,4 @@
from flask.ext.bcrypt import generate_password_hash, check_password_hash
from flask_bcrypt import generate_password_hash, check_password_hash
from itsdangerous import URLSafeSerializer

View File

@@ -2,8 +2,8 @@
from __future__ import print_function
import os
from flask.ext.script import Manager, Server
from flask.ext.migrate import Migrate, MigrateCommand
from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from app import (create_app, db, commands)
application = create_app()

2
db.py
View File

@@ -1,4 +1,4 @@
from flask.ext.script import Manager, Server
from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from app import create_app, db

View File

@@ -1,25 +1,24 @@
apispec==0.25.0
Flask==0.10.1
Flask-Script==2.0.5
Flask-Migrate==2.1.0
Flask-SQLAlchemy==2.0
psycopg2==2.7.3
SQLAlchemy==1.0.15
SQLAlchemy-Utils==0.32.14
PyJWT==1.5.2
marshmallow==2.4.2
marshmallow-sqlalchemy==0.13.1
flask-marshmallow==0.6.2
Flask-Bcrypt==0.6.2
boto3==1.4.4
monotonic==1.3
statsd==3.2.1
jsonschema==2.6.0
gunicorn==19.7.1
docopt==0.6.2
six==1.10.0
iso8601==0.1.12
boto3==1.4.6
celery==3.1.25 # pyup: <4
docopt==0.6.2
Flask-Bcrypt==0.6.2
Flask-Migrate==2.1.0
Flask-Script==2.0.5
Flask-SQLAlchemy==2.2
Flask==0.12.2
gunicorn==19.7.1
iso8601==0.1.12
jsonschema==2.6.0
marshmallow-sqlalchemy==0.13.1
marshmallow==2.13.6
monotonic==1.3
psycopg2==2.7.3
PyJWT==1.5.2
six==1.10.0
SQLAlchemy-Utils==0.32.14
SQLAlchemy==1.1.13
statsd==3.2.1
notifications-python-client==4.3.1

View File

@@ -1,4 +1,4 @@
from flask.ext.script import Manager, Server
from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from app import (create_app, db, commands)
import os

View File

@@ -1186,7 +1186,7 @@ def test_send_inbound_sms_to_service_retries_if_request_returns_500(notify_api,
mocked.assert_called_with(
exc='Unable to send_inbound_sms_to_service for service_id: {} '
'and url: {}. \n500 Server Error: None'.format(sample_service.id, inbound_api.url),
'and url: {url}. \n500 Server Error: None for url: {url}'.format(sample_service.id, url=inbound_api.url),
queue="retry-tasks")

View File

@@ -41,56 +41,65 @@ def test_receive_notification_returns_received_to_mmg(client, mocker, sample_ser
[str(inbound_sms_id), str(sample_service_full_permissions.id)], queue="notify-internal-tasks")
@pytest.mark.parametrize('provider,headers,data,expected_response', [
(
'mmg',
[('Content-Type', 'application/json')],
json.dumps({
@pytest.mark.parametrize('permissions', [
[SMS_TYPE],
[INBOUND_SMS_TYPE],
])
def test_receive_notification_from_mmg_without_permissions_does_not_persist(
client,
mocker,
notify_db_session,
permissions
):
mocked = mocker.patch("app.notifications.receive_notifications.tasks.send_inbound_sms_to_service.apply_async")
service = create_service(sms_sender='07111111111', service_permissions=permissions)
data = {
"ID": "1234",
"MSISDN": "447700900855",
"MSISDN": "07111111111",
"Message": "Some message to notify",
"Trigger": "Trigger?",
"Number": "testing",
"Channel": "SMS",
"DateRecieved": "2012-06-27 12:33:00"
}),
'RECEIVED'
),
(
'firetext',
None,
{
"Message": "Some message to notify",
"source": "Source",
"time": "2012-06-27 12:33:00",
"destination": "447700900855"
},
'{\n "status": "ok"\n}'
),
])
@pytest.mark.parametrize('permissions', [
([SMS_TYPE]),
([INBOUND_SMS_TYPE]),
])
def test_receive_notification_without_permissions_does_not_create_inbound(
client, mocker, notify_db, notify_db_session, permissions, provider, headers, data, expected_response):
service = sample_service(notify_db, notify_db_session, permissions=permissions)
mocker.patch("app.notifications.receive_notifications.dao_fetch_services_by_sms_sender",
return_value=[service])
mocked_send_inbound_sms = mocker.patch(
"app.notifications.receive_notifications.tasks.send_inbound_sms_to_service.apply_async")
mocked_has_permissions = mocker.patch(
"app.notifications.receive_notifications.has_inbound_sms_permissions", return_value=False)
response = client.post(path='/notifications/sms/receive/{}'.format(provider),
data=data,
headers=headers)
}
response = client.post(
path='/notifications/sms/receive/mmg',
data=json.dumps(data),
headers=[('Content-Type', 'application/json')]
)
assert response.status_code == 200
assert response.get_data(as_text=True) == expected_response
assert len(InboundSms.query.all()) == 0
assert mocked_has_permissions.called
mocked_send_inbound_sms.assert_not_called()
assert response.get_data(as_text=True) == 'RECEIVED'
assert InboundSms.query.count() == 0
assert mocked.called is False
@pytest.mark.parametrize('permissions', [
[SMS_TYPE],
[INBOUND_SMS_TYPE],
])
def test_receive_notification_from_firetext_without_permissions_does_not_persist(
client,
mocker,
notify_db_session,
permissions
):
service = create_service(sms_sender='07111111111', service_permissions=permissions)
mocked = mocker.patch("app.notifications.receive_notifications.tasks.send_inbound_sms_to_service.apply_async")
data = "source=07999999999&destination=07111111111&message=this is a message&time=2017-01-01 12:00:00"
response = client.post(
path='/notifications/sms/receive/firetext',
data=data,
headers=[('Content-Type', 'application/x-www-form-urlencoded')]
)
assert response.status_code == 200
result = json.loads(response.get_data(as_text=True))
assert result['status'] == 'ok'
assert InboundSms.query.count() == 0
assert mocked.called is False
@pytest.mark.parametrize('permissions,expected_response', [

View File

@@ -5,8 +5,8 @@ import boto3
import pytest
from alembic.command import upgrade
from alembic.config import Config
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script import Manager
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from app import create_app, db
@@ -18,16 +18,16 @@ def notify_api():
# deattach server-error error handlers - error_handler_spec looks like:
# {'blueprint_name': {
# status_code: [error_handlers],
# None: [ tuples of (exception, )]
# None: { ExceptionClass: error_handler }
# }}
for error_handlers in app.error_handler_spec.values():
error_handlers.pop(500, None)
if None in error_handlers:
error_handlers[None] = [
exception_handler
for exception_handler in error_handlers[None]
if exception_handler[0] != Exception
]
error_handlers[None] = {
exc_class: error_handler
for exc_class, error_handler in error_handlers[None].items()
if exc_class != Exception
}
if error_handlers[None] == []:
error_handlers.pop(None)