Beispiel #1
0
 def setUp(self):
     self.qm = QueueManager()
     self.q = Queue()
     self.qq = Queue()
     self.qm.register(self.q, {"foo": "bar", "baz": "quux"})
     self.qm.register(self.qq, {"foo": "quux"})
Beispiel #2
0
class QueueManager_Test(TestCase):
    def setUp(self):
        self.qm = QueueManager()
        self.q = Queue()
        self.qq = Queue()
        self.qm.register(self.q, {"foo": "bar", "baz": "quux"})
        self.qm.register(self.qq, {"foo": "quux"})

    def tearDown(self):
        self.qm.deregister(self.q)
        self.qm.deregister(self.qq)

    def test_fanout(self):
        message = object()
        self.qm.fanout(message)
        assert self.q.get(False) is message
        assert self.qq.get(False) is message

    def test_rules(self):
        message = object()
        self.qm.fanout(message, {"foo": "bar"})
        assert self.q.get(False) is message
        with self.assertRaises(Empty):
            self.qq.get(False)

    def test_already_registered(self):
        with self.assertRaises(AlreadyRegistered):
            self.qm.register(self.q)

    def test_not_found(self):
        with self.assertRaises(NotFound):
            self.qm.deregister(Queue())