Пример #1
0
class TestSendChannel(PyonTestCase):
    def setUp(self):
        self.ch = SendChannel()

    def test_connect(self):
        self.ch.connect(NameTrio('xp', 'key'))
        self.assertTrue(hasattr(self.ch._send_name, 'exchange'))
        self.assertTrue(hasattr(self.ch._send_name, 'queue'))
        self.assertEquals(self.ch._send_name.exchange, 'xp')
        self.assertEquals(self.ch._send_name.queue, 'key')
        self.assertEquals(self.ch._exchange, 'xp')

    def test_send(self):
        _sendmock = Mock()
        self.ch._send = _sendmock
        np = NameTrio('xp', 'key')
        self.ch.connect(np)

        self.ch.send('data', {'header': sentinel.headervalue})
        _sendmock.assert_called_once_with(
            np, 'data', headers={'header': sentinel.headervalue})

    def test__send(self):
        ac = Mock(pchannel.Channel)
        self.ch._amq_chan = ac

        # test sending in params
        self.ch._send(NameTrio('xp', 'namen'), 'daten')

        # get our props
        self.assertTrue(ac.basic_publish.called)
        self.assertIn('exchange', ac.basic_publish.call_args[1])
        self.assertIn('routing_key', ac.basic_publish.call_args[1])
        self.assertIn('body', ac.basic_publish.call_args[1])
        self.assertIn('immediate', ac.basic_publish.call_args[1])
        self.assertIn('mandatory', ac.basic_publish.call_args[1])
        self.assertIn('properties', ac.basic_publish.call_args[1])

        props = ac.basic_publish.call_args[1].get('properties')
        self.assertIsInstance(props, BasicProperties)
        self.assertTrue(hasattr(props, 'headers'))
        self.assertEquals(props.headers, {})

        # try another call to _send with a header
        self.ch._send(NameTrio('xp', 'namen'),
                      'daten',
                      headers={'custom': 'val'})

        # make sure our property showed up
        props = ac.basic_publish.call_args[1].get('properties')
        self.assertIn('custom', props.headers)
        self.assertEquals(props.headers['custom'], 'val')
Пример #2
0
class TestSendChannel(PyonTestCase):
    def setUp(self):
        self.ch = SendChannel()

    def test_connect(self):
        self.ch.connect(NameTrio('xp', 'key'))
        self.assertTrue(hasattr(self.ch._send_name, 'exchange'))
        self.assertTrue(hasattr(self.ch._send_name, 'queue'))
        self.assertEquals(self.ch._send_name.exchange, 'xp')
        self.assertEquals(self.ch._send_name.queue, 'key')
        self.assertEquals(self.ch._exchange, 'xp')

    def test_send(self):
        _sendmock = Mock()
        self.ch._send = _sendmock
        np = NameTrio('xp', 'key')
        self.ch.connect(np)

        self.ch.send('data', {'header':sentinel.headervalue})
        _sendmock.assert_called_once_with(np, 'data', headers={'header':sentinel.headervalue})

    def test__send(self):
        ac = Mock(pchannel.Channel)
        self.ch._amq_chan = ac

        # test sending in params
        self.ch._send(NameTrio('xp', 'namen'), 'daten')

        # get our props
        self.assertTrue(ac.basic_publish.called)
        self.assertIn('exchange', ac.basic_publish.call_args[1])
        self.assertIn('routing_key', ac.basic_publish.call_args[1])
        self.assertIn('body', ac.basic_publish.call_args[1])
        self.assertIn('immediate', ac.basic_publish.call_args[1])
        self.assertIn('mandatory', ac.basic_publish.call_args[1])
        self.assertIn('properties', ac.basic_publish.call_args[1])

        props = ac.basic_publish.call_args[1].get('properties')
        self.assertIsInstance(props, BasicProperties)
        self.assertTrue(hasattr(props, 'headers'))
        self.assertEquals(props.headers, {})

        # try another call to _send with a header
        self.ch._send(NameTrio('xp', 'namen'), 'daten', headers={'custom':'val'})

        # make sure our property showed up
        props = ac.basic_publish.call_args[1].get('properties')
        self.assertIn('custom', props.headers)
        self.assertEquals(props.headers['custom'], 'val')
