示例#1
0
def test_worker_death_sets_status(redis):
    """Set worker status to IDLE."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.IDLE.encode()
示例#2
0
def test_worker_death_sets_status(redis):
    """Set worker status to IDLE."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.IDLE.encode()
示例#3
0
def test_worker_death_sets_death_date(redis):
    """Set worker death date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    death = utcformat(utcnow()).encode()
    assert (yield from redis.hget(worker_key('foo'), 'death')) == death
示例#4
0
def test_worker_death_sets_death_date(redis):
    """Set worker death date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    death = utcformat(utcnow()).encode()
    assert (yield from redis.hget(worker_key('foo'), 'death')) == death
示例#5
0
def test_worker_shutdown_requested(redis):
    """Set worker shutdown requested date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_shutdown_requested(redis, 'foo')
    shutdown = yield from redis.hget(
        worker_key('foo'), 'shutdown_requested_date')
    assert shutdown == utcformat(utcnow()).encode()
示例#6
0
def test_worker_shutdown_requested(redis):
    """Set worker shutdown requested date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_shutdown_requested(redis, 'foo')
    shutdown = yield from redis.hget(worker_key('foo'),
                                     'shutdown_requested_date')
    assert shutdown == utcformat(utcnow()).encode()
示例#7
0
def test_worker_death_sets_worker_ttl(redis):
    """Set worker hash ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert (yield from redis.ttl(worker_key('foo'))) == 60
示例#8
0
def test_worker_death_workers_set(redis):
    """Remove worker from workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert not (yield from redis.smembers(workers_key()))
示例#9
0
def test_worker_birth_removes_old_hash(redis):
    """Remove old hash stored from the previous run."""

    yield from redis.hmset(worker_key('foo'), 'bar', 'baz', 'death', 0)
    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert not (yield from redis.hget(worker_key('foo'), 'bar'))
示例#10
0
def test_worker_birth_worker_status(redis):
    """Register birth sets worker status to STARTED."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.STARTED.encode()
示例#11
0
def test_worker_birth_current_job(redis):
    """Signify that aiorq doesn't support current_job worker attribute."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    current_job = yield from redis.hget(worker_key('foo'), 'current_job')
    assert current_job == b'not supported'
示例#12
0
def test_worker_birth_sets_custom_worker_ttl(redis):
    """Set custom worker ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'], 1000)
    assert (yield from redis.ttl(worker_key('foo'))) == 1000
示例#13
0
def test_worker_birth_fail_worker_exists(redis):
    """Register birth will fail with worker which already exists."""

    yield from redis.hset(worker_key('foo'), 'bar', 'baz')
    with pytest.raises(ValueError):
        yield from worker_birth(redis, 'foo', ['bar', 'baz'])
示例#14
0
def test_worker_birth_sets_queue_names(redis):
    """Set worker queue names."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from redis.hget(worker_key('foo'), 'queues')) == b'bar,baz'
示例#15
0
def test_worker_birth_removes_old_hash(redis):
    """Remove old hash stored from the previous run."""

    yield from redis.hmset(worker_key('foo'), 'bar', 'baz', 'death', 0)
    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert not (yield from redis.hget(worker_key('foo'), 'bar'))
示例#16
0
def test_worker_birth_sets_custom_worker_ttl(redis):
    """Set custom worker ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'], 1000)
    assert (yield from redis.ttl(worker_key('foo'))) == 1000
示例#17
0
def test_worker_birth_sets_queue_names(redis):
    """Set worker queue names."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from redis.hget(worker_key('foo'), 'queues')) == b'bar,baz'
示例#18
0
def test_worker_birth_fail_worker_exists(redis):
    """Register birth will fail with worker which already exists."""

    yield from redis.hset(worker_key('foo'), 'bar', 'baz')
    with pytest.raises(ValueError):
        yield from worker_birth(redis, 'foo', ['bar', 'baz'])
示例#19
0
def test_worker_death_sets_worker_ttl(redis):
    """Set worker hash ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert (yield from redis.ttl(worker_key('foo'))) == 60
示例#20
0
def test_worker_birth_worker_status(redis):
    """Register birth sets worker status to STARTED."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.STARTED.encode()
示例#21
0
def test_worker_death_workers_set(redis):
    """Remove worker from workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert not (yield from redis.smembers(workers_key()))
示例#22
0
def test_worker_birth_current_job(redis):
    """Signify that aiorq doesn't support current_job worker attribute."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    current_job = yield from redis.hget(worker_key('foo'), 'current_job')
    assert current_job == b'not supported'
示例#23
0
def test_worker_birth_workers_set(redis):
    """Add worker to the workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from
            redis.smembers(workers_key())) == [worker_key('foo').encode()]
示例#24
0
def test_worker_birth_workers_set(redis):
    """Add worker to the workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from redis.smembers(workers_key())) == [worker_key('foo').encode()]