def test_put_history(self): self.reply_queue.put(True) fetch_id = 543 item_id = 111 samples = [{"value": "123", "time": "20150321151321"}] common.assertNotRaises(self.processor.put_history, samples, item_id, fetch_id)
def test_acknowledge(self): destination_queue = DummyQueue() test_id = "test" self.__dispatcher.attach_destination(destination_queue, test_id) acknowledge = common.returnPrivObj(self.__dispatcher, "__acknowledge") test_message = (test_id, 1) common.assertNotRaises(acknowledge, test_message)
def test_hap_update_monitoring_server_info(self): test_params = {"serverId": None, "url": None, "nickName": None, "userName": None, "password": None, "pollingIntervalSec": None, "retryIntervalSec": None, "extendedInfo": None, "type": None} common.assertNotRaises(self.__main_plugin.hap_update_monitoring_server_info, test_params)
def test_load_transporter(self): test_transport_arguments = namedtuple( "transport_argument", "transporter_module transporter") test_transport_arguments.transporter_module = "hatohol.haplib" test_transport_arguments.transporter = "RabbitMQHapiConnector" common.assertNotRaises(haplib.Utils.load_transporter, test_transport_arguments)
def test_load_transporter(self): test_transport_arguments = namedtuple("transport_argument", "transporter_module transporter") test_transport_arguments.transporter_module = "haplib" test_transport_arguments.transporter = "RabbitMQHapiConnector" common.assertNotRaises(haplib.Utils.load_transporter, test_transport_arguments)
def test_hap_fetch_history(self): params = { "itemId": "1", "beginTime": None, "endTime": None, "fetchId": 1 } common.assertNotRaises(self.main.hap_fetch_history, params, 1)
def test_poll_in_block(self): poll_in_try_block = common.returnPrivObj(self.poller, "__poll_in_try_block") arm_info = haplib.ArmInfo() self.poller.set_dispatch_queue(DummyQueue()) self.poller._HapiProcessor__reply_queue = DummyQueue() org_q = self.poller._BasePoller__command_queue._CommandQueue__q self.poller._BasePoller__command_queue._CommandQueue__q = DummyCommandQueue() common.assertNotRaises(poll_in_try_block, arm_info) self.poller._BasePoller__command_queue._CommandQueue__q = org_q
def test_dispatch_receive_id_notification(self): destination_queue = DummyQueue() test_id = "test" test_contents = 1 test_message = (test_id, test_contents) dispatch_queue = common.returnPrivObj(self.__dispatcher, "__dispatch_queue") dispatch_queue.put(test_message) self.__dispatcher.attach_destination(destination_queue, test_id) dispatch = common.returnPrivObj(self.__dispatcher, "__dispatch") common.assertNotRaises(dispatch)
def test_check_error_dict_success(self): error_dict = { "error": { "code": 1, "message": "test_message", "data": "test_data" }, "id": 1 } common.assertNotRaises(haplib.Utils.__check_error_dict, error_dict)
def test_poll_in_block(self): poll_in_try_block = common.returnPrivObj(self.poller, "__poll_in_try_block") arm_info = haplib.ArmInfo() self.poller.set_dispatch_queue(DummyQueue()) self.poller._HapiProcessor__reply_queue = DummyQueue() org_q = self.poller._BasePoller__command_queue._CommandQueue__q self.poller._BasePoller__command_queue._CommandQueue__q =\ DummyCommandQueue() common.assertNotRaises(poll_in_try_block, arm_info) self.poller._BasePoller__command_queue._CommandQueue__q = org_q
def test_hap_update_monitoring_server_info(self): test_params = { "serverId": None, "url": None, "nickName": None, "userName": None, "password": None, "pollingIntervalSec": None, "retryIntervalSec": None, "extendedInfo": None, "type": None } common.assertNotRaises( self.__main_plugin.hap_update_monitoring_server_info, test_params)
def test_dispatch_receive_response(self): destination_queue = DummyQueue() test_id = "test" test_contents = haplib.ParsedMessage() test_contents.message_id = 1 self.__dispatcher.attach_destination(destination_queue, test_id) acknowledge = common.returnPrivObj(self.__dispatcher, "__acknowledge") test_message = (test_id, test_contents.message_id) acknowledge(test_message) test_message = (test_id, test_contents) dispatch_queue = common.returnPrivObj(self.__dispatcher, "__dispatch_queue") dispatch_queue.put(test_message) common.assertNotRaises(acknowledge, test_message) dispatch = common.returnPrivObj(self.__dispatcher, "__dispatch") common.assertNotRaises(dispatch)
def test_daemonize(self): dispatcher = DispatcherForTest() common.assertNotRaises(dispatcher.daemonize)
def test_daemonize(self): common.assertNotRaises(self.receiver.daemonize)
def test_messenger_get_broken_error(self): messenger = common.returnPrivObj(self.receiver, "__messenger") common.assertNotRaises(messenger, None, '{"error": "test"}')
def test_wait_acknowledge(self): self.reply_queue.put(True) wait_acknowledge = common.returnPrivObj(self.processor, "__wait_acknowledge") common.assertNotRaises(wait_acknowledge, 1)
def test_put_items(self): self.reply_queue.put(True) fetch_id = 543 items = [{"itemId": "123", "host_id": "FOOOOOO"}] common.assertNotRaises(self.processor.put_items, items, fetch_id)
def test_get_cached_event_last_info(self): self.reply_queue.put(True) common.assertNotRaises(self.processor.get_cached_event_last_info)
def test_poll_triggers(self): common.assertNotRaises(self.poller.poll_triggers)
def test_poll_host_group_membership(self): common.assertNotRaises(self.poller.poll_host_group_membership)
def test_poll_host_groups(self): common.assertNotRaises(self.poller.poll_host_groups)
def test_poll_setup(self): common.assertNotRaises(self.poller.poll_setup)
def test_poll(self): common.assertNotRaises(self.poller.poll)
def test_start_dispatcher(self): self.__main_plugin._HapiProcessor__dispatcher = DispatcherForTest() common.assertNotRaises(self.__main_plugin.start_dispatcher)
def test_start_receiver(self): common.assertNotRaises(self.__main_plugin.start_receiver)
def test_request_exit(self): common.assertNotRaises(self.__main_plugin.request_exit)
def test_poll_events(self): common.assertNotRaises(self.poller.poll_events)
def test_on_aboted_poll(self): common.assertNotRaises(self.poller.on_aborted_poll)
def test_put_events(self): self.reply_queue.put(True) events = [{"eventId": 123, "test_events":"test"}] common.assertNotRaises(self.processor.put_events, events)
def test_return_error(self): common.assertNotRaises(self.__main_plugin.hap_return_error, -32700, 1)
def test_call(self): dispatcher = DispatcherForTest() common.assertNotRaises(dispatcher)
def test_messenger(self): messenger = common.returnPrivObj(self.receiver, "__messenger") common.assertNotRaises(messenger, None, "test_message")
def test_register_callback(self): common.assertNotRaises(self.__main_plugin.register_callback, "test_code", "test_handler")
def test_call(self): common.assertNotRaises(self.receiver.__call__)
def test_close_connection_without_connection(self): comm = Common() testutil.assertNotRaises(comm.close_connection)
def test_constructor(self): testutils.assertNotRaises(Common)
def test_ensure_connection(self): comm = CommonForTest() testutil.assertNotRaises(comm.ensure_connection)