Exemplo n.º 1
0
 def test_healthmonitors_json(self):
     actual_json = """
                     {{ "{root_tag}":
                         [{{
                             {actual_json_base}
                         }}]
                     }}
                     """.format(root_tag=self.ROOT_TAG,
                                actual_json_base=self.actual_json_base,
                                **self.healthmonitor_attribute_kwargs)
     actual_obj = HealthMonitors.deserialize(actual_json, 'json')
     self.assertEqual(self.expected_obj, actual_obj)
Exemplo n.º 2
0
 def test_healthmonitors_json(self):
     actual_json = """
                     {{ "{root_tag}":
                         [{{
                             {actual_json_base}
                         }}]
                     }}
                     """.format(root_tag=self.ROOT_TAG,
                                actual_json_base=self.actual_json_base,
                                **self.healthmonitor_attribute_kwargs)
     actual_obj = HealthMonitors.deserialize(actual_json, 'json')
     self.assertEqual(self.expected_obj, actual_obj)
Exemplo n.º 3
0
 def test_healthmonitors_xml(self):
     actual_xml = """{xml_header}
                         <{root_tag} xmlns="{xmlns}">
                             <{child_tag}
                                 {actual_xml_base}
                             />
                         </{root_tag}>""".format(
         xml_header=self.XML_HEADER,
         xmlns=self.XML_NS,
         root_tag=self.ROOT_TAG,
         child_tag=self.CHILD_TAG,
         actual_xml_base=self.actual_xml_base,
         **self.healthmonitor_attribute_kwargs)
     actual_obj = HealthMonitors.deserialize(actual_xml, 'xml')
     self.assertEqual(self.expected_obj, actual_obj)
Exemplo n.º 4
0
 def test_healthmonitors_xml(self):
     actual_xml = """{xml_header}
                         <{root_tag} xmlns="{xmlns}">
                             <{child_tag}
                                 {actual_xml_base}
                             />
                         </{root_tag}>""".format(
         xml_header=self.XML_HEADER,
         xmlns=self.XML_NS,
         root_tag=self.ROOT_TAG,
         child_tag=self.CHILD_TAG,
         actual_xml_base=self.actual_xml_base,
         **self.healthmonitor_attribute_kwargs)
     actual_obj = HealthMonitors.deserialize(actual_xml, 'xml')
     self.assertEqual(self.expected_obj, actual_obj)
Exemplo n.º 5
0
    def setUpClass(cls):
        super(BaseHealthMonitorResponseTest, cls).setUpClass()
        cls.XML_HEADER = Constants.XML_HEADER
        cls.XML_NS = Constants.XML_API_NAMESPACE
        cls.id_ = "8992a43f-83af-4b49-9afd-c2bfbd82d7d7"
        cls.type_ = "HTTP"
        cls.tenant_id = "7725fe12-1c14-4f45-ba8e-44bf01763578"
        cls.delay = 20
        cls.timeout = 10
        cls.max_retries = 5
        cls.url_path = "/check"
        cls.expected_codes = "200-299"
        cls.admin_state_up = True
        cls.status = "ACTIVE"

        cls.healthmonitor_obj = HealthMonitor(
            id_=cls.id_,
            type_=cls.type_,
            tenant_id=cls.tenant_id,
            delay=cls.delay,
            timeout=cls.timeout,
            max_retries=cls.max_retries,
            url_path=cls.url_path,
            expected_codes=cls.expected_codes,
            admin_state_up=cls.admin_state_up,
            status=cls.status)
        healthmonitor_list = [cls.healthmonitor_obj]
        cls.healthmonitors_obj = HealthMonitors(healthmonitor_list)

        cls.healthmonitor_attribute_kwargs = {
            "id_": cls.id_,
            "type_": cls.type_,
            "tenant_id": cls.tenant_id,
            "delay": cls.delay,
            "timeout": cls.timeout,
            "max_retries": cls.max_retries,
            "url_path": cls.url_path,
            "expected_codes": cls.expected_codes,
            "admin_state_up": str(cls.admin_state_up).lower(),
            "status": cls.status
        }
        cls.actual_json_base = """
                    "id": "{id_}",
                    "type": "{type_}",
                    "tenant_id":"{tenant_id}",
                    "delay": {delay},
                    "timeout": {timeout},
                    "max_retries": {max_retries},
                    "url_path": "{url_path}",
                    "expected_codes": "{expected_codes}",
                    "admin_state_up": {admin_state_up},
                    "status": "{status}"
        """.format(**cls.healthmonitor_attribute_kwargs)

        cls.actual_xml_base = """
                    id="{id_}"
                    type="{type_}"
                    tenant_id="{tenant_id}"
                    delay="{delay}"
                    timeout="{timeout}"
                    max_retries="{max_retries}"
                    url_path="{url_path}"
                    expected_codes="{expected_codes}"
                    admin_state_up="{admin_state_up}"
                    status="{status}"
        """.format(**cls.healthmonitor_attribute_kwargs)