Beispiel #1
0
 def test_load_balancer_json(self):
     actual_json = """
         {{ "{root_tag}":
             {{
                 {actual_json_base}
             }}
         }}
         """.format(root_tag=self.ROOT_TAG,
                    actual_json_base=self.actual_json_base,
                    **self.lb_attribute_kwargs)
     actual_obj = LoadBalancer.deserialize(actual_json, 'json')
     self.assertEqual(self.expected_obj, actual_obj)
Beispiel #2
0
    def setUpClass(cls):
        super(BaseLoadBalancerResponseTest, cls).setUpClass()
        cls.XML_HEADER = Constants.XML_HEADER
        cls.XML_NS = Constants.XML_API_NAMESPACE
        cls.id_ = "8992a43f-83af-4b49-9afd-c2bfbd82d7d7"
        cls.name = "a-new-loadbalancer"
        cls.vip_subnet = "SUBNET_ID"
        cls.tenant_id = "7725fe12-1c14-4f45-ba8e-44bf01763578"
        cls.admin_state_up = True
        cls.description = "A very simple example load balancer."
        cls.vip_address = "1.2.3.4"
        cls.status = "ACTIVE"

        cls.load_balancer_obj = LoadBalancer(
            id_=cls.id_, name=cls.name, vip_subnet=cls.vip_subnet,
            tenant_id=cls.tenant_id, admin_state_up=cls.admin_state_up,
            description=cls.description, vip_address=cls.vip_address,
            status=cls.status)
        load_balancer_list = [cls.load_balancer_obj]
        cls.load_balancers_obj = LoadBalancers(load_balancer_list)

        cls.lb_attribute_kwargs = {
            "id_": cls.id_,
            "name": cls.name,
            "vip_subnet": cls.vip_subnet,
            "tenant_id": cls.tenant_id,
            "admin_state_up": str(cls.admin_state_up).lower(),
            "description": cls.description,
            "vip_address": cls.vip_address,
            "status": cls.status
        }
        cls.actual_json_base = """
                    "id": "{id_}",
                    "name":"{name}",
                    "vip_subnet":"{vip_subnet}",
                    "tenant_id": "{tenant_id}",
                    "admin_state_up": {admin_state_up},
                    "description": "{description}",
                    "vip_address": "{vip_address}",
                    "status": "{status}"
        """.format(**cls.lb_attribute_kwargs)

        cls.actual_xml_base = """
                    id="{id_}"
                    name="{name}"
                    vip_subnet="{vip_subnet}"
                    tenant_id="{tenant_id}"
                    admin_state_up="{admin_state_up}"
                    description="{description}"
                    vip_address="{vip_address}"
                    status="{status}"
        """.format(**cls.lb_attribute_kwargs)
Beispiel #3
0
 def test_load_balancer_xml(self):
     actual_xml = """{xml_header}
                         <{root_tag}
                             {actual_xml_base}
                             xmlns="{xmlns}"
                         />""".format(
         xml_header=self.XML_HEADER,
         xmlns=self.XML_NS,
         root_tag=self.ROOT_TAG,
         actual_xml_base=self.actual_xml_base,
         **self.lb_attribute_kwargs)
     actual_obj = LoadBalancer.deserialize(actual_xml, 'xml')
     self.assertEqual(self.expected_obj, actual_obj)