Example #1
0
 def test_ensure_connection(self):
     options = {}
     comm = CommonForTest(options)
     comm.ensure_connection()
     nova_ep = testutils.returnPrivObj(comm, "__nova_ep", "Common")
     self.assertEqual(nova_ep, comm.NOVA_EP)
     ceilometer_ep = \
         testutils.returnPrivObj(comm, "__ceilometer_ep", "Common")
     self.assertEqual(ceilometer_ep, comm.CEILOMETER_EP)
Example #2
0
 def test_ensure_connection(self):
     options = {}
     comm = CommonForTest(options)
     comm.ensure_connection()
     nova_ep = testutils.returnPrivObj(comm, "__nova_ep", "Common")
     self.assertEqual(nova_ep, comm.NOVA_EP)
     ceilometer_ep = \
         testutils.returnPrivObj(comm, "__ceilometer_ep", "Common")
     self.assertEqual(ceilometer_ep, comm.CEILOMETER_EP)
Example #3
0
 def test_detect_implemented_procedures(self):
     detect_implemented_procedures = common.returnPrivObj(self.__main_plugin,
                                         "__detect_implemented_procedures")
     detect_implemented_procedures()
     implemented_procedures = common.returnPrivObj(self.__main_plugin,
                                                   "__implemented_procedures")
     self.assertEquals({"exchangeProfile": self.__main_plugin.hap_exchange_profile,
                        "updateMonitoringServerInfo": self.__main_plugin.hap_update_monitoring_server_info},
                        implemented_procedures)
Example #4
0
 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_log_status(self):
     poller = haplib.BasePoller(sender=self.sender, process_id="test")
     log_time = common.returnPrivObj(poller, "__next_log_status_time")
     poller.log_status(haplib.ArmInfo())
     # check if the next time is update
     new_time = common.returnPrivObj(poller, "__next_log_status_time")
     self.assertGreater(new_time, log_time)
     # call again soon. __new_log_status_time should not be updated.
     new_time2 = common.returnPrivObj(poller, "__next_log_status_time")
     self.assertEquals(new_time2, new_time)
Example #6
0
 def test_log_status(self):
     poller = haplib.BasePoller(sender=self.sender, process_id="test")
     log_time = common.returnPrivObj(poller, "__next_log_status_time")
     poller.log_status(haplib.ArmInfo())
     # check if the next time is update
     new_time = common.returnPrivObj(poller, "__next_log_status_time")
     self.assertGreater(new_time, log_time)
     # call again soon. __new_log_status_time should not be updated.
     new_time2 = common.returnPrivObj(poller, "__next_log_status_time")
     self.assertEquals(new_time2, new_time)
Example #7
0
 def test_reset(self):
     self.processor.reset()
     prev_hosts = common.returnPrivObj(self.processor, "__previous_hosts")
     prev_host_groups = common.returnPrivObj(self.processor, "__previous_host_groups")
     prev_host_group_membership = common.returnPrivObj(self.processor, "__previous_host_group_membership")
     event_last_info = common.returnPrivObj(self.processor, "__event_last_info")
     self.assertIsNone(prev_hosts)
     self.assertIsNone(prev_host_groups)
     self.assertIsNone(prev_host_group_membership)
     self.assertIsNone(event_last_info)
 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_detect_implemented_procedures(self):
     detect_implemented_procedures = common.returnPrivObj(
         self.__main_plugin, "__detect_implemented_procedures")
     detect_implemented_procedures()
     implemented_procedures = common.returnPrivObj(
         self.__main_plugin, "__implemented_procedures")
     self.assertEquals(
         {
             "exchangeProfile":
             self.__main_plugin.hap_exchange_profile,
             "updateMonitoringServerInfo":
             self.__main_plugin.hap_update_monitoring_server_info
         }, implemented_procedures)
 def test_reset(self):
     self.processor.reset()
     prev_hosts = common.returnPrivObj(self.processor, "__previous_hosts")
     prev_host_groups = common.returnPrivObj(self.processor,
                                             "__previous_host_groups")
     prev_host_group_membership = \
             common.returnPrivObj(self.processor,
                                  "__previous_host_group_membership")
     event_last_info = common.returnPrivObj(self.processor,
                                            "__event_last_info")
     self.assertIsNone(prev_hosts)
     self.assertIsNone(prev_host_groups)
     self.assertIsNone(prev_host_group_membership)
     self.assertIsNone(event_last_info)
