コード例 #1
0
ファイル: test_glance.py プロジェクト: kleopatra999/cinder
    def test_extracting_missing_attributes(self):
        """Verify behavior from glance objects that are missing attributes

        This fakes the image class and is missing the checksum and name
        attribute as the client would return if they're not set in the
        database. Regression test for bug #1308058.
        """

        class MyFakeGlanceImage(glance_stubs.FakeImage):
            def __init__(self, metadata):
                IMAGE_ATTRIBUTES = [
                    "size",
                    "disk_format",
                    "owner",
                    "container_format",
                    "id",
                    "created_at",
                    "updated_at",
                    "deleted",
                    "status",
                    "min_disk",
                    "min_ram",
                    "is_public",
                    "visibility",
                    "protected",
                ]
                raw = dict.fromkeys(IMAGE_ATTRIBUTES)
                raw.update(metadata)
                self.__dict__["raw"] = raw

        metadata = {"id": 1, "created_at": self.NOW_DATETIME, "updated_at": self.NOW_DATETIME}
        image = MyFakeGlanceImage(metadata)
        actual = glance._extract_attributes(image)
        expected = {
            "id": 1,
            "name": None,
            "is_public": None,
            "protected": None,
            "size": None,
            "min_disk": None,
            "min_ram": None,
            "disk_format": None,
            "container_format": None,
            "checksum": None,
            "created_at": self.NOW_DATETIME,
            "updated_at": self.NOW_DATETIME,
            "deleted_at": None,
            "deleted": None,
            "status": None,
            "properties": {},
            "owner": None,
        }
        self.assertEqual(expected, actual)
コード例 #2
0
ファイル: test_glance.py プロジェクト: leisongbai/cinder
    def test_extracting_missing_attributes(self):
        """Verify behavior from glance objects that are missing attributes

        This fakes the image class and is missing the checksum and name
        attribute as the client would return if they're not set in the
        database. Regression test for bug #1308058.
        """
        class MyFakeGlanceImage(glance_stubs.FakeImage):
            def __init__(self, metadata):
                IMAGE_ATTRIBUTES = [
                    'size', 'disk_format', 'owner', 'container_format', 'id',
                    'created_at', 'updated_at', 'deleted', 'status',
                    'min_disk', 'min_ram', 'is_public', 'visibility',
                    'protected'
                ]
                raw = dict.fromkeys(IMAGE_ATTRIBUTES)
                raw.update(metadata)
                self.__dict__['raw'] = raw

        metadata = {
            'id': 1,
            'created_at': self.NOW_DATETIME,
            'updated_at': self.NOW_DATETIME,
        }
        image = MyFakeGlanceImage(metadata)
        actual = glance._extract_attributes(image)
        expected = {
            'id': 1,
            'name': None,
            'protected': None,
            'size': None,
            'min_disk': None,
            'min_ram': None,
            'disk_format': None,
            'container_format': None,
            'checksum': None,
            'created_at': self.NOW_DATETIME,
            'updated_at': self.NOW_DATETIME,
            'deleted_at': None,
            'deleted': None,
            'status': None,
            'properties': {},
            'owner': None,
            'visibility': None,
            'cinder_encryption_key_id': None
        }
        self.assertEqual(expected, actual)
コード例 #3
0
ファイル: test_glance.py プロジェクト: muraliran/cinder
    def test_extracting_missing_attributes(self):
        """Verify behavior from glance objects that are missing attributes

        This fakes the image class and is missing the checksum and name
        attribute as the client would return if they're not set in the
        database. Regression test for bug #1308058.
        """
        class MyFakeGlanceImage(glance_stubs.FakeImage):
            def __init__(self, metadata):
                IMAGE_ATTRIBUTES = ['size', 'disk_format', 'owner',
                                    'container_format', 'id', 'created_at',
                                    'updated_at', 'deleted', 'status',
                                    'min_disk', 'min_ram', 'is_public',
                                    'visibility', 'protected']
                raw = dict.fromkeys(IMAGE_ATTRIBUTES)
                raw.update(metadata)
                self.__dict__['raw'] = raw

        metadata = {
            'id': 1,
            'created_at': self.NOW_DATETIME,
            'updated_at': self.NOW_DATETIME,
        }
        image = MyFakeGlanceImage(metadata)
        actual = glance._extract_attributes(image)
        expected = {
            'id': 1,
            'name': None,
            'is_public': None,
            'protected': None,
            'size': None,
            'min_disk': None,
            'min_ram': None,
            'disk_format': None,
            'container_format': None,
            'checksum': None,
            'created_at': self.NOW_DATETIME,
            'updated_at': self.NOW_DATETIME,
            'deleted_at': None,
            'deleted': None,
            'status': None,
            'properties': {},
            'owner': None,
        }
        self.assertEqual(expected, actual)
コード例 #4
0
            def __init__(self, metadata):
                IMAGE_ATTRIBUTES = ['size', 'disk_format', 'owner',
                                    'container_format', 'id', 'created_at',
                                    'updated_at', 'deleted', 'status',
                                    'min_disk', 'min_ram', 'is_public']
                raw = dict.fromkeys(IMAGE_ATTRIBUTES)
                raw.update(metadata)
                self.__dict__['raw'] = raw

        metadata = {
            'id': 1,
            'created_at': self.NOW_DATETIME,
            'updated_at': self.NOW_DATETIME,
        }
        image = MyFakeGlanceImage(metadata)
        actual = glance._extract_attributes(image)
        expected = {
            'id': 1,
            'name': None,
            'is_public': None,
            'size': None,
            'min_disk': None,
            'min_ram': None,
            'disk_format': None,
            'container_format': None,
            'checksum': None,
            'created_at': self.NOW_DATETIME,
            'updated_at': self.NOW_DATETIME,
            'deleted_at': None,
            'deleted': None,
            'status': None,