Refactor T110 rule
We need to implement more rules for the other methods(DELETE/POST/PUT) for consistent method names. Before doing that, this patch separates common part from T110 rule for sharing it. Partially implements blueprint consistent-service-method-names Change-Id: I24c90d331a45a4f6ad50303c4d17e7cd4d2d784c
This commit is contained in:
parent
c4dc060b8c
commit
5334660423
|
@ -146,27 +146,37 @@ def no_testtools_skip_decorator(logical_line):
|
|||
"decorators.skip_because from tempest-lib")
|
||||
|
||||
|
||||
def _common_service_clients_check(logical_line, physical_line, filename,
|
||||
ignored_list_file=None):
|
||||
if 'tempest/services/' not in filename:
|
||||
return False
|
||||
|
||||
if ignored_list_file is not None:
|
||||
ignored_list = []
|
||||
with open('tempest/hacking/' + ignored_list_file) as f:
|
||||
for line in f:
|
||||
ignored_list.append(line.strip())
|
||||
|
||||
if filename in ignored_list:
|
||||
return False
|
||||
|
||||
if not METHOD.match(physical_line):
|
||||
return False
|
||||
|
||||
if pep8.noqa(physical_line):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_resources_on_service_clients(logical_line, physical_line, filename,
|
||||
line_number, lines):
|
||||
"""Check that service client names of GET should be consistent
|
||||
|
||||
T110
|
||||
"""
|
||||
if 'tempest/services/' not in filename:
|
||||
return
|
||||
|
||||
ignored_list = []
|
||||
with open('tempest/hacking/ignored_list_T110.txt') as f:
|
||||
for line in f:
|
||||
ignored_list.append(line.strip())
|
||||
|
||||
if filename in ignored_list:
|
||||
return
|
||||
|
||||
if not METHOD.match(physical_line):
|
||||
return
|
||||
|
||||
if pep8.noqa(physical_line):
|
||||
if not _common_service_clients_check(logical_line, physical_line,
|
||||
filename, 'ignored_list_T110.txt'):
|
||||
return
|
||||
|
||||
for line in lines[line_number:]:
|
||||
|
|
Loading…
Reference in New Issue