Remove code duplication in delete methods

This patch removes code duplication in delete methods of service
compute client unit tests.

Change-Id: Ifc2eb17bbe4f2e658f657760510bdc08e3d60251
diff --git a/tempest/tests/services/compute/base.py b/tempest/tests/services/compute/base.py
index 379d513..a35a87c 100644
--- a/tempest/tests/services/compute/base.py
+++ b/tempest/tests/services/compute/base.py
@@ -22,9 +22,11 @@
 
 class BaseComputeServiceTest(base.TestCase):
     def create_response(self, body, to_utf=False, status=200):
-        json_body = json.dumps(body)
-        if to_utf:
-            json_body = json_body.encode('utf-8')
+        json_body = {}
+        if body:
+            json_body = json.dumps(body)
+            if to_utf:
+                json_body = json_body.encode('utf-8')
         response = (httplib2.Response({'status': status}), json_body)
         return response
 
diff --git a/tempest/tests/services/compute/test_agents_client.py b/tempest/tests/services/compute/test_agents_client.py
index a8d4c87..9493a32 100644
--- a/tempest/tests/services/compute/test_agents_client.py
+++ b/tempest/tests/services/compute/test_agents_client.py
@@ -12,10 +12,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import httplib2
-
-from oslotest import mockpatch
-
 from tempest.services.compute.json import agents_client
 from tempest.tests import fake_auth_provider
 from tempest.tests.services.compute import base
@@ -71,11 +67,10 @@
             version="2", architecture="x86_64", os="linux")
 
     def _test_delete_agent(self):
-        mocked_resp = (httplib2.Response({'status': 200}), None)
-        self.useFixture(mockpatch.Patch(
+        self.check_service_client_function(
+            self.client.delete_agent,
             'tempest.common.service_client.ServiceClient.delete',
-            return_value=mocked_resp))
-        self.client.delete_agent("1")
+            {}, agent_id="1")
 
     def _test_update_agent(self, bytes_body=False):
         self.check_service_client_function(
diff --git a/tempest/tests/services/compute/test_aggregates_client.py b/tempest/tests/services/compute/test_aggregates_client.py
index 83514e5..8184a46 100644
--- a/tempest/tests/services/compute/test_aggregates_client.py
+++ b/tempest/tests/services/compute/test_aggregates_client.py
@@ -12,10 +12,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import httplib2
-
-from oslotest import mockpatch
-
 from tempest.services.compute.json import aggregates_client
 from tempest.tests import fake_auth_provider
 from tempest.tests.services.compute import base
@@ -114,12 +110,10 @@
         self._test_create_aggregate(bytes_body=True)
 
     def test_delete_aggregate(self):
-        mocked_resp = (httplib2.Response({'status': 200}), None)
-        self.useFixture(mockpatch.Patch(
+        self.check_service_client_function(
+            self.client.delete_aggregate,
             'tempest.common.service_client.ServiceClient.delete',
-            return_value=mocked_resp))
-        resp = self.client.delete_aggregate("1")
-        self.assertEqual({}, resp)
+            {}, aggregate_id="1")
 
     def _test_update_aggregate(self, bytes_body=False):
         self.check_service_client_function(
diff --git a/tempest/tests/services/compute/test_keypairs_client.py b/tempest/tests/services/compute/test_keypairs_client.py
index ba91757..6ad187b 100644
--- a/tempest/tests/services/compute/test_keypairs_client.py
+++ b/tempest/tests/services/compute/test_keypairs_client.py
@@ -13,9 +13,6 @@
 #    under the License.
 
 import copy
-import httplib2
-
-from oslotest import mockpatch
 
 from tempest.services.compute.json import keypairs_client
 from tempest.tests import fake_auth_provider
@@ -91,10 +88,7 @@
         self._test_create_keypair(bytes_body=True)
 
     def test_delete_keypair(self):
-        expected = {}
-        mocked_resp = (httplib2.Response({'status': 202}), None)
-        self.useFixture(mockpatch.Patch(
+        self.check_service_client_function(
+            self.client.delete_keypair,
             'tempest.common.service_client.ServiceClient.delete',
-            return_value=mocked_resp))
-        resp = self.client.delete_keypair('test')
-        self.assertEqual(expected, resp)
+            {}, status=202, keypair_name='test')
diff --git a/tempest/tests/services/compute/test_quotas_client.py b/tempest/tests/services/compute/test_quotas_client.py
index e2e6546..68f74aa 100644
--- a/tempest/tests/services/compute/test_quotas_client.py
+++ b/tempest/tests/services/compute/test_quotas_client.py
@@ -13,9 +13,6 @@
 #    under the License.
 
 import copy
-import httplib2
-
-from oslotest import mockpatch
 
 from tempest.services.compute.json import quotas_client
 from tempest.tests import fake_auth_provider
@@ -89,10 +86,7 @@
             tenant_id=self.project_id)
 
     def test_delete_quota_set(self):
-        expected = {}
-        mocked_resp = (httplib2.Response({'status': 202}), None)
-        self.useFixture(mockpatch.Patch(
+        self.check_service_client_function(
+            self.client.delete_quota_set,
             'tempest.common.service_client.ServiceClient.delete',
-            return_value=mocked_resp))
-        resp = self.client.delete_quota_set(self.project_id)
-        self.assertEqual(expected, resp)
+            {}, status=202, tenant_id=self.project_id)