如何使用Python REST API从VSTS(Azure DevOps)中的查询中提取工作项?
我正在使用Azure DevOps的官方Python REST API: 多亏了这些示例,我才能够从ids中检索到有关测试用例的信息 如何从查询(WIQL)执行此操作 以下是我到目前为止的代码(带有修改过的令牌和链接): 这就是我得到的错误如何使用Python REST API从VSTS(Azure DevOps)中的查询中提取工作项?,python,rest,tfs,azure-devops,azure-devops-rest-api,Python,Rest,Tfs,Azure Devops,Azure Devops Rest Api,我正在使用Azure DevOps的官方Python REST API: 多亏了这些示例,我才能够从ids中检索到有关测试用例的信息 如何从查询(WIQL)执行此操作 以下是我到目前为止的代码(带有修改过的令牌和链接): 这就是我得到的错误 File "test_TFS.py", line 35, in get_TC_from_query work_items = wit_client.get_work_items(query=query, error_policy="omit")
File "test_TFS.py", line 35, in get_TC_from_query
work_items = wit_client.get_work_items(query=query, error_policy="omit")
TypeError: get_work_items() got an unexpected keyword argument 'query'
如何从查询中检索测试用例
特别是,我不理解“客户机”的值,例如“vsts.work\u item\u tracking.v4\u 1.work\u item\u tracking\u client.WorkItemTrackingClient”
谢谢大家! 在Github VSTS示例存储库上发布消息(即问题导致a)后,我得到了解决问题的提示
解决方案是使用:
- 具有
类的wiql查询对象wiql
函数queryby\u wiql
- 将查询结果(带有工作项id的引用)转换为带有
功能的工作项(或get\u work\u item
在一次过程中处理多个工作项)get\u work\u items
以下是我对这个问题的解决方案: [更新版本5.1和azure devops模块以替换VST]
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from azure.devops.v5_1.work_item_tracking.models import Wiql
token = "hcykwckuhe6vbnigsjs7r3ai2jefsdlkfjslkfj5mxizbtfu6k53j4ia"
team_instance = "https://tfstest.toto.com:8443/tfs/Development/"
credentials = BasicAuthentication("", token)
connection = Connection(base_url=team_instance, creds=credentials)
def print_work_items(work_items):
for work_item in work_items:
print(
"{0} {1}: {2}".format(
work_item.fields["System.WorkItemType"],
work_item.id,
work_item.fields["System.Title"],
)
)
wit_client = connection.clients.get_work_item_tracking_client()
def get_TC_from_query(query):
query_wiql = Wiql(query=query)
results = wit_client.query_by_wiql(query_wiql).work_items
# WIQL query gives a WorkItemReference => we get the corresponding WorkItem from id
work_items = (wit_client.get_work_item(int(result.id)) for result in results)
print_work_items(work_items)
在Github存储库上为VSTS示例发布消息(即问题导致a)后,我得到了解决问题的提示
解决方案是使用:
- 具有
类的wiql查询对象wiql
函数queryby\u wiql
- 将查询结果(带有工作项id的引用)转换为带有
功能的工作项(或get\u work\u item
在一次过程中处理多个工作项)get\u work\u items
以下是我对这个问题的解决方案: [更新版本5.1和azure devops模块以替换VST]
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from azure.devops.v5_1.work_item_tracking.models import Wiql
token = "hcykwckuhe6vbnigsjs7r3ai2jefsdlkfjslkfj5mxizbtfu6k53j4ia"
team_instance = "https://tfstest.toto.com:8443/tfs/Development/"
credentials = BasicAuthentication("", token)
connection = Connection(base_url=team_instance, creds=credentials)
def print_work_items(work_items):
for work_item in work_items:
print(
"{0} {1}: {2}".format(
work_item.fields["System.WorkItemType"],
work_item.id,
work_item.fields["System.Title"],
)
)
wit_client = connection.clients.get_work_item_tracking_client()
def get_TC_from_query(query):
query_wiql = Wiql(query=query)
results = wit_client.query_by_wiql(query_wiql).work_items
# WIQL query gives a WorkItemReference => we get the corresponding WorkItem from id
work_items = (wit_client.get_work_item(int(result.id)) for result in results)
print_work_items(work_items)