Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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')"
Esempio n. 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()
Esempio n. 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
Esempio n. 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
Esempio n. 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'
Esempio n. 9
0
def test_create_queue():
    """We can create queue instance."""

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

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