示例#1
0
def test_custom_default_timeout():
    """Override default timeout."""

    connection = object()
    q = Queue(connection)
    assert q.default_timeout == 180
    q = Queue(connection, default_timeout=500)
    assert q.default_timeout == 500
示例#2
0
def test_queue_order():
    """Mathematical order of queues."""

    connection = object()
    q1 = Queue(connection, 'a')
    q2 = Queue(connection, 'b')
    q3 = Queue(connection, 'c')
    assert q1 < q2
    assert q3 > q2
示例#3
0
def test_equality():
    """Mathematical equality of queues."""

    connection = object()
    q1 = Queue(connection, 'foo')
    q2 = Queue(connection, 'foo')
    q3 = Queue(connection, 'bar')
    assert q1 == q2
    assert q2 == q1
    assert q1 != q3
    assert q2 != q3
示例#4
0
def test_queue_magic_methods():
    """Test simple magic method behavior of the Queue class."""

    connection = object()
    q = Queue(connection)
    assert hash(q) == hash('default')
    assert str(q) == "<Queue 'default'>"
    assert repr(q) == "Queue('default')"
示例#5
0
def go():
    redis = yield from create_redis(('localhost', 6379))
    queue = Queue('my_async_queue', connection=redis)
    job = yield from queue.enqueue(
        http_client.fetch_page, 'https://www.python.org')
    yield from asyncio.sleep(5)
    result = yield from job.result
    assert '</html>' in result, 'Given content is not a html page'
    print('Well done, Turner!')
    redis.close()
示例#6
0
def test_custom_job_string():
    """Ensure custom job string assignment works as expected."""

    connection = object()
    q = Queue(connection, job_class='fixtures.CustomJob')
    assert q.job_class == CustomJob
示例#7
0
def test_custom_job_class():
    """Ensure custom job class assignment works as expected."""

    connection = object()
    q = Queue(connection, job_class=CustomJob)
    assert q.job_class == CustomJob
示例#8
0
def test_create_named_queue():
    """We can create named queue instance."""

    connection = object()
    q = Queue(connection, 'my-queue')
    assert q.name == 'my-queue'
示例#9
0
def test_create_queue():
    """We can create queue instance."""

    connection = object()
    q = Queue(connection)
    assert q.name == 'default'
示例#10
0
def test_store_connection():
    """Each queue store connection we give it."""

    connection = object()
    q = Queue(connection)
    assert q.connection is connection