Files
notifications-admin/tests/app/notify_client/test_job_client.py
Chris Hill-Scott da1fa2e61c Make _attach_current_user a pure function
Mutating dictionaries is gross and doesn’t work as you’d expect. Better
to have the function return a new dictionary instead.

Means we can be explicit that `created_by` is one of the allowed params
when updating a service.
2016-08-11 17:07:55 +01:00

28 lines
858 B
Python

from app.notify_client.job_api_client import JobApiClient
def test_client_creates_job_data_correctly(mocker, fake_uuid):
job_id = fake_uuid
service_id = fake_uuid
template_id = fake_uuid
original_file_name = 'test.csv'
notification_count = 1
mocker.patch('app.notify_client.current_user', id='1')
expected_data = {
"id": job_id,
"template": template_id,
"original_file_name": original_file_name,
"notification_count": 1,
"created_by": '1'
}
expected_url = '/service/{}/job'.format(service_id)
client = JobApiClient()
mock_post = mocker.patch('app.notify_client.job_api_client.JobApiClient.post')
client.create_job(job_id, service_id, template_id, original_file_name, notification_count)
mock_post.assert_called_once_with(url=expected_url, data=expected_data)