Rally 上 TestFolder 下定义的 TestCase 没有被 pyral 更新
TestCase defined under TestFolder on Rally not getting updated by pyral
我无法使用 pyral
更新 Rally 上定义的测试用例
下面是我使用的代码片段:
# Get the testcase that needs to be updated
query_criteria = 'FormattedID = "%s"' % tc
rally_response = rally_obj.get('TestCase', fetch=True, query=query_criteria)
target_project = rally.getProject()
testcase_fields = {
"Project" : target_project.ref,
"Workspace" : "workspace/59461540411",
"Name" : "test",
"Method" : "Automated",
"Type" : "Acceptance",
"Notes" : "netsim testing",
"Description" : "description changing",
#"TestCase" : "testcase/360978196712"
}
testcase_response = rally.put('TestCase', testcase_fields)
testcase_response
的状态码是"200",但是测试用例没有更新。
怎么了?
您正在混合使用 2 个函数:
rally.put
: 创建一个新的 WorkItem
rally.update
:修改现有工作项
当您修改项目时,您需要参考,FormattedID
,或工作项目的对象 ID。
您的代码应该如下所示:
# Get the testcase that needs to be updated
import logging
logging.basicConfig(format="%(levelname)s:%(module)s:%(lineno)d:%(msg)s")
def get_test_case(tcid):
"""Retrieve Test Case from its ID, or None if no such TestCase id"""
query_criteria = "FormattedID = %s" % tcid
try:
response = rally_obj.get('TestCase', fetch=True, query=query_criteria)
return response.next()
except StopIteration:
logging.error("Test Case '%s' not found" % tcid)
return None
target_project = rally.getProject()
test_case = get_test_case("TC1234")
if test_case:
testcase_fields = {
"FormattedID" : test_case.FormattedID
"Project" : target_project.ref,
"Workspace" : "workspace/59461540411", # might not be necessary if you don't change it
"Name" : "test",
"Method" : "Automated",
"Type" : "Acceptance",
"Notes" : "netsim testing",
"Description" : "description changed",
}
testcase_response = rally.update('TestCase', testcase_fields)
print(testcase_response)
注意:您不必在查询中使用双引号 "
。
我无法使用 pyral
更新 Rally 上定义的测试用例下面是我使用的代码片段:
# Get the testcase that needs to be updated
query_criteria = 'FormattedID = "%s"' % tc
rally_response = rally_obj.get('TestCase', fetch=True, query=query_criteria)
target_project = rally.getProject()
testcase_fields = {
"Project" : target_project.ref,
"Workspace" : "workspace/59461540411",
"Name" : "test",
"Method" : "Automated",
"Type" : "Acceptance",
"Notes" : "netsim testing",
"Description" : "description changing",
#"TestCase" : "testcase/360978196712"
}
testcase_response = rally.put('TestCase', testcase_fields)
testcase_response
的状态码是"200",但是测试用例没有更新。
怎么了?
您正在混合使用 2 个函数:
rally.put
: 创建一个新的 WorkItemrally.update
:修改现有工作项
当您修改项目时,您需要参考,FormattedID
,或工作项目的对象 ID。
您的代码应该如下所示:
# Get the testcase that needs to be updated
import logging
logging.basicConfig(format="%(levelname)s:%(module)s:%(lineno)d:%(msg)s")
def get_test_case(tcid):
"""Retrieve Test Case from its ID, or None if no such TestCase id"""
query_criteria = "FormattedID = %s" % tcid
try:
response = rally_obj.get('TestCase', fetch=True, query=query_criteria)
return response.next()
except StopIteration:
logging.error("Test Case '%s' not found" % tcid)
return None
target_project = rally.getProject()
test_case = get_test_case("TC1234")
if test_case:
testcase_fields = {
"FormattedID" : test_case.FormattedID
"Project" : target_project.ref,
"Workspace" : "workspace/59461540411", # might not be necessary if you don't change it
"Name" : "test",
"Method" : "Automated",
"Type" : "Acceptance",
"Notes" : "netsim testing",
"Description" : "description changed",
}
testcase_response = rally.update('TestCase', testcase_fields)
print(testcase_response)
注意:您不必在查询中使用双引号 "
。