Пример #1
0
 def test_ensure_connection(self):
     options = {}
     comm = CommonForTest(options)
     comm.ensure_connection()
     nova_ep = testutils.get_priv_attr(comm, "__nova_ep", "Common")
     self.assertEqual(nova_ep, comm.NOVA_EP)
     ceilometer_ep = \
         testutils.get_priv_attr(comm, "__ceilometer_ep", "Common")
     self.assertEqual(ceilometer_ep, comm.CEILOMETER_EP)
Пример #2
0
 def test_ensure_connection(self):
     options = {}
     comm = CommonForTest(options)
     comm.ensure_connection()
     nova_ep = testutils.get_priv_attr(comm, "__nova_ep", "Common")
     self.assertEqual(nova_ep, comm.NOVA_EP)
     ceilometer_ep = \
         testutils.get_priv_attr(comm, "__ceilometer_ep", "Common")
     self.assertEqual(ceilometer_ep, comm.CEILOMETER_EP)
Пример #3
0
 def test_log_status(self):
     poller = haplib.BasePoller(sender=self.sender, process_id="test")
     log_time = testutils.get_priv_attr(poller, "__next_log_status_time")
     poller.log_status(haplib.ArmInfo())
     # check if the next time is update
     new_time = testutils.get_priv_attr(poller, "__next_log_status_time")
     self.assertGreater(new_time, log_time)
     # call again soon. __new_log_status_time should not be updated.
     new_time2 = testutils.get_priv_attr(poller, "__next_log_status_time")
     self.assertEquals(new_time2, new_time)
Пример #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 = testutils.get_priv_attr(self.__dispatcher, "__dispatch_queue")
     dispatch_queue.put(test_message)
     self.__dispatcher.attach_destination(destination_queue, test_id)
     dispatch = testutils.get_priv_attr(self.__dispatcher, "__dispatch")
     testutils.assertNotRaises(dispatch)
Пример #5
0
 def test_log_status(self):
     poller = haplib.BasePoller(sender=self.sender, process_id="test")
     log_time = testutils.get_priv_attr(poller, "__next_log_status_time")
     poller.log_status(haplib.ArmInfo())
     # check if the next time is update
     new_time = testutils.get_priv_attr(poller, "__next_log_status_time")
     self.assertGreater(new_time, log_time)
     # call again soon. __new_log_status_time should not be updated.
     new_time2 = testutils.get_priv_attr(poller, "__next_log_status_time")
     self.assertEquals(new_time2, new_time)
Пример #6
0
 def test_detect_implemented_procedures(self):
     detect_implemented_procedures = testutils.get_priv_attr(self.__main_plugin, "__detect_implemented_procedures")
     detect_implemented_procedures()
     implemented_procedures = testutils.get_priv_attr(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,
     )
Пример #7
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 = testutils.get_priv_attr(self.__dispatcher,
                                              "__dispatch_queue")
     dispatch_queue.put(test_message)
     self.__dispatcher.attach_destination(destination_queue, test_id)
     dispatch = testutils.get_priv_attr(self.__dispatcher, "__dispatch")
     testutils.assertNotRaises(dispatch)
Пример #8
0
 def test_reset(self):
     self.processor.reset()
     prev_hosts = testutils.get_priv_attr(self.processor, "__previous_hosts")
     prev_host_groups = testutils.get_priv_attr(self.processor,
                                                "__previous_host_groups")
     prev_host_group_membership = \
             testutils.get_priv_attr(self.processor,
                                     "__previous_host_group_membership")
     event_last_info = testutils.get_priv_attr(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)
Пример #9
0
 def test__collect_events_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     target_func = testutils.get_priv_attr(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.get_priv_attr(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": "",
         }])
Пример #10
0
 def test__collect_events_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     target_func = testutils.get_priv_attr(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.get_priv_attr(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": "",
     }])
Пример #11
0
 def test_detect_implemented_procedures(self):
     detect_implemented_procedures = \
         testutils.get_priv_attr(self.__main_plugin,
                                 "__detect_implemented_procedures")
     detect_implemented_procedures()
     implemented_procedures = \
         testutils.get_priv_attr(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)
Пример #12
0
 def test_reset(self):
     self.processor.reset()
     prev_hosts = testutils.get_priv_attr(self.processor,
                                          "__previous_hosts")
     prev_host_groups = testutils.get_priv_attr(self.processor,
                                                "__previous_host_groups")
     prev_host_group_membership = \
             testutils.get_priv_attr(self.processor,
                                     "__previous_host_group_membership")
     event_last_info = testutils.get_priv_attr(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)
