mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
Rewrite prev/next test to use BeautifulSoup
This commit is contained in:
@@ -172,7 +172,7 @@ def view_notifications(service_id, message_type):
|
|||||||
limit_days=current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
|
limit_days=current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
|
||||||
view_dict = dict(
|
view_dict = dict(
|
||||||
message_type=message_type,
|
message_type=message_type,
|
||||||
status=filter_args['status']
|
status=request.args.get('status')
|
||||||
)
|
)
|
||||||
prev_page = None
|
prev_page = None
|
||||||
if notifications['links'].get('prev', None):
|
if notifications['links'].get('prev', None):
|
||||||
|
|||||||
@@ -295,10 +295,21 @@ def test_should_show_notifications_for_a_service_with_next_previous(
|
|||||||
))
|
))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.get_data(as_text=True)
|
content = response.get_data(as_text=True)
|
||||||
assert url_for('main.view_notifications', service_id=service_one['id'], message_type='sms', page=3) in content
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
assert url_for('main.view_notifications', service_id=service_one['id'], message_type='sms', page=1) in content
|
next_page_link = page.find('a', {'rel': 'next'})
|
||||||
assert 'Previous page' in content
|
prev_page_link = page.find('a', {'rel': 'previous'})
|
||||||
assert 'Next page' in content
|
assert (
|
||||||
|
url_for('main.view_notifications', service_id=service_one['id'], message_type='sms', page=3) in
|
||||||
|
next_page_link['href']
|
||||||
|
)
|
||||||
|
assert 'Next page' in next_page_link.text.strip()
|
||||||
|
assert 'page 3' in next_page_link.text.strip()
|
||||||
|
assert (
|
||||||
|
url_for('main.view_notifications', service_id=service_one['id'], message_type='sms', page=1) in
|
||||||
|
prev_page_link['href']
|
||||||
|
)
|
||||||
|
assert 'Previous page' in prev_page_link.text.strip()
|
||||||
|
assert 'page 1' in prev_page_link.text.strip()
|
||||||
|
|
||||||
|
|
||||||
@freeze_time("2016-01-01 11:09:00.061258")
|
@freeze_time("2016-01-01 11:09:00.061258")
|
||||||
|
|||||||
Reference in New Issue
Block a user