Fix tests for sending sms codes.

Since the unit tests delete the data in between tests I need to add the template data for the test for send sms code.
This commit is contained in:
Rebecca Law
2016-06-06 11:51:12 +01:00
parent dbc57e3b58
commit be9fde1420
2 changed files with 54 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import uuid
from datetime import (datetime, date)
import pytest
from flask import current_app
from app import db
from app.models import (
@@ -307,15 +308,6 @@ def sample_email_job(notify_db,
return job
@pytest.fixture(scope='function')
def mock_secret_code(mocker):
def _create():
return '11111'
mock_class = mocker.patch('app.dao.users_dao.create_secret_code', side_effect=_create)
return mock_class
@pytest.fixture(scope='function')
def sample_notification(notify_db,
notify_db_session,
@@ -563,3 +555,37 @@ def mock_mmg_client(mocker, statsd_client=None):
})
client.init_app(current_app, statsd_client)
return client
@pytest.fixture(scope='function')
def sms_code_template(notify_db,
notify_db_session):
user = sample_user(notify_db, notify_db_session)
service = Service.query.get(current_app.config['NOTIFY_SERVICE_ID'])
if not service:
data = {
'id': current_app.config['NOTIFY_SERVICE_ID'],
'name': 'Notify Service',
'message_limit': 1000,
'active': True,
'restricted': False,
'email_from': 'notify.service',
'created_by': user
}
service = Service(**data)
db.session.add(service)
template = Template.query.get(current_app.config['SMS_CODE_TEMPLATE_ID'])
if not template:
data = {
'id': current_app.config['SMS_CODE_TEMPLATE_ID'],
'name': 'Sms code template',
'template_type': 'sms',
'content': '((verify_code))',
'service': service,
'created_by': user,
'archived': False
}
template = Template(**data)
db.session.add(template)
return template