Add hacking check to enforce no client aliases

Adds hacking rule to prevent clients being defined using
"self.client" as a service alias. Doing so makes code difficult to
read and harder to maintain.

Change-Id: I060042d6af743079bdb43623e49dbfeba6f46fad
diff --git a/HACKING.rst b/HACKING.rst
index b1d730d..178e538 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -37,6 +37,8 @@
 - [P101] RBAC test filenames must end with "_rbac.py"; for example,
          test_servers_rbac.py, not test_servers.py
 - [P102] RBAC test class names must end in 'RbacTest'
+- [P103] ``self.client`` must not be used as a client alias; this allows for
+         code that is more maintainable and easier to read
 
 Role Switching
 --------------
diff --git a/patrole_tempest_plugin/hacking/checks.py b/patrole_tempest_plugin/hacking/checks.py
index e7e5cb0..a3ef01f 100644
--- a/patrole_tempest_plugin/hacking/checks.py
+++ b/patrole_tempest_plugin/hacking/checks.py
@@ -202,6 +202,16 @@
                 return 0, "RBAC test class names must end in 'RbacTest'"
 
 
+def no_client_alias_in_test_cases(filename, logical_line):
+    """Check that test cases don't use "self.client" to define a client.
+
+    P103
+    """
+    if "patrole_tempest_plugin/tests/api" in filename:
+        if "self.client" in logical_line or "cls.client" in logical_line:
+            return 0, "Do not use 'self.client' as a service client alias"
+
+
 def factory(register):
     register(import_no_clients_in_api_tests)
     register(no_setup_teardown_class_for_tests)