Ejemplo n.º 1
0
def test_handle_update_job_informs(mocker, queue, fake_rq_id, started_conversion_job):
    from osmaxx.conversion.management.commands import result_harvester
    mocker.patch('django_rq.get_queue', return_value=queue)
    cmd = result_harvester.Command()
    _update_job_mock = mocker.patch.object(cmd, '_notify')
    cmd._update_job(job_id=fake_rq_id, queue=queue)
    assert _update_job_mock.call_count == 1
    _update_job_mock.assert_called_once_with(started_conversion_job)
Ejemplo n.º 2
0
def test_handle_failed_jobs_calls_update_job(mocker, fake_rq_id, queue):
    from osmaxx.conversion.management.commands import result_harvester
    mocker.patch('django_rq.get_failed_queue', return_value=queue)
    cmd = result_harvester.Command()
    _update_job_mock = mocker.patch.object(cmd, '_update_job')
    cmd._handle_failed_jobs()
    assert _update_job_mock.call_count == 1
    _update_job_mock.assert_called_once_with(job_id=str(fake_rq_id), queue=queue)
Ejemplo n.º 3
0
def test_handle_successfull_jobs_calls_update_job(mocker, queue, started_conversion_job):
    from osmaxx.conversion.management.commands import result_harvester
    mocker.patch('django_rq.get_queue', return_value=queue)
    cmd = result_harvester.Command()
    _update_job_mock = mocker.patch.object(cmd, '_update_job')
    cmd._handle_running_jobs()
    assert _update_job_mock.call_count == 1
    _update_job_mock.assert_called_once_with(job_id=str(started_conversion_job.rq_job_id), queue=queue)
Ejemplo n.º 4
0
def test_handle_failed_jobs_calls_set_failed_unless_final(
        mocker, fake_rq_id, queue):
    from osmaxx.conversion.management.commands import result_harvester
    from osmaxx.conversion.models import Job
    mocker.patch('django_rq.get_failed_queue', return_value=queue)
    conversion_job_mock = Mock()
    mocker.patch.object(Job.objects, 'get', return_value=conversion_job_mock)
    cmd = result_harvester.Command()
    _set_failed_unless_final = mocker.patch.object(cmd,
                                                   '_set_failed_unless_final')
    _update_job_mock = mocker.patch.object(cmd, '_notify')
    cmd._handle_failed_jobs()
    _set_failed_unless_final.assert_called_once_with(conversion_job_mock,
                                                     rq_job_id=str(fake_rq_id))
    _update_job_mock.assert_called_once_with(conversion_job_mock)