From 5c1d0a6246cbd3f05f6c41e7cfc7046fa3431726 Mon Sep 17 00:00:00 2001 From: Wu Wenxiang Date: Sun, 2 Mar 2014 22:20:49 +0800 Subject: [PATCH] General cleanup of unused objects * Remove unused function fake_get_remote_image_service * Remove unused local function fake_execute2 * stub_out_key_pair_funcs() does nothing, remove it. * Removed usage of enumerate() Closes-Bug: #1286714 Closes-Bug: #1286712 Closes-Bug: #1286742 Closes-Bug: #1286809 Change-Id: I76413c886f6903df2adcf4a4ceb8990486a2ff2f --- .../contrib/test_extended_snapshot_attributes.py | 2 +- cinder/tests/api/fakes.py | 15 --------------- cinder/tests/api/v1/test_snapshot_metadata.py | 1 - cinder/tests/api/v1/test_volume_metadata.py | 1 - cinder/tests/api/v2/test_snapshot_metadata.py | 1 - cinder/tests/api/v2/test_volume_metadata.py | 1 - cinder/tests/brick/test_brick_linuxscsi.py | 9 --------- cinder/tests/image/fake.py | 2 -- 8 files changed, 1 insertion(+), 31 deletions(-) diff --git a/cinder/tests/api/contrib/test_extended_snapshot_attributes.py b/cinder/tests/api/contrib/test_extended_snapshot_attributes.py index e90c29163..7df8ebb20 100644 --- a/cinder/tests/api/contrib/test_extended_snapshot_attributes.py +++ b/cinder/tests/api/contrib/test_extended_snapshot_attributes.py @@ -91,7 +91,7 @@ class ExtendedSnapshotAttributesTest(test.TestCase): res = self._make_request(url) self.assertEqual(res.status_int, 200) - for i, snapshot in enumerate(self._get_snapshots(res.body)): + for snapshot in self._get_snapshots(res.body): self.assertSnapshotAttributes(snapshot, project_id='fake', progress='0%') diff --git a/cinder/tests/api/fakes.py b/cinder/tests/api/fakes.py index 4f3bfd7a0..62c1f5288 100644 --- a/cinder/tests/api/fakes.py +++ b/cinder/tests/api/fakes.py @@ -28,7 +28,6 @@ from cinder.api.v2 import limits from cinder.api.v2 import router from cinder.api import versions from cinder import context -from cinder import exception as exc from cinder.openstack.common import timeutils from cinder import wsgi @@ -83,20 +82,6 @@ def wsgi_app(inner_app_v2=None, fake_auth=True, fake_auth_context=None, return mapper -def stub_out_key_pair_funcs(stubs, have_key_pair=True): - def key_pair(context, user_id): - return [dict(name='key', public_key='public_key')] - - def one_key_pair(context, user_id, name): - if name == 'key': - return dict(name='key', public_key='public_key') - else: - raise exc.KeypairNotFound(user_id=user_id, name=name) - - def no_key_pair(context, user_id): - return [] - - class FakeToken(object): id_count = 0 diff --git a/cinder/tests/api/v1/test_snapshot_metadata.py b/cinder/tests/api/v1/test_snapshot_metadata.py index 427d694eb..b75a88a37 100644 --- a/cinder/tests/api/v1/test_snapshot_metadata.py +++ b/cinder/tests/api/v1/test_snapshot_metadata.py @@ -137,7 +137,6 @@ class SnapshotMetaDataTest(test.TestCase): def setUp(self): super(SnapshotMetaDataTest, self).setUp() self.volume_api = cinder.volume.api.API() - fakes.stub_out_key_pair_funcs(self.stubs) self.stubs.Set(cinder.db, 'volume_get', return_volume) self.stubs.Set(cinder.db, 'snapshot_get', return_snapshot) self.stubs.Set(cinder.db, 'snapshot_metadata_get', diff --git a/cinder/tests/api/v1/test_volume_metadata.py b/cinder/tests/api/v1/test_volume_metadata.py index 56d90b303..0e71cf83a 100644 --- a/cinder/tests/api/v1/test_volume_metadata.py +++ b/cinder/tests/api/v1/test_volume_metadata.py @@ -122,7 +122,6 @@ class volumeMetaDataTest(test.TestCase): def setUp(self): super(volumeMetaDataTest, self).setUp() self.volume_api = cinder.volume.api.API() - fakes.stub_out_key_pair_funcs(self.stubs) self.stubs.Set(cinder.db, 'volume_get', return_volume) self.stubs.Set(cinder.db, 'volume_metadata_get', return_volume_metadata) diff --git a/cinder/tests/api/v2/test_snapshot_metadata.py b/cinder/tests/api/v2/test_snapshot_metadata.py index 8fc1b1f8f..bbfe45394 100644 --- a/cinder/tests/api/v2/test_snapshot_metadata.py +++ b/cinder/tests/api/v2/test_snapshot_metadata.py @@ -137,7 +137,6 @@ class SnapshotMetaDataTest(test.TestCase): def setUp(self): super(SnapshotMetaDataTest, self).setUp() self.volume_api = cinder.volume.api.API() - fakes.stub_out_key_pair_funcs(self.stubs) self.stubs.Set(cinder.db, 'volume_get', return_volume) self.stubs.Set(cinder.db, 'snapshot_get', return_snapshot) self.stubs.Set(cinder.db, 'snapshot_metadata_get', diff --git a/cinder/tests/api/v2/test_volume_metadata.py b/cinder/tests/api/v2/test_volume_metadata.py index 51c1dad38..9b76efa3b 100644 --- a/cinder/tests/api/v2/test_volume_metadata.py +++ b/cinder/tests/api/v2/test_volume_metadata.py @@ -123,7 +123,6 @@ class volumeMetaDataTest(test.TestCase): def setUp(self): super(volumeMetaDataTest, self).setUp() self.volume_api = volume_api.API() - fakes.stub_out_key_pair_funcs(self.stubs) self.stubs.Set(db, 'volume_get', return_volume) self.stubs.Set(db, 'volume_metadata_get', return_volume_metadata) diff --git a/cinder/tests/brick/test_brick_linuxscsi.py b/cinder/tests/brick/test_brick_linuxscsi.py index 9611093ea..5dc46130e 100644 --- a/cinder/tests/brick/test_brick_linuxscsi.py +++ b/cinder/tests/brick/test_brick_linuxscsi.py @@ -106,15 +106,6 @@ class LinuxSCSITestCase(test.TestCase): ) return out, None - def fake_execute2(*cmd, **kwargs): - out = ("350002ac20398383d dm-3 3PARdata,VV\n" - "size=2.0G features='0' hwhandler='0' wp=rw\n" - "`-+- policy='round-robin 0' prio=-1 status=active\n" - " |- 0:0:0:1 sde 8:64 active undef running\n" - " `- 2:0:0:1 sdf 8:80 active undef running\n" - ) - return out, None - self.stubs.Set(self.linuxscsi, '_execute', fake_execute) info = self.linuxscsi.find_multipath_device('/dev/sde') diff --git a/cinder/tests/image/fake.py b/cinder/tests/image/fake.py index 18cea571f..9b5a83fd7 100644 --- a/cinder/tests/image/fake.py +++ b/cinder/tests/image/fake.py @@ -229,8 +229,6 @@ def FakeImageService_reset(): def stub_out_image_service(stubs): - def fake_get_remote_image_service(context, image_href): - return (FakeImageService(), image_href) stubs.Set(cinder.image.glance, 'get_remote_image_service', lambda x, y: (FakeImageService(), y)) stubs.Set(cinder.image.glance, 'get_default_image_service', -- 2.45.2