Merge "Several test cleanups"
diff --git a/designate_tempest_plugin/services/dns/json/base.py b/designate_tempest_plugin/services/dns/json/base.py
index 3c2f3c1..4fc1998 100644
--- a/designate_tempest_plugin/services/dns/json/base.py
+++ b/designate_tempest_plugin/services/dns/json/base.py
@@ -53,7 +53,7 @@
     def deserialize(self, object_str):
         return json.loads(object_str)
 
-    def _get_uri(self, resource_name, uuid=None, params=None):
+    def get_uri(self, resource_name, uuid=None, params=None):
         """Get URI for a specific resource or object.
         :param resource_name: The name of the REST resource, e.g., 'zones'.
         :param uuid: The unique identifier of an object in UUID format.
@@ -82,7 +82,7 @@
                  object.
         """
         body = self.serialize(object_dict)
-        uri = self._get_uri(resource, params=params)
+        uri = self.get_uri(resource, params=params)
 
         resp, body = self.post(uri, body=body)
         self.expected_success([201, 202], resp['status'])
@@ -97,7 +97,7 @@
                        include in the request URI.
         :returns: Serialized object as a dictionary.
         """
-        uri = self._get_uri(resource, uuid=uuid, params=params)
+        uri = self.get_uri(resource, uuid=uuid, params=params)
 
         resp, body = self.get(uri)
 
@@ -112,7 +112,7 @@
                        include in the request URI.
         :returns: Serialized object as a dictionary.
         """
-        uri = self._get_uri(resource, params=params)
+        uri = self.get_uri(resource, params=params)
 
         resp, body = self.get(uri)
 
@@ -131,7 +131,7 @@
         :returns: Serialized object as a dictionary.
         """
         body = self.serialize(object_dict)
-        uri = self._get_uri(resource, uuid=uuid, params=params)
+        uri = self.get_uri(resource, uuid=uuid, params=params)
 
         resp, body = self.patch(uri, body=body)
 
@@ -147,7 +147,7 @@
                        include in the request URI.
         :returns: A tuple with the server response and the response body.
         """
-        uri = self._get_uri(resource, uuid=uuid, params=params)
+        uri = self.get_uri(resource, uuid=uuid, params=params)
 
         resp, body = self.delete(uri)
         self.expected_success([202, 204], resp['status'])
diff --git a/designate_tempest_plugin/services/dns/v2/json/zones_client.py b/designate_tempest_plugin/services/dns/v2/json/zones_client.py
index da77979..c8e4687 100644
--- a/designate_tempest_plugin/services/dns/v2/json/zones_client.py
+++ b/designate_tempest_plugin/services/dns/v2/json/zones_client.py
@@ -48,6 +48,9 @@
 
         resp, body = self._create_request('zones', zone, params=params)
 
+        # Create Zone should Return a HTTP 202
+        self.expected_success(202, resp['status'])
+
         if wait_until:
             waiters.wait_for_zone_status(self, body['id'], wait_until)
 
