Пример #1
0
    def test_assert_is_bound(self):
        exchange = Exchange("foo", "direct")
        self.assertRaises(NotBoundError, exchange.declare)

        chan = Channel()
        exchange.bind(chan).declare()
        self.assertIn("exchange_declare", chan)
Пример #2
0
    def test_revive(self):
        exchange = Exchange("foo", "direct")
        chan = Channel()

        # reviving unbound channel is a noop.
        exchange.revive(chan)
        self.assertFalse(exchange.is_bound)
        self.assertIsNone(exchange._channel)

        bound = exchange.bind(chan)
        self.assertTrue(bound.is_bound)
        self.assertIs(bound.channel, chan)

        chan2 = Channel()
        bound.revive(chan2)
        self.assertTrue(bound.is_bound)
        self.assertIs(bound._channel, chan2)
Пример #3
0
 def test_declare(self):
     chan = Channel()
     b = Queue("foo", self.exchange, "foo", channel=chan)
     self.assertTrue(b.is_bound)
     b.declare()
     self.assertIn("exchange_declare", chan)
     self.assertIn("queue_declare", chan)
     self.assertIn("queue_bind", chan)
Пример #4
0
 def test_also_binds_exchange(self):
     chan = Channel()
     b = Queue("foo", self.exchange)
     self.assertFalse(b.is_bound)
     self.assertFalse(b.exchange.is_bound)
     b = b.bind(chan)
     self.assertTrue(b.is_bound)
     self.assertTrue(b.exchange.is_bound)
     self.assertIs(b.channel, b.exchange.channel)
     self.assertIsNot(b.exchange, self.exchange)
Пример #5
0
    def test_bound(self):
        exchange = Exchange("foo", "direct")
        self.assertFalse(exchange.is_bound)
        self.assertIn("<unbound", repr(exchange))

        chan = Channel()
        bound = exchange.bind(chan)
        self.assertTrue(bound.is_bound)
        self.assertIs(bound.channel, chan)
        self.assertIn("<bound", repr(bound))
Пример #6
0
 def test_delete(self):
     chan = Channel()
     Exchange("foo", channel=chan).delete()
     self.assertIn("exchange_delete", chan)
Пример #7
0
 def test_publish(self):
     chan = Channel()
     Exchange("foo", channel=chan).publish("the quick brown fox")
     self.assertIn("basic_publish", chan)
Пример #8
0
 def test_create_message(self):
     chan = Channel()
     Exchange("foo", channel=chan).Message({"foo": "bar"})
     self.assertIn("prepare_message", chan)
Пример #9
0
 def test_bind_at_instantiation(self):
     self.assertTrue(Exchange("foo", channel=Channel()).is_bound)
Пример #10
0
 def test_delete(self):
     b = Queue("foo", self.exchange, "foo", channel=Channel())
     b.delete()
     self.assertIn("queue_delete", b.channel)
Пример #11
0
 def test_cancel(self):
     b = Queue("foo", self.exchange, "foo", channel=Channel())
     b.cancel("fifafo")
     self.assertIn("basic_cancel", b.channel)
Пример #12
0
 def test_consume(self):
     b = Queue("foo", self.exchange, "foo", channel=Channel())
     b.consume("fifafo", None)
     self.assertIn("basic_consume", b.channel)
Пример #13
0
 def test_purge(self):
     b = Queue("foo", self.exchange, "foo", channel=Channel())
     b.purge()
     self.assertIn("queue_purge", b.channel)
Пример #14
0
 def test_get(self):
     b = Queue("foo", self.exchange, "foo", channel=Channel())
     b.get()
     self.assertIn("basic_get", b.channel)
Пример #15
0
 def test_unbind(self):
     b = Queue("foo", self.exchange, "foo", channel=Channel())
     b.unbind()
     self.assertIn("queue_unbind", b.channel)
Пример #16
0
 def setUp(self):
     if self.type:
         self.e = self.type(Channel())
Пример #17
0
 def test_binds_at_instantiation(self):
     self.assertTrue(
         Queue("foo", self.exchange, channel=Channel()).is_bound)