I am trying to create a TestCase and then add an attachment to the TestCase. Currently i can successfully create a TestCase, but when I go to add the attachment I get 0 errors but no attachments are added. Here is my code:
import sys, os
import datetime
from pyral import Rally, rallyWorkset, RallyRESTAPIError
def main():
rally = Rally("rally1.rallydev.com",
apikey="_myKey", workspace="myWorkspace",
project="myProject", verify_ssl_cert=False)
rally.enableLogging("rally.history.showstories")
query_criteria = 'FormattedID = "US622745"'
response = rally.get('UserStory', query=query_criteria, instance=True)
target_project = rally.getProject()
timen = datetime.datetime.now()
testcase_fields = {
"Project" : target_project.ref,
"WorkProduct" : response.ref,
"Name" : "Automated Test Generation -- " + str(timen),
"Method" : "Automated",
"Type" : "Acceptance"
}
testcase = rally.put('TestCase', testcase_fields)
print(testcase.details())
try:
attachment = rally.addAttachment(testcase.ref, "t2.txt")
except Exception as e:
print(str(e))
if __name__ == '__main__':
main()
sys.exit(0)
Everything works as expected up to the try block. The TestCase is successfully created for the given user story, but adding the attachment doesnt work, 0 errors though. Do I have to do something else following rally.addAttachment()
? The documentation is really rough for me to read and understand.
attachment is a boolean with value False, even though the documentation specifies it should return an attachment item.
I figured it out. rally.addAttachment(testcase.ref, "t2.txt")
returns a boolean if it cannot find the artifact. Using rally.addAttachment(testcase.FormattedID, "t2.txt")
works though.