def test_with_ha_policy(self):
        qn = Queues(ha_policy=None, create_missing=False)
        qn.add('xyz')
        self.assertIsNone(qn['xyz'].queue_arguments)

        qn.add('xyx', queue_arguments={'x-foo': 'bar'})
        self.assertEqual(qn['xyx'].queue_arguments, {'x-foo': 'bar'})

        q = Queues(ha_policy='all', create_missing=False)
        q.add(Queue('foo'))
        self.assertEqual(q['foo'].queue_arguments, {'x-ha-policy': 'all'})

        qq = Queue('xyx2', queue_arguments={'x-foo': 'bari'})
        q.add(qq)
        self.assertEqual(q['xyx2'].queue_arguments, {
            'x-ha-policy': 'all',
            'x-foo': 'bari',
        })

        q2 = Queues(ha_policy=['A', 'B', 'C'], create_missing=False)
        q2.add(Queue('foo'))
        self.assertEqual(q2['foo'].queue_arguments, {
            'x-ha-policy': 'nodes',
            'x-ha-policy-params': ['A', 'B', 'C'],
        })
示例#2
0
    def test_with_ha_policy(self):
        qn = Queues(ha_policy=None, create_missing=False)
        qn.add("xyz")
        self.assertIsNone(qn["xyz"].queue_arguments)

        qn.add("xyx", queue_arguments={"x-foo": "bar"})
        self.assertEqual(qn["xyx"].queue_arguments, {"x-foo": "bar"})

        q = Queues(ha_policy="all", create_missing=False)
        q.add(Queue("foo"))
        self.assertEqual(q["foo"].queue_arguments, {"x-ha-policy": "all"})

        qq = Queue("xyx2", queue_arguments={"x-foo": "bari"})
        q.add(qq)
        self.assertEqual(q["xyx2"].queue_arguments, {"x-ha-policy": "all", "x-foo": "bari"})

        q2 = Queues(ha_policy=["A", "B", "C"], create_missing=False)
        q2.add(Queue("foo"))
        self.assertEqual(q2["foo"].queue_arguments, {"x-ha-policy": "nodes", "x-ha-policy-params": ["A", "B", "C"]})
示例#3
0
 def test_add_default_exchange(self):
     ex = Exchange('fff', 'fanout')
     q = Queues(default_exchange=ex)
     q.add(Queue('foo'))
     assert q['foo'].exchange.name == 'fff'
示例#4
0
 def test_with_ha_policy(self, ha_policy, qname, q, qargs, expected):
     queues = Queues(ha_policy=ha_policy, create_missing=False)
     queues.add(q, queue_arguments=qargs)
     assert queues[qname].queue_arguments == expected
示例#5
0
 def test_add_default_exchange(self):
     ex = Exchange('fff', 'fanout')
     q = Queues(default_exchange=ex)
     q.add(Queue('foo'))
     self.assertEqual(q['foo'].exchange, ex)
    def test_with_max_priority(self):
        qs1 = Queues(max_priority=10)
        qs1.add('foo')
        self.assertEqual(qs1['foo'].queue_arguments, {'x-max-priority': 10})

        q1 = Queue('xyx', queue_arguments={'x-max-priority': 3})
        qs1.add(q1)
        self.assertEqual(qs1['xyx'].queue_arguments, {
            'x-max-priority': 3,
        })

        q1 = Queue('moo', queue_arguments=None)
        qs1.add(q1)
        self.assertEqual(qs1['moo'].queue_arguments, {
            'x-max-priority': 10,
        })

        qs2 = Queues(ha_policy='all', max_priority=5)
        qs2.add('bar')
        self.assertEqual(qs2['bar'].queue_arguments, {
            'x-ha-policy': 'all',
            'x-max-priority': 5
        })

        q2 = Queue('xyx2', queue_arguments={'x-max-priority': 2})
        qs2.add(q2)
        self.assertEqual(qs2['xyx2'].queue_arguments, {
            'x-ha-policy': 'all',
            'x-max-priority': 2,
        })

        qs3 = Queues(max_priority=None)
        qs3.add('foo2')
        self.assertEqual(qs3['foo2'].queue_arguments, None)

        q3 = Queue('xyx3', queue_arguments={'x-max-priority': 7})
        qs3.add(q3)
        self.assertEqual(qs3['xyx3'].queue_arguments, {
            'x-max-priority': 7,
        })
