Remove final use of glance_stubs

Removes the final piece of glance_stubs from the image unit tests.

Change-Id: I0db3b6c83edaf91466e85d423ce75b3e75fd3517
Closes-bug: #1293938
This commit is contained in:
Jay Pipes 2014-08-09 15:46:01 -07:00
parent 486623c0ca
commit 8a50755b9d
3 changed files with 15 additions and 57 deletions

View File

@ -1,18 +0,0 @@
# Copyright (c) 2011 Citrix Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
:mod:`glance` -- Stubs for Glance
=================================
"""

View File

@ -1,37 +0,0 @@
# Copyright (c) 2011 Citrix Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class FakeImage(object):
def __init__(self, metadata):
IMAGE_ATTRIBUTES = ['size', 'disk_format', 'owner',
'container_format', 'checksum', 'id',
'name', 'created_at', 'updated_at',
'deleted', 'deleted_at', 'status',
'min_disk', 'min_ram', 'is_public']
raw = dict.fromkeys(IMAGE_ATTRIBUTES)
raw.update(metadata)
self.__dict__['raw'] = raw
def __getattr__(self, key):
try:
return self.__dict__['raw'][key]
except KeyError:
raise AttributeError(key)
def __setattr__(self, key, value):
try:
self.__dict__['raw'][key] = value
except KeyError:
raise AttributeError(key)

View File

@ -26,7 +26,6 @@ from nova import context
from nova import exception
from nova.image import glance
from nova import test
from nova.tests.glance import stubs as glance_stubs
from nova import utils
CONF = cfg.CONF
@ -57,7 +56,9 @@ class TestConversions(test.NoDBTestCase):
def _test_extracting_missing_attributes(self, include_locations):
# Verify behavior from glance objects that are missing attributes
class MyFakeGlanceImage(glance_stubs.FakeImage):
# TODO(jaypipes): Find a better way of testing this crappy
# glanceclient magic object stuff.
class MyFakeGlanceImage(object):
def __init__(self, metadata):
IMAGE_ATTRIBUTES = ['size', 'owner', 'id', 'created_at',
'updated_at', 'status', 'min_disk',
@ -66,6 +67,18 @@ class TestConversions(test.NoDBTestCase):
raw.update(metadata)
self.__dict__['raw'] = raw
def __getattr__(self, key):
try:
return self.__dict__['raw'][key]
except KeyError:
raise AttributeError(key)
def __setattr__(self, key, value):
try:
self.__dict__['raw'][key] = value
except KeyError:
raise AttributeError(key)
metadata = {
'id': 1,
'created_at': NOW_DATETIME,