0

I am trying to upload test cases in CA Rally using Python library pyral, test cases are uploaded successfully but not able to set Owner for test case

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())

Getting Error if using Owner Field:

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
F Blanchet
  • 1,430
  • 3
  • 21
  • 32

3 Answers3

0

I think 'user' show be a ref to a user-object.

JPKole
  • 341
  • 1
  • 6
  • can you please explain little bit more, i have already tried to use rally.getUserInfo() and rally.getAllUsers(workspace="***") but not able to achieve anything from these – Abhishek Chaubey Jun 17 '19 at 07:09
0

Correct.

The "Owner" field is a reference to the User object. You will need to set the Owner field with a reference to the ObjectID of the owner user object.

0

You need to get your user object first like:

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

Then, you can use it for referencing in TestCase like:

"Owner"       : user.ref
user2738882
  • 1,161
  • 1
  • 20
  • 38