使用 python pyral 为拉力赛缺陷添加标签

编程入门 行业动态 更新时间:2024-10-28 20:31:48
本文介绍了使用 python pyral 为拉力赛缺陷添加标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试使用 pyral python 包创建 Rally 缺陷.需要添加一个标签#TestTag2".有没有办法在创建缺陷时添加标签?我正在尝试在创建缺陷后添加标签.但是出现以下错误 -

I am trying to create Rally defect using pyral python package. Need to add a tag "#TestTag2". Is there a way to add Tag at the time defect is created? I am trying to add tag after the defect is created. But getting following error -

info = {"Workspace": "/workspace/123",
        "Project": "/project/123",
        "Name": "Test Defect",
        "Description": "Test Defect details",
        "Owner": "/user/123",
        "ScheduleState": "Defined",
        }

try:
    defect = rally.create('Defect', info )
    print ("Rally Defect Opened - {0} \n").format(defect.FormattedID)
    adds = rally.addCollectionItems(defect, 'Tag',"#TestTag")
    rally.addCollectionItems(defect,)
    print(adds)
except Exception, details:
    sys.stderr.write('ERROR: %s \n' % details)
    sys.exit(1)

出现以下错误 -

Rally Defect Opened - DE1234
ERROR: addCollectionItems() takes exactly 3 arguments (4 given) 

请在此处提供帮助,如何为缺陷添加标签.提前致谢.

Please help here, how to add a tag to a defect. Thanks in advance.

推荐答案

你得到这个错误是因为方法的签名如下:

You got this error because of the signature of the method is the following:

def addCollectionItems(self, target, items)

您需要调整代码以传递标签列表:

You need to adjust your code to pass the list of tags:

tag_req = rally.get('Tag', fetch=True, query='Name = "TAG NAME"')
tag = tag_req.next()
adds = rally.addCollectionItems(defect, [tag])

或者您可以在缺陷创建期间直接使用,无需任何额外的 API 调用:

Or you can use directly during Defect creation without any additional API calls:

from pyral import Rally

SERVER = 'SERVER URL'
USER = 'USER'
PASSWORD = 'PASSWORD'
WORKSPACE = 'WORKSPACE'
TAG = 'TAG NAME'
OWNER_EMAIL = 'bla@bla'

rally = Rally(SERVER, USER, PASSWORD, workspace=WORKSPACE)

target_project = rally.getProject()

user_req = rally.get('User', fetch=True, query='EmailAddress = "%s"' % (OWNER_EMAIL))
user = user_req.next()

tag_req = rally.get('Tag', fetch=True, query='Name = "%s"' % (TAG))
tag = tag_req.next()

defect_info ={"Project": target_project.ref,
        "Name": "Test Defect",
        "Description": "Test Defect details",
        "ScheduleState": "Defined",
        "Owner": user.ref,
        "TAGS": [tag],
        }

try:
    defect = rally.create('Defect', defect_info )
    print ("Rally Defect Opened - {0} \n").format(defect.FormattedID)
except Exception, details:
    sys.stderr.write('ERROR: %s \n' % details)

这篇关于使用 python pyral 为拉力赛缺陷添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 10:33:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408765.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:拉力赛   缺陷   标签   python   pyral

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!