0

我正在尝试使用 Python 库 pyral 在 CA Rally 中上传测试用例,测试用例已成功上传,但无法为测试用例设置所有者

import sys
from pyral import Rally, rallyWorkset

options = [arg for arg in sys.argv[1:] if arg.startswith('--')]
args = [arg for arg in sys.argv[1:] if arg not in options]

server, user, password, apikey, workspace, project = 
rallyWorkset(options)


rally = Rally(server='rally1.rallydev.com', 
      apikey="************************",
      workspace='***', project='*****',
      server_ping=False)
response = rally.get('UserStory', fetch = True, projectScopeDown=True, 
query = 'FormattedID = *****', instance=True)
target_project = rally.getProject()
testcase_fields = {
 "Project"     : target_project.ref,
 "WorkProduct" : response.ref,
 "Name"        : "Fifth Test Case",
 "Owner"       : "myDisplayName" or "myUserName",(Nothing Works)
 "Description" : "This is a python integration test",
 "Method"      : "Manual",
 "Type"        : "Acceptance",
 "Pre Conditions"  : "This is Pre-Condition",
 "Validation Input"  : "This is validation input",
 "Validation Expected Result"  : "This is validation expected result",
 "Post Conditions"  : "This is post condition"
}
testcase = rally.put('TestCase', testcase_fields)
print(testcase.details())

如果使用所有者字段,则会出错:

File "<ipython-input-57-c146d75c3723>", line 51, in <module>
    testcase = rally.put('TestCase', testcase_fields)

File "C:\Users\achaube2\AppData\Local\Continuum\anaconda3\lib\site-packages\pyral\restapi.py", line 1024, in put
    raise RallyRESTAPIError(problem)

RallyRESTAPIError: 422 Cannot parse object reference from "myDisplayName"

Test Case is uploaded successfully if i remove the Owner Filed in above code
4

3 回答 3

0

正确的。

“所有者”字段是对用户对象的引用。您将需要使用对所有者用户对象的 ObjectID 的引用来设置所有者字段。

于 2019-06-19T01:57:05.343 回答
0

我认为“用户”显示是对用户对象的引用。

于 2019-06-15T04:57:55.530 回答
0

您需要首先获取您的用户对象,例如:

user_req = rally.getUserInfo(username="name@domain.com")
user = user_req[0]

然后,您可以使用它在 TestCase 中进行引用,例如:

"Owner"       : user.ref
于 2019-06-20T15:24:38.723 回答