Пример #13
0
 def test_acknowledge(self):
     destination_queue = DummyQueue()
     test_id = "test"
     self.__dispatcher.attach_destination(destination_queue, test_id)
     acknowledge = testutils.get_priv_attr(self.__dispatcher, "__acknowledge")
     test_message = (test_id, 1)
     testutils.assertNotRaises(acknowledge, test_message)
Пример #14
0
 def test_set_dispatch_queue(self):
     hapiproc = self.__create_test_instance()
     test_dispatch_queue = DummyQueue()
     hapiproc.set_dispatch_queue(test_dispatch_queue)
     self.assertEquals(
         testutils.get_priv_attr(hapiproc, "__dispatch_queue"),
         test_dispatch_queue)
Пример #15
0
 def test__publish_with_exception(self):
     conn = RabbitMQConnector()
     testutils.set_priv_attr(conn, "__publish_raw", None)
     target_func = testutils.get_priv_attr(conn, "__publish")
     with self.assertRaises(hap.Signal) as cm:
         target_func("msg")
     self.assertTrue(cm.exception.critical)
Пример #16
0
 def test__publish_with_exception(self):
     conn = RabbitMQConnector()
     testutils.set_priv_attr(conn, "__publish_raw", None)
     target_func = testutils.get_priv_attr(conn, "__publish")
     with self.assertRaises(hap.Signal) as cm:
         target_func("msg")
     self.assertTrue(cm.exception.critical)
Пример #17
0
 def test_set_dispatch_queue(self):
     hapiproc = self.__create_test_instance()
     test_dispatch_queue = DummyQueue()
     hapiproc.set_dispatch_queue(test_dispatch_queue)
     self.assertEquals(
         testutils.get_priv_attr(hapiproc, "__dispatch_queue"),
         test_dispatch_queue)
Пример #18
0
 def test_encode_decode_last_alarm_timestamp_map(self):
     comm = CommonForTest()
     enc_func = testutils.get_priv_attr(
                     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)
Пример #19
0
 def test_encode_decode_last_alarm_timestamp_map(self):
     comm = CommonForTest()
     enc_func = testutils.get_priv_attr(
         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)
Пример #20
0
 def __assert_get_resource(self, num_items, expect):
     comm = CommonForTest({"href1_num_items": num_items})
     get_resource = \
         testutils.get_priv_attr(comm, "__get_resource", "Common")
     rel = None
     href = "http://HREF/href1"
     self.assertEquals(get_resource(rel, href), expect)
Пример #21
0
 def __assert_get_resource(self, num_items, expect):
     comm = CommonForTest({"href1_num_items": num_items})
     get_resource = \
         testutils.get_priv_attr(comm, "__get_resource", "Common")
     rel = None
     href = "http://HREF/href1"
     self.assertEquals(get_resource(rel, href), expect)
Пример #22
0
 def test_acknowledge(self):
     destination_queue = DummyQueue()
     test_id = "test"
     self.__dispatcher.attach_destination(destination_queue, test_id)
     acknowledge = testutils.get_priv_attr(self.__dispatcher,
                                           "__acknowledge")
     test_message = (test_id, 1)
     testutils.assertNotRaises(acknowledge, test_message)
Пример #23
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.get_priv_attr(
                         comm, "__parse_alarm_host", "Common")
     self.assertEquals(target_func(threshold_rule), expect)
Пример #24
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 = testutils.get_priv_attr(self.__dispatcher, "__acknowledge")
        test_message = (test_id, test_contents.message_id)
        acknowledge(test_message)

        test_message = (test_id, test_contents)
        dispatch_queue = testutils.get_priv_attr(self.__dispatcher, "__dispatch_queue")
        dispatch_queue.put(test_message)

        testutils.assertNotRaises(acknowledge, test_message)
        dispatch = testutils.get_priv_attr(self.__dispatcher, "__dispatch")
        testutils.assertNotRaises(dispatch)
Пример #25
0
 def test_remove_missing_alarm_before_get_all_alarms(self):
     comm = CommonForTest()
     target_func = testutils.get_priv_attr(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)
