В Azure DevOps я пытаюсь рекурсивно получить значение поля проекта/CR Id из каждой пользовательской истории и всех ее дочерних элементов -> тестовые примеры на любом уровне и сопоставить значение поля проекта/CR Id каждого тестового примера для согласованности, если они присутствуют и одинаковы. При использовании SDK я получаю следующую ошибку.
import os
import operator as op
import re
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Replace with your actual PAT and organization URL
personal_access_token = 'PAT'
organization_url = 'https://dev.azure.com/**'
work_item_id = 123 # Replace with your actual work item ID
# Create connection to the organization
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
# Get work item tracking client for interacting with work items API.
work_item_tracking_client = connection.clients.get_work_item_tracking_client()
def check_project_cr_ids_consistency(work_item):
project_cr_ids_consistent = True
project_cr_id_value = None
def recursive_check(item):
nonlocal project_cr_ids_consistent, project_cr_id_value
if 'Custom.ProjectorCRId' in item.fields:
current_project_cr_id_value = item.fields['Custom.ProjectorCRId']
if current_project_cr_id_value.strip() == "":
project_cr_ids_consistent = False
elif project_cr_id_value is None:
project_cr_id_value = current_project_cr_id_value
elif project_cr_id_value != current_project_cr_id_value:
project_cr_ids_consistent = False
else:
project_cr_ids_consistent = False
if hasattr(item, 'relations'):
for relation in item.relations:
if relation.rel == 'System.LinkTypes.Hierarchy-Forward':
child_id = int(relation.url.split('/')[-1])
child_work_items = work_item_tracking_client.get_work_items(ids=[child_id])
for child_work_item in child_work_items:
recursive_check(child_work_item)
recursive_check(work_item)
return (project_cr_ids_consistent, project_cr_id_value)
try:
# Fetch details of the specific work item by ID, including relations (child items).
work_item = work_item_tracking_client.get_work_item(id=work_item_id, expand='all')
# Print details of the fetched work item.
title=work_item.fields['System.Title']
print(f"Title: {title}")
consistent , cr_or_project_value= check_project_cr_ids_consistency(work_item)
except Exception as e :
print(f"An error occurred: {e}")
print(f"Project/CR IDs Consistent: {consistent}")
if not consistent :
print("Inconsistent Project/CR IDs found among children.")
else :
print(f"Consistent Project/CR ID Value: {cr_or_project_value}")
pattern=re.compile(r'\b' + re.escape(cr_or_project_value) + r'\b')
match=pattern.search(title)
print(bool(match))
Ошибка:
An error occurred: 'NoneType' object is not iterable
Exception has occurred: NameError
name 'consistent' is not defined
File "C:\Users\Desktop\CRAutomation\projectid.py", line 67, in
print(f"Project/CR IDs Consistent: {consistent}")
NameError: name 'consistent' is not defined
Подробнее здесь: https://stackoverflow.com/questions/790 ... onsistency
Рекурсивно проверяйте согласованность каждого значения поля проекта/CR Id каждого тестового примера. ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как установить различную макетную реализацию для каждого тестового примера?
Anonymous » » в форуме Javascript - 0 Ответы
- 5 Просмотры
-
Последнее сообщение Anonymous
-