Integration tests cleanup
This patch does a cleanup and fixes some nits found by reviewers
in the original patches [1], some of them are:
- import json instead of jsonutils
- use six.moves.http_client
- put common logic on clients superclass
- use "fails" to indicate negative cases
- stronger comparison in update tests
[1] https://review.openstack.org/#/q/topic:federation_integration_tests
Change-Id: I216fc5d4758e7b09d167d9d26271ddd149c66816
diff --git a/keystone_tempest_plugin/services/identity/clients.py b/keystone_tempest_plugin/services/identity/clients.py
index d8c8692..caf8b52 100644
--- a/keystone_tempest_plugin/services/identity/clients.py
+++ b/keystone_tempest_plugin/services/identity/clients.py
@@ -12,6 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+import json
+
+from six.moves import http_client
from tempest import config
from tempest.lib.common import rest_client
@@ -48,16 +51,27 @@
def _delete(self, entity_id, **kwargs):
url = self._build_path(entity_id)
- return super(Federation, self).delete(url, **kwargs)
+ resp, body = super(Federation, self).delete(url, **kwargs)
+ self.expected_success(http_client.NO_CONTENT, resp.status)
+ return rest_client.ResponseBody(resp, body)
def _get(self, entity_id=None, **kwargs):
url = self._build_path(entity_id)
- return super(Federation, self).get(url, **kwargs)
+ resp, body = super(Federation, self).get(url, **kwargs)
+ self.expected_success(http_client.OK, resp.status)
+ body = json.loads(body)
+ return rest_client.ResponseBody(resp, body)
def _patch(self, entity_id, body, **kwargs):
url = self._build_path(entity_id)
- return super(Federation, self).patch(url, body, **kwargs)
+ resp, body = super(Federation, self).patch(url, body, **kwargs)
+ self.expected_success(http_client.OK, resp.status)
+ body = json.loads(body)
+ return rest_client.ResponseBody(resp, body)
def _put(self, entity_id, body, **kwargs):
url = self._build_path(entity_id)
- return super(Federation, self).put(url, body, **kwargs)
+ resp, body = super(Federation, self).put(url, body, **kwargs)
+ self.expected_success(http_client.CREATED, resp.status)
+ body = json.loads(body)
+ return rest_client.ResponseBody(resp, body)