Ejemplo n.º 1
0
def test_fail_job_set_status(redis):
    """Failed job should have corresponding status."""

    yield from enqueue_job(redis=redis, **stubs.job)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert (yield from job_status(redis,
                                  stubs.job_id)) == JobStatus.FAILED.encode()
Ejemplo n.º 2
0
def test_requeue_job_clean_exc_info(redis):
    """Requeue existing job cleanup exception information."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    yield from requeue_job(redis, stored_id.decode())
    assert not (yield from redis.hget(job_key(stubs.job_id), 'exc_info'))
Ejemplo n.º 3
0
def test_requeue_job_enqueue_into_origin(redis):
    """Requeue existing job puts it into jobs origin queue."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    yield from requeue_job(redis, stored_id.decode())
    assert stubs.job_id.encode() in (yield from jobs(redis, stubs.queue))
Ejemplo n.º 4
0
def test_requeue_job_clean_exc_info(redis):
    """Requeue existing job cleanup exception information."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    yield from requeue_job(redis, stored_id.decode())
    assert not (yield from redis.hget(job_key(stubs.job_id), 'exc_info'))
Ejemplo n.º 5
0
def test_requeue_job_set_status(redis):
    """Requeue existing job set corresponding job status."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    yield from requeue_job(redis, stored_id.decode())
    assert (yield from job_status(redis, stubs.job_id)) == JobStatus.QUEUED.encode()
Ejemplo n.º 6
0
def test_requeue_job_enqueue_into_origin(redis):
    """Requeue existing job puts it into jobs origin queue."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    yield from requeue_job(redis, stored_id.decode())
    assert stubs.job_id.encode() in (yield from jobs(redis, stubs.queue))
Ejemplo n.º 7
0
def test_requeue_job_set_status(redis):
    """Requeue existing job set corresponding job status."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    yield from requeue_job(redis, stored_id.decode())
    assert (yield from job_status(redis,
                                  stubs.job_id)) == JobStatus.QUEUED.encode()
Ejemplo n.º 8
0
def test_fail_job_removes_from_started_registry(redis):
    """Fail job remove given job from started registry."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    stored_id = stored_id.decode()
    queue = stored_spec[b'origin'].decode()
    timeout = stored_spec[b'timeout']
    yield from start_job(redis, queue, stored_id, timeout)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert stubs.job_id.encode() not in (yield from started_jobs(redis, queue))
Ejemplo n.º 9
0
def test_fail_job_removes_from_started_registry(redis):
    """Fail job remove given job from started registry."""

    yield from enqueue_job(redis=redis, **stubs.job)
    stored_id, stored_spec = yield from dequeue_job(redis, stubs.queue)
    stored_id = stored_id.decode()
    queue = stored_spec[b'origin'].decode()
    timeout = stored_spec[b'timeout']
    yield from start_job(redis, queue, stored_id, timeout)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert stubs.job_id.encode() not in (yield from started_jobs(redis, queue))
Ejemplo n.º 10
0
def test_fail_job_sets_exc_info(redis):
    """Failed job should have exception information."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    exc_info = yield from redis.hget(job_key(stubs.job_id), 'exc_info')
    assert exc_info == stubs.job_exc_info.encode()
Ejemplo n.º 11
0
def test_fail_job_sets_ended_at(redis):
    """Failed job should have ended at time."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    ended_at = yield from redis.hget(job_key(stubs.job_id), 'ended_at')
    assert ended_at == utcformat(utcnow()).encode()
Ejemplo n.º 12
0
def test_fail_job_enqueue_into_faileld_queue(redis):
    """Failed job appears in the failed queue."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert stubs.job_id.encode() in (yield from jobs(redis, 'failed'))
Ejemplo n.º 13
0
def test_fail_job_enqueue_into_faileld_queue(redis):
    """Failed job appears in the failed queue."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert stubs.job_id.encode() in (yield from jobs(redis, 'failed'))
Ejemplo n.º 14
0
def test_fail_job_sets_exc_info(redis):
    """Failed job should have exception information."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    exc_info = yield from redis.hget(job_key(stubs.job_id), 'exc_info')
    assert exc_info == stubs.job_exc_info.encode()
Ejemplo n.º 15
0
def test_fail_job_sets_ended_at(redis):
    """Failed job should have ended at time."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    ended_at = yield from redis.hget(job_key(stubs.job_id), 'ended_at')
    assert ended_at == utcformat(utcnow()).encode()
Ejemplo n.º 16
0
def test_fail_job_set_status(redis):
    """Failed job should have corresponding status."""

    yield from enqueue_job(redis=redis, **stubs.job)
    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert (yield from job_status(redis, stubs.job_id)) == JobStatus.FAILED.encode()
Ejemplo n.º 17
0
def test_fail_job_registers_failed_queue(redis):
    """Register failed queue on quarantine job."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert (yield from queues(redis)) == [failed_queue_key().encode()]
Ejemplo n.º 18
0
def test_fail_job_registers_failed_queue(redis):
    """Register failed queue on quarantine job."""

    yield from fail_job(redis, stubs.queue, stubs.job_id, stubs.job_exc_info)
    assert (yield from queues(redis)) == [failed_queue_key().encode()]