Source

araldo / test / sender_test.py

Full commit
import pytest
import gevent
from mock import Mock
from gevent.queue import Queue
from araldo.sender import Sender


@pytest.fixture
def config():
    result = Mock()
    result.settings.return_value = {"routes": {}}
    return result


@pytest.fixture
def sender(config):
    return Sender(config, Queue())


def test_creation(sender):
    pass


def test_run(sender):
    sender.start()

    timeout = gevent.Timeout(.1)
    timeout.start()
    q = Queue()
    q.put("testmessage_1")
    q.put("testmessage_2")
    with pytest.raises(gevent.Timeout):
        sender.join()