

def test_process_message(self):
    msg_runner = fakes.get_message_runner('api-cell')
    dispatcher = rpc_driver.InterCellRPCDispatcher(msg_runner)
    message = messaging._BroadcastMessage(msg_runner, self.ctxt, 'fake', {
        
    }, 'down', fanout=True)
    call_info = {
        
    }

    def _fake_message_from_json(json_message):
        call_info['json_message'] = json_message
        self.assertEqual(message.to_json(), json_message)
        return message

    def _fake_process():
        call_info['process_called'] = True
    self.stubs.Set(msg_runner, 'message_from_json', _fake_message_from_json)
    self.stubs.Set(message, 'process', _fake_process)
    dispatcher.process_message(self.ctxt, message.to_json())
    self.assertEqual(message.to_json(), call_info['json_message'])
    self.assertTrue(call_info['process_called'])

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/cells/test_cells_rpc_driver.py CellsRPCDriverTestCase.test_process_message/original