TestCase, определенный в TestFolder на Rally, не обновляется pyral - PullRequest
0 голосов
/ 25 января 2020

Я не могу обновить testCase, определенный на Rally, используя pyral

Ниже приведен фрагмент кода, который я использую:

# 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" , но контрольный пример не обновляется.

Что не так?

1 Ответ

0 голосов
/ 25 января 2020

Вы смешиваете 2 функции:

  • rally.put: создать новый WorkItem
  • rally.update: изменить существующий WorkItem

Когда вы изменяете элемент, вам нужна ссылка, FormattedID или идентификатор объекта рабочего элемента.

Ваш код должен выглядеть примерно так:

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

ПРИМЕЧАНИЕ : вам не нужно указывать в запросе двойные кавычки ".

...