Пример #3
0
class TestSendChannel(PyonTestCase):
    def setUp(self):
        self.ch = SendChannel()

    def test_connect(self):
        self.ch.connect(NameTrio("xp", "key"))
        self.assertTrue(hasattr(self.ch._send_name, "exchange"))
        self.assertTrue(hasattr(self.ch._send_name, "queue"))
        self.assertEquals(self.ch._send_name.exchange, "xp")
        self.assertEquals(self.ch._send_name.queue, "key")
        self.assertEquals(self.ch._exchange, "xp")

    def test_send(self):
        _sendmock = Mock()
        self.ch._send = _sendmock
        np = NameTrio("xp", "key")
        self.ch.connect(np)

        self.ch.send("data", {"header": sentinel.headervalue})
        _sendmock.assert_called_once_with(np, "data", headers={"header": sentinel.headervalue})

    def test__send(self):
        ac = Mock(pchannel.Channel)
        self.ch._amq_chan = ac

        # test sending in params
        self.ch._send(NameTrio("xp", "namen"), "daten")

        # get our props
        self.assertTrue(ac.basic_publish.called)
        self.assertIn("exchange", ac.basic_publish.call_args[1])
        self.assertIn("routing_key", ac.basic_publish.call_args[1])
        self.assertIn("body", ac.basic_publish.call_args[1])
        self.assertIn("immediate", ac.basic_publish.call_args[1])
        self.assertIn("mandatory", ac.basic_publish.call_args[1])
        self.assertIn("properties", ac.basic_publish.call_args[1])

        props = ac.basic_publish.call_args[1].get("properties")
        self.assertIsInstance(props, BasicProperties)
        self.assertTrue(hasattr(props, "headers"))
        self.assertEquals(props.headers, {})

        # try another call to _send with a header
        self.ch._send(NameTrio("xp", "namen"), "daten", headers={"custom": "val"})

        # make sure our property showed up
        props = ac.basic_publish.call_args[1].get("properties")
        self.assertIn("custom", props.headers)
        self.assertEquals(props.headers["custom"], "val")
Пример #4
0
 def setUp(self):
     self.ch = SendChannel()
Пример #5
0
 def setUp(self):
     self.ch = SendChannel()
Пример #6
0
class TestSendChannel(PyonTestCase):
    def setUp(self):
        self.ch = SendChannel()

    def test_connect(self):
        self.ch.connect(NameTrio('xp', 'key'))
        self.assertTrue(hasattr(self.ch._send_name, 'exchange'))
        self.assertTrue(hasattr(self.ch._send_name, 'queue'))
        self.assertEquals(self.ch._send_name.exchange, 'xp')
        self.assertEquals(self.ch._send_name.queue, 'key')
        self.assertEquals(self.ch._exchange, 'xp')

    def test_send(self):
        _sendmock = Mock()
        self.ch._send = _sendmock
        np = NameTrio('xp', 'key')
        self.ch.connect(np)

        self.ch.send('data', {'header':sentinel.headervalue})
        _sendmock.assert_called_once_with(np, 'data', headers={'header':sentinel.headervalue})

    def test__send(self):
        transport = Mock()
        transport.channel_number = sentinel.channel_number
        self.ch.on_channel_open(transport)

        # test sending in params
        self.ch._send(NameTrio('xp', 'namen'), 'daten')

        # get our props
        self.assertTrue(transport.publish_impl.called)
        self.assertIn('exchange', transport.publish_impl.call_args[1])
        self.assertIn('routing_key', transport.publish_impl.call_args[1])
        self.assertIn('body', transport.publish_impl.call_args[1])
        self.assertIn('immediate', transport.publish_impl.call_args[1])
        self.assertIn('mandatory', transport.publish_impl.call_args[1])
        self.assertIn('properties', transport.publish_impl.call_args[1])

        props = transport.publish_impl.call_args[1].get('properties')
        self.assertEquals(props, {})

        # try another call to _send with a header
        self.ch._send(NameTrio('xp', 'namen'), 'daten', headers={'custom':'val'})

        # make sure our property showed up
        props = transport.publish_impl.call_args[1].get('properties')
        self.assertIn('custom', props)
        self.assertEquals(props['custom'], 'val')
