Esempio n. 1
0
def test_client_parses_empty_job_stats_for_service(mocker):
    service_id = 'service_id'
    job_1_id = 'job_id_1'
    job_2_id = 'job_id_2'
    expected_data = {
        'data': [{
            'status': 'finished',
            'template_version': 3,
            'id': job_1_id,
            'updated_at': '2016-08-24T08:29:28.332972+00:00',
            'service': service_id,
            'processing_finished': '2016-08-24T08:11:48.676365+00:00',
            'statistics': [],
            'original_file_name': 'test-notify-email.csv',
            'created_by': {
                'name': '*****@*****.**',
                'id': '3571f2ae-7a39-4fb4-9ad7-8453f5257072'
            },
            'created_at': '2016-08-24T08:09:56.371073+00:00',
            'template': 'c0309261-9c9e-4530-8fed-5f67b02260d2',
            'notification_count': 80,
            'processing_started': '2016-08-24T08:09:57.661246+00:00'
        }, {
            'status': 'finished',
            'template_version': 3,
            'id': job_2_id,
            'updated_at': '2016-08-24T08:29:28.332972+00:00',
            'service': service_id,
            'processing_finished': '2016-08-24T08:11:48.676365+00:00',
            'statistics': [],
            'original_file_name': 'test-notify-email.csv',
            'created_by': {
                'name': '*****@*****.**',
                'id': '3571f2ae-7a39-4fb4-9ad7-8453f5257072'
            },
            'created_at': '2016-08-24T08:09:56.371073+00:00',
            'template': 'c0309261-9c9e-4530-8fed-5f67b02260d2',
            'notification_count': 40,
            'processing_started': '2016-08-24T08:09:57.661246+00:00'
        }]
    }

    expected_url = '/service/{}/job'.format(service_id)

    mock_get = mocker.patch(
        'app.notify_client.job_api_client.JobApiClient.get',
        return_value=expected_data)

    result = PaginatedJobs(service_id)

    mock_get.assert_called_once_with(url=expected_url,
                                     params={
                                         'page': 1,
                                         'statuses': ANY
                                     })
    assert result[0].id == job_1_id
    assert result[0].notifications_requested == 0
    assert result[0].notifications_sent == 0
    assert result[0].notification_count == 80
    assert result[0].notifications_failed == 0
    assert result[1].id == job_2_id
    assert result[1].notifications_requested == 0
    assert result[1].notifications_sent == 0
    assert result[1].notification_count == 40
    assert result[1].notifications_failed == 0
Esempio n. 2
0
 def get_page_of_jobs(self, page):
     return PaginatedJobs(self.id, page=page)