コード例 #1
0
ファイル: test_protocol.py プロジェクト: dveselov/aiorq
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()
コード例 #2
0
ファイル: test_protocol.py プロジェクト: zefciu/aiorq
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()
コード例 #3
0
ファイル: test_protocol.py プロジェクト: dveselov/aiorq
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()
コード例 #4
0
ファイル: test_protocol.py プロジェクト: dveselov/aiorq
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()
コード例 #5
0
ファイル: test_protocol.py プロジェクト: zefciu/aiorq
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()
コード例 #6
0
ファイル: test_protocol.py プロジェクト: dveselov/aiorq
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()
コード例 #7
0
ファイル: test_protocol.py プロジェクト: zefciu/aiorq
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()
コード例 #8
0
ファイル: test_protocol.py プロジェクト: dveselov/aiorq
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()
コード例 #9
0
ファイル: test_protocol.py プロジェクト: dveselov/aiorq
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()
コード例 #10
0
ファイル: test_protocol.py プロジェクト: dveselov/aiorq
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()
コード例 #11
0
ファイル: test_protocol.py プロジェクト: zefciu/aiorq
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()
コード例 #12
0
ファイル: test_protocol.py プロジェクト: zefciu/aiorq
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()
コード例 #13
0
ファイル: test_protocol.py プロジェクト: zefciu/aiorq
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()
コード例 #14
0
ファイル: test_protocol.py プロジェクト: zefciu/aiorq
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()