Пример #7
0
class TestSendChannel(PyonTestCase):
    def setUp(self):
        self.ch = SendChannel()

    def test_connect(self):
        self.ch.connect(NameTrio('xp', 'key'))
        self.assertTrue(hasattr(self.ch._send_name, 'exchange'))
        self.assertTrue(hasattr(self.ch._send_name, 'queue'))
        self.assertEquals(self.ch._send_name.exchange, 'xp')
        self.assertEquals(self.ch._send_name.queue, 'key')
        self.assertEquals(self.ch._exchange, 'xp')

    def test_send(self):
        _sendmock = Mock()
        self.ch._send = _sendmock
        np = NameTrio('xp', 'key')
        self.ch.connect(np)

        self.ch.send('data', {'header': sentinel.headervalue})
        _sendmock.assert_called_once_with(
            np, 'data', headers={'header': sentinel.headervalue})

    def test__send(self):
        transport = Mock()
        transport.channel_number = sentinel.channel_number
        self.ch.on_channel_open(transport)

        # test sending in params
        self.ch._send(NameTrio('xp', 'namen'), 'daten')

        # get our props
        self.assertTrue(transport.publish_impl.called)
        self.assertIn('exchange', transport.publish_impl.call_args[1])
        self.assertIn('routing_key', transport.publish_impl.call_args[1])
        self.assertIn('body', transport.publish_impl.call_args[1])
        self.assertIn('immediate', transport.publish_impl.call_args[1])
        self.assertIn('mandatory', transport.publish_impl.call_args[1])
        self.assertIn('properties', transport.publish_impl.call_args[1])

        props = transport.publish_impl.call_args[1].get('properties')
        self.assertEquals(props, {})

        # try another call to _send with a header
        self.ch._send(NameTrio('xp', 'namen'),
                      'daten',
                      headers={'custom': 'val'})

        # make sure our property showed up
        props = transport.publish_impl.call_args[1].get('properties')
        self.assertIn('custom', props)
        self.assertEquals(props['custom'], 'val')
Пример #8
0
class TestSendChannel(PyonTestCase):
    def setUp(self):
        self.ch = SendChannel()

    def test_connect(self):
        self.ch.connect(NameTrio("xp", "key"))
        self.assertTrue(hasattr(self.ch._send_name, "exchange"))
        self.assertTrue(hasattr(self.ch._send_name, "queue"))
        self.assertEquals(self.ch._send_name.exchange, "xp")
        self.assertEquals(self.ch._send_name.queue, "key")
        self.assertEquals(self.ch._exchange, "xp")

    def test_send(self):
        _sendmock = Mock()
        self.ch._send = _sendmock
        np = NameTrio("xp", "key")
        self.ch.connect(np)

        self.ch.send("data", {"header": sentinel.headervalue})
        _sendmock.assert_called_once_with(np, "data", headers={"header": sentinel.headervalue})

    def test__send(self):
        transport = Mock()
        transport.channel_number = sentinel.channel_number
        self.ch.on_channel_open(transport)

        # test sending in params
        self.ch._send(NameTrio("xp", "namen"), "daten")

        # get our props
        self.assertTrue(transport.publish_impl.called)
        self.assertIn("exchange", transport.publish_impl.call_args[1])
        self.assertIn("routing_key", transport.publish_impl.call_args[1])
        self.assertIn("body", transport.publish_impl.call_args[1])
        self.assertIn("immediate", transport.publish_impl.call_args[1])
        self.assertIn("mandatory", transport.publish_impl.call_args[1])
        self.assertIn("properties", transport.publish_impl.call_args[1])

        props = transport.publish_impl.call_args[1].get("properties")
        self.assertEquals(props, {})

        # try another call to _send with a header
        self.ch._send(NameTrio("xp", "namen"), "daten", headers={"custom": "val"})

        # make sure our property showed up
        props = transport.publish_impl.call_args[1].get("properties")
        self.assertIn("custom", props)
        self.assertEquals(props["custom"], "val")