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/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)