Flesh out FakeImage for extra_properties

The FakeImage in test_images_resource.py is missing a lot of standard
properties. That becomes a problem as soon as you add extra_properties,
which gets delegated to for any missing property by ImageTarget. Thus,
if that fixture has extra_properties defined on it, any other base
property (i.e. checksum, size, etc) will be looked for inside that dict
if it is not defined on the fixture itself.

Thus, this adds fake values for all those properties and adds
extra_properties={} so that subsequent patches can put things into
extra_properties without a bunch of work.

Change-Id: I4b63706927b599eb343b614f0c396f699378e14b
(cherry picked from commit 7c91a177ed)
This commit is contained in:
Dan Smith 2020-07-29 08:13:36 -07:00
parent ec46cbca97
commit 663e027e50
1 changed files with 20 additions and 0 deletions

View File

@ -140,6 +140,26 @@ class FakeImage(object):
self.disk_format = disk_format self.disk_format = disk_format
self.locations = locations self.locations = locations
self.owner = unit_test_utils.TENANT1 self.owner = unit_test_utils.TENANT1
self.created_at = ''
self.updated_at = ''
self.min_disk = ''
self.min_ram = ''
self.protected = False
self.checksum = ''
self.os_hash_algo = ''
self.os_hash_value = ''
self.size = 0
self.virtual_size = 0
self.visibility = 'public'
self.os_hidden = False
self.name = 'foo'
self.tags = []
self.extra_properties = {}
# NOTE(danms): This fixture looks more like the db object than
# the proxy model. This needs fixing all through the tests
# below.
self.image_id = self.id
class TestImagesController(base.IsolatedUnitTest): class TestImagesController(base.IsolatedUnitTest):