Beispiel #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()
Beispiel #2
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()
Beispiel #3
0
def test_enqueue_job_dependent_status(redis):
    """Set DEFERRED status to jobs with unfinished dependencies."""

    yield from enqueue_job(redis=redis, **stubs.job)
    yield from enqueue_job(redis=redis, **stubs.child_job)
    assert (yield from
            job_status(redis,
                       stubs.child_job_id)) == JobStatus.DEFERRED.encode()
Beispiel #4
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()
Beispiel #5
0
def test_start_job_sets_job_status(redis):
    """Start job sets corresponding job status."""

    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)
    assert (yield from job_status(redis, stubs.job_id)) == JobStatus.STARTED.encode()
Beispiel #6
0
def test_start_job_sets_job_status(redis):
    """Start job sets corresponding job status."""

    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)
    assert (yield from job_status(redis,
                                  stubs.job_id)) == JobStatus.STARTED.encode()
Beispiel #7
0
def test_finish_job_sets_corresponding_status(redis):
    """Finish job sets corresponding status."""

    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 finish_job(redis, queue, stored_id)
    assert (yield from job_status(redis, stubs.job_id)) == JobStatus.FINISHED.encode()
Beispiel #8
0
def test_finish_job_sets_corresponding_status(redis):
    """Finish job sets corresponding status."""

    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 finish_job(redis, queue, stored_id)
    assert (yield from
            job_status(redis, stubs.job_id)) == JobStatus.FINISHED.encode()
Beispiel #9
0
def test_job_status(redis):
    """Get job status."""

    yield from redis.hset(job_key(stubs.job_id), 'status', JobStatus.QUEUED)
    assert (yield from job_status(redis,
                                  stubs.job_id)) == JobStatus.QUEUED.encode()
Beispiel #10
0
def test_enqueue_job_set_job_status(redis):
    """Enqueue job must set job status to QUEUED."""

    yield from enqueue_job(redis=redis, **stubs.job)
    assert (yield from job_status(redis,
                                  stubs.job_id)) == JobStatus.QUEUED.encode()
Beispiel #11
0
def test_job_status(redis):
    """Get job status."""

    yield from redis.hset(job_key(stubs.job_id), 'status', JobStatus.QUEUED)
    assert (yield from job_status(redis, stubs.job_id)) == JobStatus.QUEUED.encode()
Beispiel #12
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()
Beispiel #13
0
def test_enqueue_job_dependent_status(redis):
    """Set DEFERRED status to jobs with unfinished dependencies."""

    yield from enqueue_job(redis=redis, **stubs.job)
    yield from enqueue_job(redis=redis, **stubs.child_job)
    assert (yield from job_status(redis, stubs.child_job_id)) == JobStatus.DEFERRED.encode()
Beispiel #14
0
def test_enqueue_job_set_job_status(redis):
    """Enqueue job must set job status to QUEUED."""

    yield from enqueue_job(redis=redis, **stubs.job)
    assert (yield from job_status(redis, stubs.job_id)) == JobStatus.QUEUED.encode()