in azdev/operations/cmdcov/cmdcov.py [0:0]
def _run_command_test_coverage(self):
"""
all_commands: All commands that need to be test
all_tested_commands: All commands already tested
command_test_coverage: {{module1: pct}, {module2: pct}}
module: vm
pct: xx.xxx%
"""
import ast
for module in self.all_commands.keys():
self.command_test_coverage[module] = []
self.all_untested_commands[module] = []
# pylint: disable=too-many-nested-blocks
for module in self.all_commands.keys():
count = 0
for command in self.all_commands[module]:
exist_flag = False
prefix = command.rsplit('[', maxsplit=1)[0]
opt_list = ast.literal_eval('[' + command.rsplit('[', maxsplit=1)[1]) if self.level == 'argument' \
else []
for cmd in self.all_tested_commands[module]:
if prefix in cmd or \
module == 'rdbms' and prefix.split(maxsplit=1)[1] in cmd:
if self.level == 'argument':
for opt in opt_list:
if opt in cmd:
count += 1
exist_flag = True
if exist_flag:
break
else:
count += 1
exist_flag = True
if exist_flag:
break
if exist_flag:
break
else:
self.all_untested_commands[module].append(command)
try:
self.command_test_coverage[module] = [count, len(self.all_untested_commands[module]),
f'{count / len(self.all_commands[module]):.3%}']
except ZeroDivisionError:
self.command_test_coverage[module] = [0, 0, 'N/A']
self.command_test_coverage['Total'][0] += count
self.command_test_coverage['Total'][1] += len(self.all_untested_commands[module])
self.command_test_coverage['Total'][2] = f'''{self.command_test_coverage["Total"][0] /
(self.command_test_coverage["Total"][0] +
self.command_test_coverage["Total"][1]):.3%}'''
logger.warning(self.command_test_coverage)
return self.command_test_coverage