Example #11
0
 def test__collect_events_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     target_func = testutils.returnPrivObj(comm, "__collect_events_and_put",
                                           "Common")
     # TODO: test the path when alarm_cache is hit
     #       In that case, hostId, hostName, and brief should not be "N/A"
     alarm_id = "alarm1"
     last_alarm_time = "20150423112233.123000"
     fetch_id = "a123"
     target_func(alarm_id, last_alarm_time, fetch_id)
     self.assertEquals(comm.store["fetch_id"], fetch_id)
     self.assertEquals(comm.store["last_info_generator"],
         testutils.returnPrivObj(comm, "__last_info_generator", "Common"))
     self.assertEquals(comm.store["events"], [
         {
             "eventId": "event_id_0",
             "time": "20130322045000.334455",
             "type": "GOOD",
             "status": "OK",
             "triggerId": alarm_id,
             "hostId": "N/A",
             "hostName": "N/A",
             "severity": "ERROR",
             "brief": "N/A",
             "extendedInfo": "",
         }, {
             "eventId": "event_id_1",
             "time": "20130322045600.334455",
             "status": "OK",
             "type": "GOOD",
             "triggerId": alarm_id,
             "hostId": "N/A",
             "hostName": "N/A",
             "severity": "ERROR",
             "brief": "N/A",
             "extendedInfo": "",
         }, {
             "eventId": "event_id_2",
             "time": "20130322045612.111222",
             "type": "BAD",
             "status": "NG",
             "triggerId": alarm_id,
             "hostId": "N/A",
             "hostName": "N/A",
             "severity": "ERROR",
             "brief": "N/A",
             "extendedInfo": "",
         }])
Example #12
0
 def test__collect_events_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     target_func = testutils.returnPrivObj(comm, "__collect_events_and_put",
                                           "Common")
     # TODO: test the path when alarm_cache is hit
     #       In that case, hostId, hostName, and brief should not be "N/A"
     alarm_id = "alarm1"
     last_alarm_time = "20150423112233.123000"
     fetch_id = "a123"
     target_func(alarm_id, last_alarm_time, fetch_id)
     self.assertEquals(comm.store["fetch_id"], fetch_id)
     self.assertEquals(
         comm.store["last_info_generator"],
         testutils.returnPrivObj(comm, "__last_info_generator", "Common"))
     self.assertEquals(comm.store["events"], [{
         "eventId": "event_id_0",
         "time": "20130322045000.334455",
         "type": "GOOD",
         "status": "OK",
         "triggerId": alarm_id,
         "hostId": "N/A",
         "hostName": "N/A",
         "severity": "ERROR",
         "brief": "N/A",
         "extendedInfo": "",
     }, {
         "eventId": "event_id_1",
         "time": "20130322045600.334455",
         "status": "OK",
         "type": "GOOD",
         "triggerId": alarm_id,
         "hostId": "N/A",
         "hostName": "N/A",
         "severity": "ERROR",
         "brief": "N/A",
         "extendedInfo": "",
     }, {
         "eventId": "event_id_2",
         "time": "20130322045612.111222",
         "type": "BAD",
         "status": "NG",
         "triggerId": alarm_id,
         "hostId": "N/A",
         "hostName": "N/A",
         "severity": "ERROR",
         "brief": "N/A",
         "extendedInfo": "",
     }])
Example #13
0
 def test_encode_decode_last_alarm_timestamp_map(self):
     comm = CommonForTest()
     enc_func = testutils.returnPrivObj(
         comm, "__encode_last_alarm_timestamp_map", "Common")
     source = {"ABCDEFG": 1, "2345": "foo"}
     encoded = enc_func(source)
     self.__assert_decode_last_alarm_timestamp_map(encoded, source)
Example #14
0
 def __assert_get_resource(self, num_items, expect):
     comm = CommonForTest({"href1_num_items": num_items})
     get_resource = \
         testutils.returnPrivObj(comm, "__get_resource", "Common")
     rel = None
     href = "http://HREF/href1"
     self.assertEquals(get_resource(rel, href), expect)
Example #15
0
 def test_encode_decode_last_alarm_timestamp_map(self):
     comm = CommonForTest()
     enc_func = testutils.returnPrivObj(
                     comm, "__encode_last_alarm_timestamp_map", "Common")
     source = {"ABCDEFG": 1, "2345": "foo"}
     encoded = enc_func(source)
     self.__assert_decode_last_alarm_timestamp_map(encoded, source)
 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)
Example #17
0
 def __assert_get_resource(self, num_items, expect):
     comm = CommonForTest({"href1_num_items": num_items})
     get_resource = \
         testutils.returnPrivObj(comm, "__get_resource", "Common")
     rel = None
     href = "http://HREF/href1"
     self.assertEquals(get_resource(rel, href), expect)
Example #18
0
 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)