Пример #26
0
 def test_poll_in_block(self):
     poll_in_try_block = testutils.get_priv_attr(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()
     testutils.assertNotRaises(poll_in_try_block, arm_info)
     self.poller._BasePoller__command_queue._CommandQueue__q = org_q
Пример #27
0
 def test__collect_items_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     host_id = "host_id2"
     target_func = \
         testutils.get_priv_attr(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])
Пример #28
0
 def test__collect_items_and_put(self):
     comm = CommonForTest()
     comm.ensure_connection()
     host_id = "host_id2"
     target_func = \
         testutils.get_priv_attr(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])
Пример #29
0
 def test_wait_response(self):
     hapiproc = self.__create_test_instance()
     test_result = "test_result"
     test_id = 1
     pm = haplib.ParsedMessage()
     pm.message_dict = {"id": test_id, "result": test_result}
     pm.message_id = test_id
     hapiproc.get_reply_queue().put(pm)
     wait_response = testutils.get_priv_attr(hapiproc, "__wait_response")
     self.assertEquals(wait_response(test_id), test_result)
Пример #30
0
 def test_wait_response(self):
     hapiproc = self.__create_test_instance()
     test_result = "test_result"
     test_id = 1
     pm = haplib.ParsedMessage()
     pm.message_dict = {"id": test_id, "result": test_result}
     pm.message_id = test_id
     hapiproc.get_reply_queue().put(pm)
     wait_response = testutils.get_priv_attr(hapiproc, "__wait_response")
     self.assertEquals(wait_response(test_id), test_result)
Пример #31
0
 def test_remove_missing_alarm_before_get_all_alarms(self):
     comm = CommonForTest()
     target_func = testutils.get_priv_attr(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)
Пример #32
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.get_priv_attr(comm, "__parse_alarm_host",
                                           "Common")
     self.assertEquals(target_func(threshold_rule), expect)
