Download CSV option now available.

This commit is contained in:
Nicholas Staples
2016-04-12 14:19:51 +01:00
parent bcdde451af
commit 6ea72182d2
6 changed files with 67 additions and 4 deletions

View File

@@ -126,7 +126,10 @@ def notification_json(service_id,
data = {
'notifications': [{
'to': to,
'template': {'id': template['id'], 'name': template['name']},
'template': {
'id': template['id'],
'name': template['name'],
'template_type': template['template_type']},
'job': {'id': job['id'], 'original_file_name': job['original_file_name']},
'sent_at': sent_at,
'status': status,

View File

@@ -1,6 +1,7 @@
from flask import url_for
from bs4 import BeautifulSoup
import json
from app.utils import generate_notifications_csv
def test_should_return_list_of_all_jobs(app_,
@@ -179,3 +180,26 @@ def test_should_show_notifications_for_a_service_with_next_previous(app_,
assert url_for('main.view_notifications', service_id=service_one['id'], page=1) in content
assert 'Previous page' in content
assert 'Next page' in content
def test_should_download_notifications_for_a_service(app_,
service_one,
api_user_active,
mock_login,
mock_get_user,
mock_get_user_by_email,
mock_get_service,
mock_get_notifications,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.get(url_for(
'main.view_notifications',
service_id=service_one['id'],
download='csv'))
csv_content = generate_notifications_csv(
mock_get_notifications(service_one['id'])['notifications'])
assert response.status_code == 200
assert response.get_data(as_text=True) == csv_content
assert 'text/csv' in response.headers['Content-Type']