Example #19
0
 def test_wait_acknowledge_timeout(self):
     self.processor.set_timeout_sec(1)
     wait_acknowledge = common.returnPrivObj(self.processor,
                                             "__wait_acknowledge")
     try:
         wait_acknowledge(1)
     except Exception as exception:
         self.assertEquals(str(exception), "Timeout")
Example #20
0
 def __assert_parse_alarm_host(self, threshold_rule,  expect,
                               host_cache=None):
     comm = CommonForTest()
     if host_cache is not None:
         comm.set_host_cache(host_cache)
     target_func = testutils.returnPrivObj(
                         comm, "__parse_alarm_host", "Common")
     self.assertEquals(target_func(threshold_rule), expect)
Example #21
0
 def test_wait_response_timeout(self):
     self.processor.set_timeout_sec(1)
     test_id = 1
     wait_response = common.returnPrivObj(self.processor, "__wait_response")
     try:
         wait_response(test_id)
     except Exception as exception:
         self.assertEquals(str(exception), "Timeout")
Example #22
0
 def test_remove_missing_alarm_before_get_all_alarms(self):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(comm, "__remove_missing_alarm",
                                           "Common")
     alarm_time_map = {"alarm1": "20120222101011.123456",
                       "alarm2": "20120322121311.123456",
     }
     target_func(alarm_time_map)
     self.assertEquals(len(alarm_time_map), 2)
Example #23
0
    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)
Example #24
0
 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
Example #25
0
 def test__collect_items_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     host_id = "host_id2"
     target_func = \
         testutils.returnPrivObj(comm, "__collect_items_and_put", "Common")
     expect_item = comm.EXPECT_ITEM_HOST_ID1_CNAME
     expect_item["itemId"] = "host_id2.CNAME"
     expect_item["hostId"] = host_id
     self.assertEquals(target_func(host_id), [expect_item])
    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)
Example #27
0
 def test_remove_missing_alarm_before_get_all_alarms(self):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(comm, "__remove_missing_alarm",
                                           "Common")
     alarm_time_map = {
         "alarm1": "20120222101011.123456",
         "alarm2": "20120322121311.123456",
     }
     target_func(alarm_time_map)
     self.assertEquals(len(alarm_time_map), 2)
Example #28
0
 def test__collect_items_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     host_id = "host_id2"
     target_func = \
         testutils.returnPrivObj(comm, "__collect_items_and_put", "Common")
     expect_item = comm.EXPECT_ITEM_HOST_ID1_CNAME
     expect_item["itemId"] = "host_id2.CNAME"
     expect_item["hostId"] = host_id
     self.assertEquals(target_func(host_id), [expect_item])
Example #29
0
 def __assert_parse_alarm_host(self,
                               threshold_rule,
                               expect,
                               host_cache=None):
     comm = CommonForTest()
     if host_cache is not None:
         comm.set_host_cache(host_cache)
     target_func = testutils.returnPrivObj(comm, "__parse_alarm_host",
                                           "Common")
     self.assertEquals(target_func(threshold_rule), expect)
 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
Example #31
0
 def test_remove_missing_alarm(self):
     comm = CommonForTest()
     comm.ensure_connection()
     comm.collect_triggers_and_put()
     target_func = testutils.returnPrivObj(comm, "__remove_missing_alarm",
                                           "Common")
     alarm_time_map = {"alarm1": "20120222101011.123456",
                       "112233": "20120322121311.123456",
     }
     target_func(alarm_time_map)
     self.assertEquals(alarm_time_map, {"112233": "20120322121311.123456"})
Example #32
0
 def test_remove_missing_alarm(self):
     comm = CommonForTest()
     comm.ensure_connection()
     comm.collect_triggers_and_put()
     target_func = testutils.returnPrivObj(comm, "__remove_missing_alarm",
                                           "Common")
     alarm_time_map = {
         "alarm1": "20120222101011.123456",
         "112233": "20120322121311.123456",
     }
     target_func(alarm_time_map)
     self.assertEquals(alarm_time_map, {"112233": "20120322121311.123456"})
    def test_wait_response(self):
        exact_result = "test_result"
        exact_id = 1
        reply_queue = self.reply_queue
        pm = haplib.ParsedMessage()
        pm.message_dict = {"id": exact_id, "result": exact_result}
        pm.message_id = exact_id
        reply_queue.put(pm)
        wait_response = common.returnPrivObj(self.processor, "__wait_response")
        output = wait_response(exact_id)

        self.assertEquals(output, exact_result)
