mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Move pagination utils into own module
This continues the pattern established in [1], just to chip away a bit more at the random collection of stuff in utils/__init__.py. [1]: https://github.com/alphagov/notifications-admin/pull/3923
This commit is contained in:
@@ -4,8 +4,6 @@ from freezegun import freeze_time
|
||||
from app import format_datetime_relative
|
||||
from app.formatters import email_safe, round_to_significant_figures
|
||||
from app.utils import (
|
||||
generate_next_dict,
|
||||
generate_previous_dict,
|
||||
get_current_financial_year,
|
||||
get_logo_cdn_domain,
|
||||
is_less_than_days_ago,
|
||||
@@ -29,25 +27,6 @@ def test_email_safe_return_dot_separated_email_domain(service_name, safe_email):
|
||||
assert email_safe(service_name) == safe_email
|
||||
|
||||
|
||||
def test_generate_previous_dict(client):
|
||||
ret = generate_previous_dict('main.view_jobs', 'foo', 2, {})
|
||||
assert 'page=1' in ret['url']
|
||||
assert ret['title'] == 'Previous page'
|
||||
assert ret['label'] == 'page 1'
|
||||
|
||||
|
||||
def test_generate_next_dict(client):
|
||||
ret = generate_next_dict('main.view_jobs', 'foo', 2, {})
|
||||
assert 'page=3' in ret['url']
|
||||
assert ret['title'] == 'Next page'
|
||||
assert ret['label'] == 'page 3'
|
||||
|
||||
|
||||
def test_generate_previous_next_dict_adds_other_url_args(client):
|
||||
ret = generate_next_dict('main.view_notifications', 'foo', 2, {'message_type': 'blah'})
|
||||
assert 'notifications/blah' in ret['url']
|
||||
|
||||
|
||||
def test_get_cdn_domain_on_localhost(client, mocker):
|
||||
mocker.patch.dict('app.current_app.config', values={'ADMIN_BASE_URL': 'http://localhost:6012'})
|
||||
domain = get_logo_cdn_domain()
|
||||
|
||||
20
tests/app/utils/test_pagination.py
Normal file
20
tests/app/utils/test_pagination.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from app.utils.pagination import generate_next_dict, generate_previous_dict
|
||||
|
||||
|
||||
def test_generate_previous_dict(client):
|
||||
ret = generate_previous_dict('main.view_jobs', 'foo', 2, {})
|
||||
assert 'page=1' in ret['url']
|
||||
assert ret['title'] == 'Previous page'
|
||||
assert ret['label'] == 'page 1'
|
||||
|
||||
|
||||
def test_generate_next_dict(client):
|
||||
ret = generate_next_dict('main.view_jobs', 'foo', 2, {})
|
||||
assert 'page=3' in ret['url']
|
||||
assert ret['title'] == 'Next page'
|
||||
assert ret['label'] == 'page 3'
|
||||
|
||||
|
||||
def test_generate_previous_next_dict_adds_other_url_args(client):
|
||||
ret = generate_next_dict('main.view_notifications', 'foo', 2, {'message_type': 'blah'})
|
||||
assert 'notifications/blah' in ret['url']
|
||||
Reference in New Issue
Block a user