Merge pull request #829 from alphagov/feat-add-endpoint-for-service-monthly-usage-stats

Add endpoint for service monthly usage stats by template
This commit is contained in:
imdadahad
2017-03-09 16:12:22 +00:00
committed by GitHub
9 changed files with 270 additions and 46 deletions

View File

@@ -26,10 +26,11 @@ from app.dao.provider_details_dao import (
)
from app.models import Service, Template
from app.utils import get_london_midnight_in_utc
from tests.app.db import create_notification, create_service, create_template
from tests.app.db import create_notification, create_service
from tests.app.conftest import (
sample_job as create_sample_job,
sample_notification_history as create_notification_history
sample_notification_history as create_notification_history,
create_custom_template
)
from tests.conftest import set_config_values
from unittest.mock import call, patch, PropertyMock
@@ -43,12 +44,13 @@ def _create_slow_delivery_notification(provider='mmg'):
service = create_service(
service_id=current_app.config.get('FUNCTIONAL_TEST_PROVIDER_SERVICE_ID')
)
template = Template.query.get(current_app.config['FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID'])
if not template:
template = create_template(
template_id=current_app.config.get('FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID'),
service=service
template = create_custom_template(
service=service,
user=service.users[0],
template_config_name='FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID',
template_type='sms'
)
create_notification(