Example #1
0
    def test_fixed_ip_missing_attribute_json(self):
        modified_dict = self.fixed_ip_dict.copy()
        modified_dict.popitem()

        actual_json = json.dumps(modified_dict)
        actual_obj = FixedIp.deserialize(actual_json, 'json')
        self.assertIsNone(actual_obj)
Example #2
0
    def test_fixed_ip_extra_attribute_json(self):
        modified_dict = self.fixed_ip_dict.copy()
        modified_dict['test_dummy'] = 'test_dummy'

        actual_json = json.dumps(modified_dict)
        actual_obj = FixedIp.deserialize(actual_json, 'json')
        self.assertIsNone(actual_obj)
Example #3
0
    def test_fixed_ip_extra_attribute_json(self):
        modified_dict = self.fixed_ip_dict.copy()
        modified_dict['test_dummy'] = 'test_dummy'

        actual_json = json.dumps(modified_dict)
        actual_obj = FixedIp.deserialize(actual_json, 'json')
        self.assertIsNone(actual_obj)
Example #4
0
    def test_fixed_ip_missing_attribute_json(self):
        modified_dict = self.fixed_ip_dict.copy()
        modified_dict.popitem()

        actual_json = json.dumps(modified_dict)
        actual_obj = FixedIp.deserialize(actual_json, 'json')
        self.assertIsNone(actual_obj)
Example #5
0
    def setUpClass(cls):
        super(BaseCommonTest, cls).setUpClass()

        cls.bandwidth_interface_dict = {
            "bw_in": 123456,
            "bw_out": 654321
        }

        cls.bandwidth_dict = {
            "private": cls.bandwidth_interface_dict,
            "public": cls.bandwidth_interface_dict,
            "extra": cls.bandwidth_interface_dict
        }

        cls.fixed_ip_dict = {
            "address": "10.10.0.0",
            "floating_ips": [],
            "label": "public",
            "meta": {},
            "type": "fixed",
            "version": 4,
            "vif_mac": "FE:ED:FA:00:1C:D4"
        }

        cls.fixed_ips_dict = {
            "fixed_ips": [cls.fixed_ip_dict]
        }

        cls.image_meta_dict = {
            "auto_disk_config": "disabled",
            "base_image_ref": "5e91ad7f-afe4-4a83-bd5f-84673462cae1",
            "container_format": "ovf",
            "disk_format": "vhd",
            "image_type": "base",
            "min_disk": "20",
            "min_ram": "512",
            "org.openstack__1__architecture": "x64",
            "org.openstack__1__os_distro": "com.ubuntu",
            "org.openstack__1__os_version": "12.04",
            "os_type": "linux"
        }

        cls.instance_exception_dict = {
            "kwargs": {
                "instance_uuid": "5e91ad7f-afe4-4a83-bd5f-84673462cae1",
                "reason": "Something broke",
                "code": 500
            }
        }

        cls.bandwidth_obj = Bandwidth._dict_to_obj(cls.bandwidth_dict)
        cls.bandwidth_interface_obj = BandwidthInterface._dict_to_obj(
            cls.bandwidth_interface_dict)
        cls.fixed_ip_obj = FixedIp._dict_to_obj(cls.fixed_ip_dict)
        cls.fixed_ips_obj = FixedIps._list_to_obj(
            cls.fixed_ips_dict['fixed_ips'])
        cls.image_meta_obj = ImageMeta._dict_to_obj(cls.image_meta_dict)
        cls.instance_exception_obj = InstanceException._dict_to_obj(
            cls.instance_exception_dict)
Example #6
0
    def test_fixed_ip_json(self):
        expected_obj = self.fixed_ip_obj

        actual_json = json.dumps(self.fixed_ip_dict)
        actual_obj = FixedIp.deserialize(actual_json, 'json')

        self.assertEqual(expected_obj, actual_obj)
        self.assertFalse(actual_obj.is_empty())
Example #7
0
    def test_fixed_ip_json(self):
        expected_obj = self.fixed_ip_obj

        actual_json = json.dumps(self.fixed_ip_dict)
        actual_obj = FixedIp.deserialize(actual_json, 'json')

        self.assertEqual(expected_obj, actual_obj)
        self.assertFalse(actual_obj.is_empty())
Example #8
0
    def setUpClass(cls):
        super(BaseCommonTest, cls).setUpClass()

        cls.bandwidth_interface_dict = {"bw_in": 123456, "bw_out": 654321}

        cls.bandwidth_dict = {
            "private": cls.bandwidth_interface_dict,
            "public": cls.bandwidth_interface_dict,
            "extra": cls.bandwidth_interface_dict
        }

        cls.fixed_ip_dict = {
            "address": "10.10.0.0",
            "floating_ips": [],
            "label": "public",
            "meta": {},
            "type": "fixed",
            "version": 4,
            "vif_mac": "FE:ED:FA:00:1C:D4"
        }

        cls.fixed_ips_dict = {"fixed_ips": [cls.fixed_ip_dict]}

        cls.image_meta_dict = {
            "auto_disk_config": "disabled",
            "base_image_ref": "5e91ad7f-afe4-4a83-bd5f-84673462cae1",
            "container_format": "ovf",
            "disk_format": "vhd",
            "image_type": "base",
            "min_disk": "20",
            "min_ram": "512",
            "org.openstack__1__architecture": "x64",
            "org.openstack__1__os_distro": "com.ubuntu",
            "org.openstack__1__os_version": "12.04",
            "os_type": "linux"
        }

        cls.instance_exception_dict = {
            "kwargs": {
                "instance_uuid": "5e91ad7f-afe4-4a83-bd5f-84673462cae1",
                "reason": "Something broke",
                "code": 500
            }
        }

        cls.bandwidth_obj = Bandwidth._dict_to_obj(cls.bandwidth_dict)
        cls.bandwidth_interface_obj = BandwidthInterface._dict_to_obj(
            cls.bandwidth_interface_dict)
        cls.fixed_ip_obj = FixedIp._dict_to_obj(cls.fixed_ip_dict)
        cls.fixed_ips_obj = FixedIps._list_to_obj(
            cls.fixed_ips_dict['fixed_ips'])
        cls.image_meta_obj = ImageMeta._dict_to_obj(cls.image_meta_dict)
        cls.instance_exception_obj = InstanceException._dict_to_obj(
            cls.instance_exception_dict)