def test__build_header(self, mockr, mockp): mockr.return_value = {'one':1, 'two':2} mockp.return_value = {'two':-2, 'three':3} ep = ProcessSubscriberEndpointUnit() header = ep._build_header(sentinel.raw_msg, {}) self.assertEquals(header, {'one':1, 'two':-2, 'three':3})
def test__build_header(self, mockr, mockp): mockr.return_value = {'one': 1, 'two': 2} mockp.return_value = {'two': -2, 'three': 3} ep = ProcessSubscriberEndpointUnit() header = ep._build_header(sentinel.raw_msg, {}) self.assertEquals(header, {'one': 1, 'two': -2, 'three': 3})
def test__message_received(self, mockmr): procmock = Mock() procmock.push_context = MagicMock() ep = ProcessSubscriberEndpointUnit(process=procmock, interceptors={}) ep._message_received(sentinel.msg, sentinel.headers) procmock.push_context.assert_called_once_with(sentinel.headers) procmock.push_context().__enter__.assert_called_once_with() mockmr.assert_called_once_with(ep, sentinel.msg, sentinel.headers)
def test__make_routing_call(self, mockmrc): ep = ProcessSubscriberEndpointUnit() ep._make_routing_call(sentinel.call, sentinel.timeout, sentinel.arg, kw=sentinel.kwarg) mockmrc.assert_called_once_with(ep, sentinel.call, sentinel.timeout, sentinel.arg, kw=sentinel.kwarg)
def test__make_routing_call_with_routing_call_set(self): mrc = Mock() proc = Mock() proc.get_context.return_value = sentinel.context ep = ProcessSubscriberEndpointUnit(process=proc, routing_call=mrc) ep._make_routing_call(sentinel.call, sentinel.timeout, sentinel.arg, kw=sentinel.kwarg) mrc.assert_called_once_with(sentinel.call, sentinel.context, sentinel.arg, kw=sentinel.kwarg) mrcar = mrc() #mrcar.get.assert_called_once_with(timeout=sentinel.timeout) mrcar.get.assert_called_once_with()
def test_init(self, mockr, mockp): ep = ProcessSubscriberEndpointUnit(process=sentinel.process, callback=sentinel.callback, other=sentinel.other) mockp.assert_called_once_with(ep, process=sentinel.process) mockr.assert_called_once_with(ep, callback=sentinel.callback, other=sentinel.other)