示例#7
0
 def test_add_default_exchange(self):
     ex = Exchange('fff', 'fanout')
     q = Queues(default_exchange=ex)
     q.add(Queue('foo'))
     self.assertEqual(q['foo'].exchange.name, '')
示例#8
0
 def test_add(self):
     q = Queues()
     q.add('foo', exchange='ex', routing_key='rk')
     assert 'foo' in q
     assert isinstance(q['foo'], Queue)
     assert q['foo'].routing_key == 'rk'
示例#9
0
 def test_with_ha_policy_compat(self):
     q = Queues(ha_policy="all")
     q.add("bar")
     self.assertEqual(q["bar"].queue_arguments, {"x-ha-policy": "all"})
示例#10
0
 def test_alias(self):
     q = Queues()
     q.add(Queue("foo", alias="barfoo"))
     self.assertIs(q["barfoo"], q["foo"])
示例#11
0
 def test_add_default_exchange(self):
     ex = Exchange("fff", "fanout")
     q = Queues(default_exchange=ex)
     q.add(Queue("foo"))
     self.assertEqual(q["foo"].exchange, ex)
示例#12
0
 def test_add(self):
     q = Queues()
     q.add("foo", exchange="ex", routing_key="rk")
     self.assertIn("foo", q)
     self.assertIsInstance(q["foo"], Queue)
     self.assertEqual(q["foo"].routing_key, "rk")
示例#13
0
 def test_add(self):
     q = Queues()
     q.add("foo", exchange="ex", routing_key="rk")
     assert "foo" in q
     assert isinstance(q["foo"], Queue)
     assert q["foo"].routing_key == "rk"
示例#14
0
 def test_alias(self):
     q = Queues()
     q.add(Queue("foo", alias="barfoo"))
     assert q["barfoo"] is q["foo"]
示例#15
0
 def test_add_default_exchange(self):
     ex = Exchange("fff", "fanout")
     q = Queues(default_exchange=ex)
     q.add(Queue("foo"))
     assert q["foo"].exchange.name == ""
示例#16
0
 def test_with_max_priority(self, queues_kwargs, qname, q, expected):
     queues = Queues(**queues_kwargs)
     queues.add(q)
     assert queues[qname].queue_arguments == expected
示例#17
0
 def test_with_ha_policy_compat(self):
     q = Queues(ha_policy="all")
     q.add("bar")
     assert q["bar"].queue_arguments == {"x-ha-policy": "all"}
示例#18
0
 def test_add_default_exchange(self):
     ex = Exchange("fff", "fanout")
     q = Queues(default_exchange=ex)
     q.add(Queue("foo"))
     self.assertEqual(q["foo"].exchange, ex)
 def test_with_ha_policy_compat(self):
     q = Queues(ha_policy='all')
     q.add('bar')
     self.assertEqual(q['bar'].queue_arguments, {'x-ha-policy': 'all'})
示例#20
0
 def test_alias(self):
     q = Queues()
     q.add(Queue("foo", alias="barfoo"))
     self.assertIs(q["barfoo"], q["foo"])
示例#21
0
 def test_alias(self):
     q = Queues()
     q.add(Queue('foo', alias='barfoo'))
     self.assertIs(q['barfoo'], q['foo'])
示例#22
0
 def test_add(self):
     q = Queues()
     q.add("foo", exchange="ex", routing_key="rk")
     self.assertIn("foo", q)
     self.assertIsInstance(q["foo"], Queue)
     self.assertEqual(q["foo"].routing_key, "rk")
