Adding description for testcases - identity part1

When Tempest is used in customer site, often we are required to
provide a testcase list including testcase names and descriptions.
Now no this kind of doc is available, so we can add descriptions
with the format of doc string for every testcase, so later we
can generata such a testcase description list.

There are hundreds of testcases missing descriptions, so we can
add them gradually, and limit the modified files in one patch
for the convenience of reviewing.

BTW: some minor code refactor is done along with this patch.

Change-Id: I072bd2c86a7f50559e9e452dda3e1669fad3be00
partially-implements: blueprint testcase-description
diff --git a/tempest/api/identity/admin/v2/test_endpoints.py b/tempest/api/identity/admin/v2/test_endpoints.py
index 947706e..236ce7c 100644
--- a/tempest/api/identity/admin/v2/test_endpoints.py
+++ b/tempest/api/identity/admin/v2/test_endpoints.py
@@ -19,6 +19,7 @@
 
 
 class EndPointsTestJSON(base.BaseIdentityV2AdminTest):
+    """Test keystone v2 endpoints"""
 
     @classmethod
     def resource_setup(cls):
@@ -51,6 +52,7 @@
 
     @decorators.idempotent_id('11f590eb-59d8-4067-8b2b-980c7f387f51')
     def test_list_endpoints(self):
+        """Test listing keystone endpoints"""
         # Get a list of endpoints
         fetched_endpoints = self.endpoints_client.list_endpoints()['endpoints']
         # Asserting LIST endpoints
@@ -62,6 +64,7 @@
 
     @decorators.idempotent_id('9974530a-aa28-4362-8403-f06db02b26c1')
     def test_create_list_delete_endpoint(self):
+        """Test creating, listing and deleting a keystone endpoint"""
         region = data_utils.rand_name('region')
         url = data_utils.rand_url()
         endpoint = self.endpoints_client.create_endpoint(
diff --git a/tempest/api/identity/admin/v3/test_default_project_id.py b/tempest/api/identity/admin/v3/test_default_project_id.py
index 73fddb7..7c3a6cc 100644
--- a/tempest/api/identity/admin/v3/test_default_project_id.py
+++ b/tempest/api/identity/admin/v3/test_default_project_id.py
@@ -22,6 +22,7 @@
 
 
 class TestDefaultProjectId(base.BaseIdentityV3AdminTest):
+    """Test creating a token without project will default to user's project"""
 
     @classmethod
     def setup_credentials(cls):
@@ -35,11 +36,11 @@
         self.domains_client.delete_domain(domain_id)
 
     @testtools.skipIf(CONF.identity_feature_enabled.immutable_user_source,
-                      'Skipped because environment has an '
-                      'immutable user source and solely '
-                      'provides read-only access to users.')
+                      'Skipped because environment has an immutable user '
+                      'source and solely provides read-only access to users.')
     @decorators.idempotent_id('d6110661-6a71-49a7-a453-b5e26640ff6d')
     def test_default_project_id(self):
