diff options
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) |
