def test_queue(): # Test queueing tasks. with patch('psq.queue.Queue._get_or_create_topic'): q = Queue(Mock()) q.storage.put_task = Mock() r = q.enqueue(sum, 1, 2, arg='c') assert q.topic.publish.called assert q.storage.put_task.called t = q.storage.put_task.call_args[0][0] assert t.f == sum assert t.args == (1, 2) assert t.kwargs == {'arg': 'c'} assert r.task_id == t.id
def test_queue(self): # Test queueing tasks. with patch('psq.queue.Queue._get_or_create_topic'): q = Queue(Mock()) q.storage.put_task = Mock() r = q.enqueue(sum, 1, 2, arg='c') assert q.topic.publish.called assert q.storage.put_task.called t = q.storage.put_task.call_args[0][0] assert t.f == sum assert t.args == (1, 2) assert t.kwargs == {'arg': 'c'} assert r.task_id == t.id
def test_synchronous_fail(): q = Queue(pubsub=None, storage=TestStorage(), async=False) r = q.enqueue(sum, "2") with pytest.raises(TypeError): r.result()
def test_synchronous_success(): q = Queue(pubsub=None, storage=TestStorage(), async=False) r = q.enqueue(sum, [1, 2]) assert r.result() == 3
def test_string_function(): q = Queue(pubsub=None, storage=TestStorage(), async=False) r = q.enqueue('psq.queue_test.dummy_queue_func') assert r.result() == "Hello"