in azdev/operations/cmdcov/cmdcov.py [0:0]
def _get_all_tested_commands_from_record(self):
"""
get all tested commands from recording files
"""
print("\033[31m" + "Get tested commands from recording files".center(self.width, self.fillchar) + "\033[0m")
time.sleep(0.1)
for idx, path in enumerate(tqdm(self.selected_mod_paths)):
if 'azure-cli-extensions' in path:
for dirname in os.listdir(path):
if dirname.startswith('azext'):
test_dir = os.path.join(path, dirname, 'tests')
break
else:
test_dir = os.path.join(path, 'tests')
files = find_files(test_dir, 'test*.yaml')
for f in files:
with open(os.path.join(test_dir, f)) as f:
# safe_load can not determine a constructor for the tag: !!python/unicode
records = yaml.load(f, Loader=yaml.Loader) or {}
for record in records['interactions']:
# ['acr agentpool create']
command = record['request']['headers'].get('CommandName', [''])[0]
# ['-n -r']
argument = record['request']['headers'].get('ParameterSetName', [''])[0]
if command or argument:
cmd = command + ' ' + argument
self.all_tested_commands[self.selected_mod_names[idx]].append(cmd)