示例#23
0
 def test_add(self):
     q = Queues()
     q.add('foo', exchange='ex', routing_key='rk')
     self.assertIn('foo', q)
     self.assertIsInstance(q['foo'], Queue)
     self.assertEqual(q['foo'].routing_key, 'rk')
示例#24
0
 def test_with_ha_policy(self, ha_policy, qname, q, qargs, expected):
     queues = Queues(ha_policy=ha_policy, create_missing=False)
     queues.add(q, queue_arguments=qargs)
     assert queues[qname].queue_arguments == expected
示例#25
0
 def test_add(self):
     q = Queues()
     q.add('foo', exchange='ex', routing_key='rk')
     self.assertIn('foo', q)
     self.assertIsInstance(q['foo'], Queue)
     self.assertEqual(q['foo'].routing_key, 'rk')
示例#26
0
 def test_with_ha_policy_compat(self):
     q = Queues(ha_policy='all')
     q.add('bar')
     assert q['bar'].queue_arguments == {'x-ha-policy': 'all'}
示例#27
0
 def test_alias(self):
     q = Queues()
     q.add(Queue('foo', alias='barfoo'))
     self.assertIs(q['barfoo'], q['foo'])
示例#28
0
 def test_add_default_exchange(self):
     ex = Exchange('fff', 'fanout')
     q = Queues(default_exchange=ex)
     q.add(Queue('foo'))
     assert q['foo'].exchange.name == 'fff'
示例#29
0
 def test_with_ha_policy_compat(self):
     q = Queues(ha_policy='all')
     q.add('bar')
     assert q['bar'].queue_arguments == {'ha-mode': 'all'}
示例#30
0
 def test_alias(self):
     q = Queues()
     q.add(Queue('foo', alias='barfoo'))
     assert q['barfoo'] is q['foo']
示例#31
0
 def test_alias(self):
     q = Queues()
     q.add(Queue('foo', alias='barfoo'))
     assert q['barfoo'] is q['foo']
示例#32
0
 def test_with_max_priority(self, queues_kwargs, qname, q, expected):
     queues = Queues(**queues_kwargs)
     queues.add(q)
     assert queues[qname].queue_arguments == expected
示例#33
0
 def test_add(self):
     q = Queues()
     q.add('foo', exchange='ex', routing_key='rk')
     assert 'foo' in q
     assert isinstance(q['foo'], Queue)
     assert q['foo'].routing_key == 'rk'
示例#34
0
    def test_with_max_priority(self):
        qs1 = Queues(max_priority=10)
        qs1.add("foo")
        self.assertEqual(qs1["foo"].queue_arguments, {"x-max-priority": 10})

        q1 = Queue("xyx", queue_arguments={"x-max-priority": 3})
        qs1.add(q1)
        self.assertEqual(qs1["xyx"].queue_arguments, {"x-max-priority": 3})

        q1 = Queue("moo", queue_arguments=None)
        qs1.add(q1)
        self.assertEqual(qs1["moo"].queue_arguments, {"x-max-priority": 10})

        qs2 = Queues(ha_policy="all", max_priority=5)
        qs2.add("bar")
        self.assertEqual(qs2["bar"].queue_arguments, {"x-ha-policy": "all", "x-max-priority": 5})

        q2 = Queue("xyx2", queue_arguments={"x-max-priority": 2})
        qs2.add(q2)
        self.assertEqual(qs2["xyx2"].queue_arguments, {"x-ha-policy": "all", "x-max-priority": 2})

        qs3 = Queues(max_priority=None)
        qs3.add("foo2")
        self.assertEqual(qs3["foo2"].queue_arguments, None)

        q3 = Queue("xyx3", queue_arguments={"x-max-priority": 7})
        qs3.add(q3)
        self.assertEqual(qs3["xyx3"].queue_arguments, {"x-max-priority": 7})