示例#1
0
    def setup_class(cls):
        cls.raw_image_str = open(
            os.path.join(os.path.dirname(__file__), 'data/image.json')).read()
        cls.raw_images_str = open(
            os.path.join(os.path.dirname(__file__),
                         'data/images.json')).read()

        cls.raw_images_schema_str = open(
            os.path.join(os.path.dirname(__file__),
                         'data/images_schema.json')).read()
        cls.raw_image_schema_str = open(
            os.path.join(os.path.dirname(__file__),
                         'data/image_schema.json')).read()

        if IS_MOCK:
            HTTPretty.enable()
            cls.mock_api()

        cls.image_obj = Image._json_to_obj(cls.raw_image_str)
        cls.images_obj = Image._json_to_obj(cls.raw_images_str)

        cls.images_client = ImageClient(
            base_url='http://localhost/v2',
            auth_token='36a04b4e71484ab9aacb1d0ac95733fc',
            serialize_format='json',
            deserialize_format='json')
示例#2
0
    def setup_class(cls):
        cls.raw_image_str = open(
            os.path.join(os.path.dirname(__file__),
                         '../data/image.json')).read()
        cls.raw_images_str = open(
            os.path.join(os.path.dirname(__file__),
                         '../data/images.json')).read()

        cls.image_obj = Image(
            id_='21c697d1-2cc5-4a45-ba50-61fab15ab9b7',
            name='cirros-0.3.1-x86_64-uec-ramdisk',
            visibility=ImageVisibility.PUBLIC,
            status=ImageStatus.ACTIVE,
            protected=False,
            tags=[],
            checksum='69c33642f44ca552ba4bb8b66ad97e85',
            size=3714968,
            created_at=datetime.strptime('2013-05-22T14:24:36Z',
                                         '%Y-%m-%dT%H:%M:%SZ'),
            updated_at=datetime.strptime('2013-05-22T14:24:36Z',
                                         '%Y-%m-%dT%H:%M:%SZ'),
            file_='/v2/images/21c697d1-2cc5-4a45-ba50-61fab15ab9b7/file',
            self_='/v2/images/21c697d1-2cc5-4a45-ba50-61fab15ab9b7',
            schema='/v2/schemas/image',
            container_format=ImageContainerFormat.ARI,
            disk_format=ImageDiskFormat.ARI,
            min_disk=0,
            min_ram=0)
示例#3
0
    def setup_class(cls):
        cls.raw_image_str = open(os.path.join(
            os.path.dirname(__file__), 'data/image.json')).read()
        cls.raw_images_str = open(os.path.join(
            os.path.dirname(__file__), 'data/images.json')).read()

        cls.raw_images_schema_str = open(os.path.join(
            os.path.dirname(__file__), 'data/images_schema.json')).read()
        cls.raw_image_schema_str = open(os.path.join(
            os.path.dirname(__file__), 'data/image_schema.json')).read()

        if IS_MOCK:
            HTTPretty.enable()
            cls.mock_api()

        cls.image_obj = Image._json_to_obj(cls.raw_image_str)
        cls.images_obj = Image._json_to_obj(cls.raw_images_str)

        cls.images_client = ImageClient(
            base_url='http://localhost/v2',
            auth_token='36a04b4e71484ab9aacb1d0ac95733fc',
            serialize_format='json',
            deserialize_format='json'
        )
示例#4
0
    def test_serialization_to_json(self):
        serialized_obj = self.image_obj._obj_to_json()
        # we do this to overcome the property ordering:
        deserialized_obj = Image._json_to_obj(serialized_obj)

        assert self.image_obj == deserialized_obj
示例#5
0
    def test_deserialization_from_json(self):
        deserialized_obj = Image._json_to_obj(self.raw_image_str)

        print self.image_obj
        print deserialized_obj
        assert self.image_obj == deserialized_obj
示例#6
0
    def test_serialization_to_json(self):
        serialized_obj = self.image_obj._obj_to_json()
        # we do this to overcome the property ordering:
        deserialized_obj = Image._json_to_obj(serialized_obj)

        assert self.image_obj == deserialized_obj
示例#7
0
    def test_deserialization_from_json(self):
        deserialized_obj = Image._json_to_obj(self.raw_image_str)

        print self.image_obj
        print deserialized_obj
        assert self.image_obj == deserialized_obj