示例#1
0
    def test_send(self, mocksendchannel):
        depmock = Mock()
        pubchan = PublisherChannel()
        pubchan._declare_exchange = depmock

        pubchan._send_name = NameTrio(sentinel.xp, sentinel.routing_key)

        pubchan.send(sentinel.data)

        depmock.assert_called_once_with(sentinel.xp)
        mocksendchannel.send.assert_called_once_with(pubchan, sentinel.data, headers=None)
示例#2
0
    def test_send(self, mocksendchannel):
        depmock = Mock()
        pubchan = PublisherChannel()
        pubchan._declare_exchange = depmock

        pubchan._send_name = NameTrio(sentinel.xp, sentinel.routing_key)

        pubchan.send(sentinel.data)

        depmock.assert_called_once_with(sentinel.xp)
        mocksendchannel.send.assert_called_once_with(pubchan,
                                                     sentinel.data,
                                                     headers=None)
示例#3
0
    def test_send(self, mocksendchannel):
        depmock = Mock()
        pubchan = PublisherChannel()
        pubchan._declare_exchange = depmock

        pubchan._send_name = NameTrio(sentinel.xp, sentinel.routing_key)

        pubchan.send(sentinel.data)

        depmock.assert_called_once_with(sentinel.xp)
        mocksendchannel.send.assert_called_once_with(pubchan, sentinel.data, headers=None)
        self.assertTrue(pubchan._declared)

        # call send again, to show declare is not called again
        pubchan.send(sentinel.data2)
        depmock.assert_called_once_with(sentinel.xp)
        self.assertEquals(mocksendchannel.send.call_count, 2)
        mocksendchannel.send.assert_called_with(pubchan, sentinel.data2, headers=None)
示例#4
0
    def test_send(self, mocksendchannel):
        depmock = Mock()
        pubchan = PublisherChannel()
        pubchan._declare_exchange = depmock

        pubchan._send_name = NameTrio(sentinel.xp, sentinel.routing_key)

        pubchan.send(sentinel.data)

        depmock.assert_called_once_with(sentinel.xp)
        mocksendchannel.send.assert_called_once_with(pubchan,
                                                     sentinel.data,
                                                     headers=None)
        self.assertTrue(pubchan._declared)

        # call send again, to show declare is not called again
        pubchan.send(sentinel.data2)
        depmock.assert_called_once_with(sentinel.xp)
        self.assertEquals(mocksendchannel.send.call_count, 2)
        mocksendchannel.send.assert_called_with(pubchan,
                                                sentinel.data2,
                                                headers=None)
示例#5
0
 def test_send_no_name(self, mocksendchannel):
     pubchan = PublisherChannel()
     self.assertRaises(AssertionError, pubchan.send, sentinel.data)
示例#6
0
 def test_init(self, mocksendchannel):
     pubchan = PublisherChannel()
     self.assertFalse(pubchan._declared)
示例#7
0
 def test_init(self, mocksendchannel):
     pubchan = PublisherChannel()