diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-03-05 11:01:09 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-03-05 11:01:09 +0000 |
| commit | 899d518aec818bc7609f523baa6bc1dfd45d2ece (patch) | |
| tree | 941a795311dc9f694e953b5493f60b1b2615f96b /nova/tests | |
| parent | b581c63d10207541248c0bec21bc70f0b1bc9c1a (diff) | |
| parent | 4a2c57684c18f90f23263156f952561154751e09 (diff) | |
Merge "Fix an error in compute api snapshot_volume_backed bdm code"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/ec2/test_cloud.py | 70 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/test_server_actions.py | 33 |
2 files changed, 23 insertions, 80 deletions
diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index b8a4712c4..2ba8cfc60 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -1907,34 +1907,15 @@ class CloudTestCase(test.TestCase): self.stubs.Set(fake._FakeImageService, 'show', fake_show) def fake_block_device_mapping_get_all_by_instance(context, inst_id): - class BDM(object): - def __init__(self): - self.no_device = None - self.values = dict(id=1, - snapshot_id=snapshots[0], - volume_id=volumes[0], - virtual_name=None, - volume_size=1, - device_name='sda1', - delete_on_termination=False, - connection_info='{"foo":"bar"}') - - def __getattr__(self, name): - """Properly delegate dotted lookups.""" - if name in self.__dict__['values']: - return self.values.get(name) - try: - return self.__dict__[name] - except KeyError: - raise AttributeError - - def __getitem__(self, key): - return self.values.get(key) - - def iteritems(self): - return self.values.iteritems() - - return [BDM()] + return [dict(id=1, + snapshot_id=snapshots[0], + volume_id=volumes[0], + virtual_name=None, + volume_size=1, + device_name='sda1', + delete_on_termination=False, + no_device=None, + connection_info='{"foo":"bar"}')] self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', fake_block_device_mapping_get_all_by_instance) @@ -1998,32 +1979,13 @@ class CloudTestCase(test.TestCase): ec2_instance_id = self._run_instance(**kwargs) def fake_block_device_mapping_get_all_by_instance(context, inst_id): - class BDM(object): - def __init__(self): - self.no_device = None - self.values = dict(snapshot_id=snapshots[0], - volume_id=volumes[0], - virtual_name=None, - volume_size=1, - device_name='vda', - delete_on_termination=False) - - def __getattr__(self, name): - """Properly delegate dotted lookups.""" - if name in self.__dict__['values']: - return self.values.get(name) - try: - return self.__dict__[name] - except KeyError: - raise AttributeError - - def __getitem__(self, key): - return self.values.get(key) - - def iteritems(self): - return self.values.iteritems() - - return [BDM()] + return [dict(snapshot_id=snapshots[0], + volume_id=volumes[0], + virtual_name=None, + volume_size=1, + device_name='vda', + delete_on_termination=False, + no_device=None)] self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', fake_block_device_mapping_get_all_by_instance) diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py index f94b77280..62a688962 100644 --- a/nova/tests/api/openstack/compute/test_server_actions.py +++ b/nova/tests/api/openstack/compute/test_server_actions.py @@ -784,32 +784,13 @@ class ServerActionsControllerTest(test.TestCase): image_service.create(None, original_image) def fake_block_device_mapping_get_all_by_instance(context, inst_id): - class BDM(object): - def __init__(self): - self.no_device = None - self.values = dict(volume_id=_fake_id('a'), - virtual_name=None, - volume_size=1, - device_name='vda', - snapshot_id=1, - delete_on_termination=False) - - def __getattr__(self, name): - """Properly delegate dotted lookups.""" - if name in self.__dict__['values']: - return self.values.get(name) - try: - return self.__dict__[name] - except KeyError: - raise AttributeError - - def __getitem__(self, key): - return self.values.get(key) - - def iteritems(self): - return self.values.iteritems() - - return [BDM()] + return [dict(volume_id=_fake_id('a'), + virtual_name=None, + volume_size=1, + device_name='vda', + snapshot_id=1, + delete_on_termination=False, + no_device=None)] self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', fake_block_device_mapping_get_all_by_instance) |
