Merge pull request #1083 from alphagov/removed-download-link

Removed download link on the notifications page.
This commit is contained in:
Chris Hill-Scott
2017-01-24 17:29:00 +00:00
committed by GitHub
2 changed files with 39 additions and 89 deletions

View File

@@ -5,11 +5,6 @@
<div class="ajax-block-container"> <div class="ajax-block-container">
{% if notifications %} {% if notifications %}
<p class="bottom-gutter">
<a href="{{ download_link }}" download="download" class="heading-small">Download this report</a>
&emsp;
Data available for 7 days
</p>
<div class='dashboard-table'> <div class='dashboard-table'>
{% endif %} {% endif %}
{% call(item, row_number) list_table( {% call(item, row_number) list_table(

View File

@@ -344,12 +344,10 @@ def test_should_show_updates_for_one_job_as_json(
] ]
) )
def test_can_show_notifications( def test_can_show_notifications(
app_, logged_in_client,
service_one, service_one,
active_user_with_permissions,
mock_get_notifications, mock_get_notifications,
mock_get_detailed_service, mock_get_detailed_service,
mocker,
message_type, message_type,
page_title, page_title,
status_argument, status_argument,
@@ -357,91 +355,48 @@ def test_can_show_notifications(
page_argument, page_argument,
expected_page_argument expected_page_argument
): ):
# todo refactor, possibly consider deleting? response = logged_in_client.get(url_for(
with app_.test_request_context(): 'main.view_notifications',
with app_.test_client() as client: service_id=service_one['id'],
client.login(active_user_with_permissions, mocker, service_one) message_type=message_type,
response = client.get(url_for( status=status_argument,
'main.view_notifications', page=page_argument))
service_id=service_one['id'], assert response.status_code == 200
message_type=message_type, content = response.get_data(as_text=True)
status=status_argument, notifications = notification_json(service_one['id'])
page=page_argument)) notification = notifications['notifications'][0]
assert response.status_code == 200 assert notification['to'] in content
content = response.get_data(as_text=True) assert notification['status'] in content
notifications = notification_json(service_one['id']) assert notification['template']['name'] in content
notification = notifications['notifications'][0] page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert notification['to'] in content assert page_title in page.h1.text.strip()
assert notification['status'] in content
assert notification['template']['name'] in content
assert 'csv' in content
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page_title in page.h1.text.strip()
assert url_for(
'.view_notifications_csv',
service_id=service_one['id'],
message_type=message_type,
status=status_argument
) == page.findAll("a", {"download": "download"})[0]['href']
path_to_json = page.find("div", {'data-key': 'notifications'})['data-resource']
url = urlparse(path_to_json) path_to_json = page.find("div", {'data-key': 'notifications'})['data-resource']
assert url.path == '/services/{}/notifications/{}.json'.format(service_one['id'], message_type)
query_dict = parse_qs(url.query)
if status_argument:
assert query_dict['status'] == [status_argument]
if expected_page_argument:
assert query_dict['page'] == [str(expected_page_argument)]
mock_get_notifications.assert_called_with( url = urlparse(path_to_json)
limit_days=7, assert url.path == '/services/{}/notifications/{}.json'.format(service_one['id'], message_type)
page=expected_page_argument, query_dict = parse_qs(url.query)
service_id=service_one['id'], if status_argument:
status=expected_api_call, assert query_dict['status'] == [status_argument]
template_type=[message_type] if expected_page_argument:
) assert query_dict['page'] == [str(expected_page_argument)]
csv_response = client.get(url_for( mock_get_notifications.assert_called_with(
'main.view_notifications_csv', limit_days=7,
service_id=service_one['id'], page=expected_page_argument,
message_type=message_type, service_id=service_one['id'],
download='csv' status=expected_api_call,
)) template_type=[message_type]
)
notifications_json = mock_get_notifications(service_one['id'], template_type=[message_type])['notifications'] json_response = logged_in_client.get(url_for(
notifications_as_csv = _csv_notifications(notifications_json) 'main.get_notifications_as_json',
service_id=service_one['id'],
mock_notifications_as_csv = mocker.patch('app.utils.generate_notifications_csv', message_type=message_type,
return_value=notifications_as_csv) status=status_argument
))
csv_content = utils.generate_notifications_csv( json_content = json.loads(json_response.get_data(as_text=True))
limit_days=7, assert json_content.keys() == {'counts', 'notifications'}
page=expected_page_argument,
service_id=service_one['id'],
status=expected_api_call,
template_type=[message_type]
)
mock_notifications_as_csv.assert_called_with(
limit_days=7,
page=expected_page_argument,
service_id=service_one['id'],
status=expected_api_call,
template_type=[message_type]
)
assert csv_response.status_code == 200
assert csv_response.get_data(as_text=True) == csv_content
assert 'text/csv' in csv_response.headers['Content-Type']
json_response = client.get(url_for(
'main.get_notifications_as_json',
service_id=service_one['id'],
message_type=message_type,
status=status_argument
))
json_content = json.loads(json_response.get_data(as_text=True))
assert json_content.keys() == {'counts', 'notifications'}
def test_should_show_notifications_for_a_service_with_next_previous( def test_should_show_notifications_for_a_service_with_next_previous(