mock.sentinel.channel_number

Here are the examples of the python api mock.sentinel.channel_number taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: pyon Source File: test_channel.py
Function: test_ack
    def test_ack(self):
        transport = Mock()
        transport.channel_number = sentinel.channel_number
        self.ch.on_channel_open(transport)

        self.ch.ack(sentinel.delivery_tag)

        transport.ack_impl.assert_called_once_with(sentinel.delivery_tag)

Example 2

Project: pyon Source File: test_channel.py
Function: test_reject
    def test_reject(self):
        transport = Mock()
        transport.channel_number = sentinel.channel_number
        self.ch.on_channel_open(transport)

        self.ch.reject(sentinel.delivery_tag, requeue=True)

        transport.reject_impl.assert_called_once_with(sentinel.delivery_tag, requeue=True)

Example 3

Project: pyon Source File: test_channel.py
    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')