2

我用过 pyral api

rally = Rally(server, apikey=api_key, workspace=workspace, project=project)

连接到集会比,

  testfolders = rally.get('TestFolder', fetch=True, query=query_criteria) 

我需要将集会中定义的所有测试用例提取为:

TF*****
  -TC1
  -TC2
  -TC3

我需要从 testfolders 返回的 formattedID 中获取所有测试用例。

for tc in testfolders:
   print(tc.Name)
   print(tc.FormattedID)# this represents the TF***
   tc_link=tc._ref#url for TC's https://rally1.rallydev.com/slm/webservice 
query_criteria = 'TestSets = "%s"' % tp_name
testfolders = rally.get('TestFolder', fetch=True, query=query_criteria)

我尝试寻找不同的组合集来提取测试用例 tc._ref 实际上是一个

https://rally1.rallydev.com/slm/webservice/v2.0/TestFolder/XXXXX/TestCases

当我试图在浏览器中打开它时,它给出了整个测试用例列表。我需要提取那些测试用例列表。我尝试使用 urllib 访问以使用 python 访问数据,但是说未经授权的访问,我认为如果我在同一个会话上授权不应该是一个问题,因为集会对象已经实例化。对此的任何帮助将不胜感激!提前致谢

    rally = Rally(server, apikey=api_key, workspace=workspace, project=project)
    tp_name = "specific test case "
    query_criteria = 'FormattedID = "%s"' % tp_name
    testfolders = rally.get('TestFolder', fetch=True, query=query_criteria)
    for tc in testfolders:
         print(tc.Name)
         print(tc.FormattedID)   
         query_criteria = 'TestSets = "%s"' % tc._ref
         response = rally.get('TestCase', fetch=True, query=query_criteria)
         print(response)

422 Could not read: could not read all instances of class com.f4tech.slm.domain.TestCase for class TestCase
4

1 回答 1

0

目前尚不清楚您要实现什么,但请查看下面的代码。可能,它将解决您的问题:

query = 'FormattedID = %s'

test_folder_req = rally.get('TestFolder', fetch=True, projectScopeDown=True,
                                       query=query % folder_id) # folder_id == "TF111"
if test_folder_req.resultCount == 0:
    print('Rally returned nothing for folder: %s', folder_id)
    sys.exit(1)

test_folder = test_folder_req.next()

test_cases = test_folder.TestCases
print('Start working with %s' % folder_id)
print('Test Folder %s contains %s TestCases' % (folder_id, len(test_cases)))

for test_case in test_cases:
    print(test_case.FormattedID)
    print(test_case.Name)
于 2019-07-17T10:02:17.600 回答