def test_send_not_addressed(self, send): node = Queue() plugin = Mock(url='') request = Document(replyto=None) status = 'rejected' consumer = RequestConsumer(node, plugin) # Test consumer.send(request, status) # Validation self.assertFalse(send.called)
def test_send(self, ts, _open, _close, send): send.side_effect = ValueError node = Queue() plugin = Mock(url='') request = Document(sn=1, replyto='elmer', data=123) status = 'rejected' details = dict(a=1) consumer = RequestConsumer(node, plugin) # Test consumer.send(request, status, **details) # Validation _open.assert_called_once_with() _close.assert_called_once_with()
def test_send(self, ts, _open, _close, send): send.side_effect = ValueError node = Queue() plugin = Mock(url='') request = Document( sn=1, replyto='elmer', data=123) status = 'rejected' details = dict(a=1) consumer = RequestConsumer(node, plugin) # Test consumer.send(request, status, **details) # Validation _open.assert_called_once_with() _close.assert_called_once_with()
def test_send(self, ts, _open, _close, send): node = Queue() plugin = Mock(url='') request = Document(sn=1, replyto='elmer', data=123) status = 'rejected' details = dict(a=1) consumer = RequestConsumer(node, plugin) # Test consumer.send(request, status, **details) # Validation _open.assert_called_once_with() send.assert_called_once_with(request.replyto, sn=request.sn, data=request.data, status=status, timestamp=ts.return_value, **details) _close.assert_called_once_with()
def test_dispatch(self): node = Queue() plugin = Mock(url='') request = Document() consumer = RequestConsumer(node, plugin) consumer.send = Mock() # Test consumer.dispatch(request) # Validation consumer.send.assert_called_once_with(request, 'accepted') plugin.scheduler.add.assert_called_once_with(request)
def test_send(self, ts, _open, _close, send): node = Queue() plugin = Mock(url='') request = Document( sn=1, replyto='elmer', data=123) status = 'rejected' details = dict(a=1) consumer = RequestConsumer(node, plugin) # Test consumer.send(request, status, **details) # Validation _open.assert_called_once_with() send.assert_called_once_with( request.replyto, sn=request.sn, data=request.data, status=status, timestamp=ts.return_value, **details) _close.assert_called_once_with()
def test_rejected(self): node = Queue() plugin = Mock(url='') code = '401' description = 'failed' details = dict(msg='failed') document = Document(field='value') consumer = RequestConsumer(node, plugin) consumer.send = Mock() # Test consumer.rejected(code, description, document, details) # Validation consumer.send.assert_called_once_with( document, 'rejected', **{ 'code': code, 'description': description, 'details': details, })
def test_rejected(self): node = Queue() plugin = Mock(url='') code = '401' description = 'failed' details = dict(msg='failed') document = Document(field='value') consumer = RequestConsumer(node, plugin) consumer.send = Mock() # Test consumer.rejected(code, description, document, details) # Validation consumer.send.assert_called_once_with( document, 'rejected', **{ 'code' : code, 'description': description, 'details': details, } )