3030def assert_no_oslo (logical_line ):
3131 """Check for use of oslo libraries.
3232
33- O400
33+ Okay: import os
34+ Okay: from os import path
35+ O400: import oslo_messaging
36+ O400: from oslo_log import log
3437 """
3538 if match := re .match (r'(from|import) (oslo_.*)' , logical_line ):
3639 if match .group (2 ) == 'oslo_i18n' :
@@ -42,7 +45,13 @@ def assert_no_oslo(logical_line):
4245def assert_no_duplicated_setup (logical_line , filename ):
4346 """Check for use of various unnecessary test duplications.
4447
45- O401
48+ This check only applies to files under openstackclient/tests/unit/.
49+
50+ Okay: self.app = fakes.FakeShell()
51+ Okay: self.app.client_manager.auth_ref = mock.Mock()
52+ O401: self.app = Namespace(self.app, self.namespace)
53+ O401: self.network_client = self.app.client_manager.network
54+ O401: self.app.client_manager.network = mock.Mock()
4655 """
4756 if os .path .join ('openstackclient' , 'tests' , 'unit' ) not in filename :
4857 return
@@ -80,7 +89,14 @@ def assert_no_duplicated_setup(logical_line, filename):
8089def assert_use_of_client_aliases (logical_line , filename ):
8190 """Ensure we use $service_client instead of $sdk_connection.service.
8291
83- O402
92+ Okay: self.compute_client.find_server(foo)
93+ O402: self.app.client_manager.sdk_connnection.compute.find_server(foo)
94+
95+ The following checks only apply to files under openstackclient/tests/unit/:
96+
97+ O402: self.app.client_manager.compute.find_server.return_value = server
98+ O402: self.app.client_manager.compute.find_server = mock.Mock()
99+ O402: self.compute_client.find_server = mock.Mock()
84100 """
85101 # we should expand the list of services as we drop legacy clients
86102 if match := re .match (
@@ -205,7 +221,9 @@ def assert_find_ignore_missing_kwargs(logical_line, filename):
205221def assert_use_of_osc_command (logical_line , filename ):
206222 """Ensure we use openstackclient.command instead of osc_lib.command.
207223
208- O404
224+ Okay: from openstackclient.command import command
225+ Okay: import openstackclient.command
226+ O404: from osc_lib.command import command
209227 """
210228 if filename == 'openstackclient/command.py' :
211229 return
0 commit comments