Пример #33
0
 def test_remove_missing_alarm(self):
     comm = CommonForTest()
     comm.ensure_connection()
     comm.collect_triggers_and_put()
     target_func = testutils.get_priv_attr(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"})
Пример #34
0
 def test_poll_in_block(self):
     poll_in_try_block = testutils.get_priv_attr(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()
     testutils.assertNotRaises(poll_in_try_block, arm_info)
     self.poller._BasePoller__command_queue._CommandQueue__q = org_q
Пример #35
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 = testutils.get_priv_attr(self.__dispatcher,
                                              "__acknowledge")
        test_message = (test_id, test_contents.message_id)
        acknowledge(test_message)

        test_message = (test_id, test_contents)
        dispatch_queue = testutils.get_priv_attr(self.__dispatcher,
                                                 "__dispatch_queue")
        dispatch_queue.put(test_message)

        testutils.assertNotRaises(acknowledge, test_message)
        dispatch = testutils.get_priv_attr(self.__dispatcher, "__dispatch")
        testutils.assertNotRaises(dispatch)
Пример #36
0
    def test_reset(self):
        targets = ("__previous_hosts", "__previous_host_groups",
                   "__previous_host_group_membership", "__event_last_info")

        # Set arbitary data to each member
        hapiproc = self.__create_test_instance()
        for attr_name in targets:
            testutils.set_priv_attr(hapiproc, attr_name, "Test Data")

        hapiproc.reset()
        for attr_name in targets:
            self.assertIsNone(testutils.get_priv_attr(hapiproc, attr_name))
Пример #37
0
 def test_remove_missing_alarm(self):
     comm = CommonForTest()
     comm.ensure_connection()
     comm.collect_triggers_and_put()
     target_func = testutils.get_priv_attr(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"})
Пример #38
0
    def test_reset(self):
        targets = ("__previous_hosts", "__previous_host_groups",
                   "__previous_host_group_membership", "__event_last_info")

        # Set arbitary data to each member
        hapiproc = self.__create_test_instance()
        for attr_name in targets:
            testutils.set_priv_attr(hapiproc, attr_name, "Test Data")

        hapiproc.reset()
        for attr_name in targets:
            self.assertIsNone(testutils.get_priv_attr(hapiproc, attr_name))
Пример #39
0
 def test_private_set_ms_info(self):
     set_ms_info = testutils.get_priv_attr(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 hap.Signal:
         pass
Пример #40
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 = testutils.get_priv_attr(self.processor,
                                                "__wait_response")
        output = wait_response(exact_id)

        self.assertEquals(output, exact_result)
Пример #41
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 = testutils.get_priv_attr(self.processor,
                                                "__wait_response")
        output = wait_response(exact_id)

        self.assertEquals(output, exact_result)
Пример #42
0
 def test_last_info_generator(self):
     comm = CommonForTest()
     target_func = testutils.get_priv_attr(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)
Пример #43
0
 def test_last_info_generator(self):
     comm = CommonForTest()
     target_func = testutils.get_priv_attr(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)
Пример #44
0
    def test__setup_ssl(self):
        conn = RabbitMQConnector()
        target_func = testutils.get_priv_attr(conn, "__setup_ssl")
        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")
Пример #45
0
 def test_private_set_ms_info(self):
     set_ms_info = testutils.get_priv_attr(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 hap.Signal:
         pass
Пример #46
0
    def test__setup_ssl(self):
        conn = RabbitMQConnector()
        target_func = testutils.get_priv_attr(conn, "__setup_ssl")
        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")
Пример #47
0
 def test_get_command_queue(self):
     command_queue = testutils.get_priv_attr(self.poller, "__command_queue")
     self.assertEquals(command_queue, self.poller.get_command_queue())
Пример #48
0
 def test_get_dispatcher(self):
     dispatcher = testutils.get_priv_attr(self.__main_plugin,
                                          "__dispatcher")
     self.assertEquals(dispatcher, self.__main_plugin.get_dispatcher())
Пример #49
0
 def test_set_sender(self):
     test_sender = "test_sender"
     self.__main_plugin.set_sender(test_sender)
     sender = testutils.get_priv_attr(self.__main_plugin, "__sender")
     self.assertEquals(test_sender, sender)
Пример #50
0
 def test_get_sender(self):
     sender = testutils.get_priv_attr(self.__main_plugin, "__sender")
     self.assertEquals(sender, self.__main_plugin.get_sender())
Пример #51
0
 def __assert_parse_url(self, url, expect):
     comm = Common()
     target_func = testutils.get_priv_attr(comm, "__parse_url")
     self.assertEquals(target_func(url), expect)
Пример #52
0
 def is_expented_id_notification(self):
     is_expected_id_notification = \
         testutils.get_priv_attr(self.__dispatcher,
                                 "__is_expenced_id_notification")
     test_contents = 1
     self.assertTrue(is_expected_id_notification(test_contents))
Пример #53
0
 def __assert_validate_object_id(self, host_id, expect=True):
     comm = Common()
     target_func = testutils.get_priv_attr(comm, "__validate_object_id")
     self.assertEquals(target_func(host_id), expect)
Пример #54
0
 def __assert(self, last_info, expect, cached_last_info=""):
     comm = CommonForTest()
     target = testutils.get_priv_attr(comm, "__fixup_event_last_info",
                                      "Common")
     comm.get_cached_event_last_info = lambda: cached_last_info
     self.assertEquals(target(last_info), expect)
Пример #55
0
 def __assert_get_history_query_option(self, last_alarm_time, expect):
     comm = CommonForTest()
     target_func = testutils.get_priv_attr(
                         comm, "__get_history_query_option", "Common")
     self.assertEquals(target_func(last_alarm_time), expect)
Пример #56
0
 def __assert(self, query, expect):
     comm = CommonForTest()
     target_func = testutils.get_priv_attr(
                         comm, "__parse_alarm_host_each", "Common")
     self.assertEquals(target_func(query), expect)
Пример #57
0
 def test_set_ms_info(self):
     ms_info = ("test_ms_info")
     self.poller.set_ms_info(ms_info)
     command_queue = testutils.get_priv_attr(self.poller, "__command_queue")
     q = testutils.get_priv_attr(command_queue, "__q")
     self.assertEquals((1, ms_info), q.get())
Пример #58
0
 def test_get_dispatch_queue(self):
     dispatch_queue = testutils.get_priv_attr(self.__dispatcher,
                                              "__dispatch_queue")
     self.assertEquals(self.__dispatcher.get_dispatch_queue(),
                       dispatch_queue)
Пример #59
0
 def get_priv_attr(self, name):
     return testutils.get_priv_attr(self, name, "Hap2FluentdMain")
Пример #60
0
 def __assert_parse_status_and_severity(self, status, expect):
     comm = Common()
     target_func = \
         testutils.get_priv_attr(comm, "__parse_status_and_severity")
     self.assertEquals(target_func(status), expect)