Example #34
0
 def test_private_set_ms_info(self):
     set_ms_info = common.returnPrivObj(self.poller, "__set_ms_info")
     test_params = {"serverId": None, "url": None, "nickName": None,
                    "userName": None, "password": None,
                    "pollingIntervalSec": None, "retryIntervalSec": None,
                    "extendedInfo": None, "type": None}
     ms_info = haplib.MonitoringServerInfo(test_params)
     try:
         set_ms_info(ms_info)
         raise
     except haplib.Signal:
         pass
Example #35
0
    def test_wait_response(self):
        exact_result = "test_result"
        exact_id = 1
        reply_queue = self.reply_queue
        pm = haplib.ParsedMessage()
        pm.message_dict = {"id": exact_id, "result": exact_result}
        pm.message_id = exact_id
        reply_queue.put(pm)
        wait_response = common.returnPrivObj(self.processor, "__wait_response")
        output = wait_response(exact_id)

        self.assertEquals(output, exact_result)
Example #36
0
 def test_last_info_generator(self):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(comm, "__last_info_generator",
                                           "Common")
     # TODO: test the path when __alarm_last_time_map.get(alarm_id) is hit
     events = [{
         "triggerId": "alarm1",
         "time": "20121212121212.121212",
     }, {
         "triggerId": "alarm2",
         "time": "20121212121213.131313",
     }]
     last_info = target_func(events)
     expect = {
         "alarm1": "20121212121212.121212",
         "alarm2": "20121212121213.131313",
     }
     self.__assert_decode_last_alarm_timestamp_map(last_info, expect)
Example #37
0
 def test_last_info_generator(self):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(comm, "__last_info_generator",
                                           "Common")
     # TODO: test the path when __alarm_last_time_map.get(alarm_id) is hit
     events = [{
         "triggerId": "alarm1",
         "time": "20121212121212.121212",
     }, {
         "triggerId": "alarm2",
         "time": "20121212121213.131313",
     }]
     last_info = target_func(events)
     expect =  {
         "alarm1": "20121212121212.121212",
         "alarm2": "20121212121213.131313",
     }
     self.__assert_decode_last_alarm_timestamp_map(last_info, expect)
Example #38
0
    def test__setup_ssl(self):
        conn = RabbitMQConnector()
        target_func = testutils.returnPrivObj(conn, "__setup_ssl", "RabbitMQConnector")
        conn_args = {}
        transporter_args = self.__get_default_transporter_args()
        target_func(conn_args, transporter_args)
        self.assertNotIn("ssl", conn_args)
        self.assertNotIn("ssl_options", conn_args)

        transporter_args["amqp_ssl_key"] = "/foo/key"
        transporter_args["amqp_ssl_cert"] = "/foo/cert"
        transporter_args["amqp_ssl_ca"] = "/kamo/ca"
        conn_args = {}
        target_func(conn_args, transporter_args)
        self.assertTrue(conn_args["ssl"])
        ssl_options = conn_args["ssl_options"]
        self.assertEquals(ssl_options["keyfile"], "/foo/key")
        self.assertEquals(ssl_options["certfile"], "/foo/cert")
        self.assertEquals(ssl_options["ca_certs"], "/kamo/ca")
 def test_private_set_ms_info(self):
     set_ms_info = common.returnPrivObj(self.poller, "__set_ms_info")
     test_params = {
         "serverId": None,
         "url": None,
         "nickName": None,
         "userName": None,
         "password": None,
         "pollingIntervalSec": None,
         "retryIntervalSec": None,
         "extendedInfo": None,
         "type": None
     }
     ms_info = haplib.MonitoringServerInfo(test_params)
     try:
         set_ms_info(ms_info)
         raise
     except haplib.Signal:
         pass
    def test__setup_ssl(self):
        conn = RabbitMQConnector()
        target_func = testutils.returnPrivObj(conn, "__setup_ssl", "RabbitMQConnector")
        conn_args = {}
        transporter_args = self.__get_default_transporter_args()
        target_func(conn_args, transporter_args)
        self.assertNotIn("ssl", conn_args)
        self.assertNotIn("ssl_options", conn_args)

        transporter_args["amqp_ssl_key"] = "/foo/key"
        transporter_args["amqp_ssl_cert"] = "/foo/cert"
        transporter_args["amqp_ssl_ca"] = "/kamo/ca"
        conn_args = {}
        target_func(conn_args, transporter_args)
        self.assertTrue(conn_args["ssl"])
        ssl_options = conn_args["ssl_options"]
        self.assertEquals(ssl_options["keyfile"], "/foo/key")
        self.assertEquals(ssl_options["certfile"], "/foo/cert")
        self.assertEquals(ssl_options["ca_certs"], "/kamo/ca")