+        """Creating a token without project will default to user's project"""
         # create a domain
         dom_name = data_utils.rand_name('dom')
         domain_body = self.domains_client.create_domain(
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index 5aec931..7bd0bcf 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -22,6 +22,7 @@
 
 
 class UsersV3TestJSON(base.BaseIdentityV3AdminTest):
+    """Test listing keystone users"""
 
     def _list_users_with_params(self, params, key, expected, not_expected):
         # Helper method to list users filtered with params and
@@ -69,7 +70,7 @@
 
     @decorators.idempotent_id('08f9aabb-dcfe-41d0-8172-82b5fa0bd73d')
     def test_list_user_domains(self):
-        # List users with domain
+        """List users with domain"""
         params = {'domain_id': self.domain['id']}
         self._list_users_with_params(params, 'domain_id',
                                      self.domain_enabled_user,
@@ -77,7 +78,7 @@
 
     @decorators.idempotent_id('bff8bf2f-9408-4ef5-b63a-753c8c2124eb')
     def test_list_users_with_not_enabled(self):
-        # List the users with not enabled
+        """List the users with not enabled"""
         params = {'enabled': False}
         self._list_users_with_params(params, 'enabled',
                                      self.non_domain_enabled_user,
@@ -85,7 +86,7 @@
 
     @decorators.idempotent_id('c285bb37-7325-4c02-bff3-3da5d946d683')
     def test_list_users_with_name(self):
-        # List users with name
+        """List users with name"""
         params = {'name': self.domain_enabled_user['name']}
         # When domain specific drivers are enabled the operations
         # of listing all users and listing all groups are not supported,
@@ -98,7 +99,7 @@
 
     @decorators.idempotent_id('b30d4651-a2ea-4666-8551-0c0e49692635')
     def test_list_users(self):
-        # List users
+        """List users"""
         # When domain specific drivers are enabled the operations
         # of listing all users and listing all groups are not supported,
         # they need a domain filter to be specified
@@ -120,7 +121,7 @@
 
     @decorators.idempotent_id('b4baa3ae-ac00-4b4e-9e27-80deaad7771f')
     def test_get_user(self):
-        # Get a user detail
+        """Get a user detail"""
         user = self.users_client.show_user(self.users[0]['id'])['user']
         self.assertEqual(self.users[0]['id'], user['id'])
         self.assertEqual(self.users[0]['name'], user['name'])
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 2908fc4..fb81d0a 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -19,13 +19,14 @@
 
 
 class PoliciesTestJSON(base.BaseIdentityV3AdminTest):
+    """Test keystone policies"""
 
     def _delete_policy(self, policy_id):
         self.policies_client.delete_policy(policy_id)
 
     @decorators.idempotent_id('1a0ad286-2d06-4123-ab0d-728893a76201')
     def test_list_policies(self):
-        # Test to list policies
+        """Test to list keystone policies"""
         policy_ids = list()
         fetched_ids = list()
         for _ in range(3):
@@ -46,7 +47,7 @@
     @decorators.attr(type='smoke')
     @decorators.idempotent_id('e544703a-2f03-4cf2-9b0f-350782fdb0d3')
     def test_create_update_delete_policy(self):
-        # Test to update policy
+        """Test to update keystone policy"""
         blob = data_utils.rand_name('BlobName')
         policy_type = data_utils.rand_name('PolicyType')
         policy = self.policies_client.create_policy(blob=blob,
diff --git a/tempest/api/identity/admin/v3/test_project_tags.py b/tempest/api/identity/admin/v3/test_project_tags.py
index b7878a8..eed60af 100644
--- a/tempest/api/identity/admin/v3/test_project_tags.py
+++ b/tempest/api/identity/admin/v3/test_project_tags.py
@@ -25,6 +25,8 @@
 
 
 class IdentityV3ProjectTagsTest(base.BaseIdentityV3AdminTest):
+    """Test keystone project tags"""
+
     # NOTE: force_tenant_isolation is true in the base class by default but
     # overridden to false here to allow test execution for clouds using the
     # pre-provisioned credentials provider.
@@ -34,6 +36,7 @@
     @testtools.skipUnless(CONF.identity_feature_enabled.project_tags,
                           'Project tags not available.')
     def test_list_update_delete_project_tags(self):
+        """Test listing, updating and deleting of project tags"""
         project = self.setup_test_project()
 
         # Create a tag for testing.
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index 5afeb98..a649d27 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -20,6 +20,7 @@
 
 
 class ServicesTestJSON(base.BaseIdentityV3AdminTest):
+    """Test keystone services"""
 
     def _del_service(self, service_id):
         # Used for deleting the services created in this class
@@ -31,6 +32,7 @@
     @decorators.attr(type='smoke')
     @decorators.idempotent_id('5193aad5-bcb7-411d-85b0-b3b61b96ef06')
     def test_create_update_get_service(self):
+        """Test creating, updating and getting of keystone service"""
         # Creating a Service
         name = data_utils.rand_name('service')
         serv_type = data_utils.rand_name('type')
@@ -63,7 +65,7 @@
 
     @decorators.idempotent_id('d1dcb1a1-2b6b-4da8-bbb8-5532ef6e8269')
     def test_create_service_without_description(self):
-        # Create a service only with name and type
+        """Create a keystone service only with name and type"""
         name = data_utils.rand_name('service')
         serv_type = data_utils.rand_name('type')
         service = self.services_client.create_service(
@@ -74,7 +76,7 @@
 
     @decorators.idempotent_id('e55908e8-360e-439e-8719-c3230a3e179e')
     def test_list_services(self):
-        # Create, List, Verify and Delete Services
+        """Create, List, Verify and Delete Keystone Services"""
         service_ids = list()
         service_types = list()
         for _ in range(3):
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index 8955a93..31cbbac 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -27,6 +27,7 @@
 
 
 class UsersV3TestJSON(base.BaseIdentityV3AdminTest):
+    """Test keystone users"""
 
     @classmethod
     def skip_checks(cls):
@@ -38,7 +39,7 @@
 
     @decorators.idempotent_id('b537d090-afb9-4519-b95d-270b0708e87e')
     def test_user_update(self):
-        # Test case to check if updating of user attributes is successful.
+        """Test case to check if updating of user attributes is successful"""
         # Creating first user
         u_name = data_utils.rand_name('user')
         u_desc = u_name + 'description'
@@ -72,6 +73,7 @@
 
     @decorators.idempotent_id('2d223a0e-e457-4a70-9fb1-febe027a0ff9')
     def test_update_user_password(self):
+        """Test updating user password"""
         # Creating User to check password updation
         u_name = data_utils.rand_name('user')
         original_password = data_utils.rand_password()
@@ -98,7 +100,7 @@
 
     @decorators.idempotent_id('a831e70c-e35b-430b-92ed-81ebbc5437b8')
     def test_list_user_projects(self):
-        # List the projects that a user has access upon
+        """Test listing the projects that a user has access upon"""
         assigned_project_ids = list()
         fetched_project_ids = list()
         u_project = self.setup_test_project()
@@ -141,7 +143,7 @@
 
     @decorators.idempotent_id('c10dcd90-461d-4b16-8e23-4eb836c00644')
     def test_get_user(self):
-        # Get a user detail
+        """Test getting a user detail"""
         user = self.setup_test_user()
         fetched_user = self.users_client.show_user(user['id'])['user']
         self.assertEqual(user['id'], fetched_user['id'])
@@ -150,6 +152,7 @@
                           'Security compliance not available.')
     @decorators.idempotent_id('568cd46c-ee6c-4ab4-a33a-d3791931979e')
     def test_password_history_not_enforced_in_admin_reset(self):
+        """Test setting same password when password history is not enforced"""
         old_password = self.os_primary.credentials.password
         user_id = self.os_primary.credentials.user_id
 
diff --git a/tempest/api/identity/v3/test_catalog.py b/tempest/api/identity/v3/test_catalog.py
index bc95f0d..ce6adf9 100644
--- a/tempest/api/identity/v3/test_catalog.py
+++ b/tempest/api/identity/v3/test_catalog.py
@@ -19,9 +19,11 @@
 
 
 class IdentityCatalogTest(base.BaseIdentityV3Test):
+    """Test service's catalog type values"""
 
     @decorators.idempotent_id('56b57ced-22b8-4127-9b8a-565dfb0207e2')
     def test_catalog_standardization(self):
+        """Test that every service has a standard catalog type value"""
         # https://opendev.org/openstack/service-types-authority
         # /src/branch/master/service-types.yaml
         standard_service_values = [{'name': 'keystone', 'type': 'identity'},
@@ -31,11 +33,9 @@
         # next, we need to GET the catalog using the catalog client
         catalog = self.non_admin_catalog_client.show_catalog()['catalog']
         # get list of the service types present in the catalog
-        catalog_services = []
-        for service in catalog:
-            catalog_services.append(service['type'])
+        catalog_services = [service['type'] for service in catalog]
         for service in standard_service_values:
-            # if service enabled, check if it has a standard typevalue
+            # if service enabled, check if it has a standard type value
             if service['name'] == 'keystone' or\
                     getattr(CONF.service_available, service['name']):
                 self.assertIn(service['type'], catalog_services)