Files
notifications-admin/tests/app/models/test_contact_list.py
Chris Hill-Scott b579f68411 Limit jobs sent from contact list by data retention
On the uploads page we only show jobs which are within a service’s data
retention.

This commit does the same for when we’re listing the jobs for a contact
list. This matches the UI, which says a contact list has been ‘used
`<count_of_jobs>` in the last <data_retention> days’
2020-12-01 13:57:56 +00:00

33 lines
967 B
Python

from datetime import datetime
from app.models.contact_list import ContactList
from app.models.job import PaginatedJobs
def test_created_at():
created_at = ContactList({'created_at': '2016-05-06T07:08:09.061258'}).created_at
assert isinstance(created_at, datetime)
assert created_at.isoformat() == '2016-05-06T08:08:09.061258+01:00'
def test_get_jobs(mock_get_jobs):
contact_list = ContactList({'id': 'a', 'service_id': 'b'})
assert isinstance(contact_list.get_jobs(page=123), PaginatedJobs)
# mock_get_jobs mocks the underlying API client method, not
# contact_list.get_jobs
mock_get_jobs.assert_called_once_with(
'b',
contact_list_id='a',
statuses={
'finished',
'sending limits exceeded',
'ready to send',
'scheduled',
'sent to dvla',
'pending',
'in progress',
},
page=123,
limit_days=None,
)