Example #41
0
 def __assert(self, query, expect):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(
                         comm, "__parse_alarm_host_each", "Common")
     self.assertEquals(target_func(query), expect)
Example #42
0
 def __assert_decode_last_alarm_timestamp_map(self, last_info, source):
     comm = CommonForTest()
     dec_func = testutils.returnPrivObj(
                     comm, "__decode_last_alarm_timestamp_map", "Common")
     self.assertEquals(dec_func(last_info), source)
Example #43
0
 def __assert(self, last_info, expect, cached_last_info=""):
     comm = CommonForTest()
     target = testutils.returnPrivObj(comm, "__fixup_event_last_info",
                                      "Common")
     comm.get_cached_event_last_info = lambda: cached_last_info
     self.assertEquals(target(last_info), expect)
 def __assert_extract_validated_event_last_info(self, last_info, expect):
     comm = Common()
     target_func = \
         testutil.returnPrivObj(comm, "__extract_validated_event_last_info")
     self.assertEquals(target_func(last_info), expect)
 def get_priv_attr(self, name):
     return testutils.returnPrivObj(self, name, "Hap2FluentdMain")
Example #46
0
 def __assert(self, query, expect):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(comm, "__parse_alarm_host_each",
                                           "Common")
     self.assertEquals(target_func(query), expect)
Example #47
0
 def test_set_ms_info(self):
     ms_info = ("test_ms_info")
     self.poller.set_ms_info(ms_info)
     command_queue = common.returnPrivObj(self.poller, "__command_queue")
     q = common.returnPrivObj(command_queue, "__q")
     self.assertEquals((1, ms_info), q.get())
 def test_get_command_queue(self):
     command_queue = common.returnPrivObj(self.poller, "__command_queue")
     self.assertEquals(command_queue, self.poller.get_command_queue())
 def test_set_ms_info(self):
     ms_info = ("test_ms_info")
     self.poller.set_ms_info(ms_info)
     command_queue = common.returnPrivObj(self.poller, "__command_queue")
     q = common.returnPrivObj(command_queue, "__q")
     self.assertEquals((1, ms_info), q.get())
Example #50
0
 def __assert_get_history_query_option(self, last_alarm_time, expect):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(
                         comm, "__get_history_query_option", "Common")
     self.assertEquals(target_func(last_alarm_time), expect)
 def __assert_parse_url(self, url, expect):
     comm = Common()
     target_func = testutil.returnPrivObj(comm, "__parse_url")
     self.assertEquals(target_func(url), expect)
 def __assert_validate_object_id(self, host_id, expect=True):
     comm = Common()
     target_func = testutil.returnPrivObj(comm, "__validate_object_id")
     self.assertEquals(target_func(host_id), expect)
 def __assert_parse_status_and_severity(self, status, expect):
     comm = Common()
     target_func = \
         testutil.returnPrivObj(comm, "__parse_status_and_severity")
     self.assertEquals(target_func(status), expect)
Example #54
0
 def test_get_command_queue(self):
     command_queue = common.returnPrivObj(self.poller, "__command_queue")
     self.assertEquals(command_queue, self.poller.get_command_queue())
Example #55
0
 def test_get_sender(self):
     sender = common.returnPrivObj(self.__main_plugin, "__sender")
     self.assertEquals(sender, self.__main_plugin.get_sender())
Example #56
0
 def __assert_get_history_query_option(self, last_alarm_time, expect):
     comm = CommonForTest()
     target_func = testutils.returnPrivObj(comm,
                                           "__get_history_query_option",
                                           "Common")
     self.assertEquals(target_func(last_alarm_time), expect)
Example #57
0
 def test_set_sender(self):
     test_sender = "test_sender"
     self.__main_plugin.set_sender(test_sender)
     sender = common.returnPrivObj(self.__main_plugin, "__sender")
     self.assertEquals(test_sender, sender)
Example #58
0
 def test_get_dispatcher(self):
     dispatcher = common.returnPrivObj(self.__main_plugin, "__dispatcher")
     self.assertEquals(dispatcher, self.__main_plugin.get_dispatcher())
Example #59
0
 def __assert(self, last_info, expect, cached_last_info=""):
     comm = CommonForTest()
     target = testutils.returnPrivObj(comm, "__fixup_event_last_info",
                                      "Common")
     comm.get_cached_event_last_info = lambda: cached_last_info
     self.assertEquals(target(last_info), expect)
Example #60
0
 def __assert_decode_last_alarm_timestamp_map(self, last_info, source):
     comm = CommonForTest()
     dec_func = testutils.returnPrivObj(
         comm, "__decode_last_alarm_timestamp_map", "Common")
     self.assertEquals(dec_func(last_info), source)