@@ -80,7 +83,12 @@
                        include in the request URI.
         :return: A tuple with the server response and the response body.
         """
-        return self._delete_request('zones', uuid, params=params)
+        resp, body = self._delete_request('zones', uuid, params=params)
+
+        # Delete Zone should Return a HTTP 202
+        self.expected_success(202, resp['status'])
+
+        return resp, body
 
     @base.handle_errors
     def update_zone(self, uuid, email=None, ttl=None,
@@ -106,7 +114,10 @@
 
         resp, body = self._update_request('zones', uuid, zone, params=params)
 
+        # Update Zone should Return a HTTP 202
+        self.expected_success(202, resp['status'])
+
         if wait_until:
             waiters.wait_for_zone_status(self, body['id'], wait_until)
 
-        return resp, body
\ No newline at end of file
+        return resp, body
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones.py b/designate_tempest_plugin/tests/api/v2/test_zones.py
index b71f74b..f97e256 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones.py
@@ -14,7 +14,9 @@
 from oslo_log import log as logging
 from tempest import test
 from tempest.lib import exceptions as lib_exc
+from tempest.lib.common.utils import data_utils
 
+from designate_tempest_plugin import data_utils as dns_data_utils
 from designate_tempest_plugin.tests import base
 
 LOG = logging.getLogger(__name__)
@@ -43,7 +45,14 @@
         self.assertEqual('CREATE', zone['action'])
         self.assertEqual('PENDING', zone['status'])
 
-        LOG.info('Re-Fetch the zone')
+    @test.attr(type='smoke')
+    @test.idempotent_id('02ca5d6a-86ce-4f02-9d94-9e5db55c3055')
+    def test_show_zone(self):
+        LOG.info('Create a zone')
+        _, zone = self.client.create_zone()
+        self.addCleanup(self.client.delete_zone, zone['id'])
+
+        LOG.info('Fetch the zone')
         _, body = self.client.show_zone(zone['id'])
 
         LOG.info('Ensure the fetched response matches the created zone')
@@ -71,10 +80,6 @@
         _, zone = self.client.create_zone()
         self.addCleanup(self.client.delete_zone, zone['id'])
 
-        LOG.info('Ensure we respond with CREATE+PENDING')
-        self.assertEqual('CREATE', zone['action'])
-        self.assertEqual('PENDING', zone['status'])
-
         LOG.info('List zones')
         _, body = self.client.list_zones()
 
@@ -89,16 +94,27 @@
         _, zone = self.client.create_zone()
         self.addCleanup(self.client.delete_zone, zone['id'])
 
-        LOG.info('Ensure we respond with CREATE+PENDING')
-        self.assertEqual('CREATE', zone['action'])
-        self.assertEqual('PENDING', zone['status'])
+        # Generate a random description
+        description = data_utils.rand_name()
 
         LOG.info('Update the zone')
-        resp, body = self.client.update_zone(zone['id'])
+        _, zone = self.client.update_zone(
+            zone['id'], description=description)
 
-        self.assertEqual(202, resp.status)
-        self.assertEqual('UPDATE', body['action'])
-        self.assertEqual('PENDING', body['status'])
+        LOG.info('Ensure we respond with UPDATE+PENDING')
+        self.assertEqual('UPDATE', zone['action'])
+        self.assertEqual('PENDING', zone['status'])
+
+        LOG.info('Ensure we respond with updated values')
+        self.assertEqual(description, zone['description'])
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('925192f2-0ed8-4591-8fe7-a9fa028f90a0')
+    def test_list_zones_dot_json_fails(self):
+        uri = self.client.get_uri('zones.json')
+
+        self.assertRaises(lib_exc.NotFound,
+            lambda: self.client.get(uri))
 
 
 class ZonesAdminTest(BaseZonesTest):
@@ -142,9 +158,9 @@
         _, zone = self.client.create_zone()
         self.addCleanup(self.client.delete_zone, zone['id'])
 
-        LOG.info('Ensure we respond with CREATE+PENDING')
-        self.assertEqual('CREATE', zone['action'])
-        self.assertEqual('PENDING', zone['status'])
+        LOG.info('Create a zone as an default with existing domain')
+        self.assertRaises(lib_exc.Conflict,
+            self.client.create_zone, name=zone['name'])
 
         LOG.info('Create a zone as an alt user with existing domain')
         self.assertRaises(lib_exc.Conflict,
@@ -157,11 +173,7 @@
         _, zone = self.client.create_zone()
         self.addCleanup(self.client.delete_zone, zone['id'])
 
-        LOG.info('Ensure we respond with CREATE+PENDING')
-        self.assertEqual('CREATE', zone['action'])
-        self.assertEqual('PENDING', zone['status'])
-
-        LOG.info('Create a zone as an alt user with  existing subdomain')
+        LOG.info('Create a zone as an alt user with existing subdomain')
         self.assertRaises(lib_exc.Forbidden,
             self.alt_client.create_zone, name='sub.' + zone['name'])
         self.assertRaises(lib_exc.Forbidden,
@@ -170,14 +182,12 @@
     @test.attr(type='smoke')
     @test.idempotent_id('f1723d48-c082-43cd-94bf-ebeb5b8c9458')
     def test_no_create_superdomain_by_alt_user(self):
-        LOG.info('Create a zone as a default user')
-        _, zone = self.client.create_zone(name='a.b.' + "example.com.")
-        self.addCleanup(self.client.delete_zone, zone['id'])
+        zone_name = dns_data_utils.rand_zone_name()
 
-        LOG.info('Ensure we respond with CREATE+PENDING')
-        self.assertEqual('CREATE', zone['action'])
-        self.assertEqual('PENDING', zone['status'])
+        LOG.info('Create a zone as a default user')
+        _, zone = self.client.create_zone(name='a.b.' + zone_name)
+        self.addCleanup(self.client.delete_zone, zone['id'])
 
         LOG.info('Create a zone as an alt user with existing superdomain')
         self.assertRaises(lib_exc.Forbidden,
-            self.alt_client.create_zone, name='example.com.')
+            self.alt_client.create_zone, name=zone_name)