pyal deleteAttachment从测试用例定义中删除附件无效

问题描述 投票:0回答:1

我正在尝试使用pyral从Rally的测试用例定义中删除附件:

del_attachment = rally.deleteAttachment('TestCase',filename)

任何建议,怎么了?

python devops rally pyral
1个回答
0
投票

[如果您查看codepyral,您将获得以下签名:

  def deleteAttachment(self, artifact, filename):
        """
            Still unclear for WSAPI v2.0 if Attachment items can be deleted.
            Apparently AttachmentContent items can be deleted.
        """
        art_type, artifact = self._realizeArtifact(artifact)
        if not art_type:
            return False

        current_attachments = [att for att in artifact.Attachments]
        hits = [att for att in current_attachments if att.Name == filename]
        if not hits:
            return False

        ...

所以第一个参数是工件(即测试用例对象),而不是字符串。

可能应该是这样:

import logging

logging.basicConfig(format="%(levelname)s:%(module)s:%(lineno)d:%(msg)s")


try:
    # Get number of existing steps
    testcase = rally.get("TestCase", query="FormattedID = %s" % tcid, instance=True)
    has_been_deleted = rally.deleteAttachment(testcase, filename)
    if not has_been_deleted:
        msg = "Attachment '{0}' of Test Case {1} not deleted successfully"
        logging.warning(msg.format(filename, testcase.FormattedID))

except RallyRESTAPIError as e:
    logging.error("Error while deleting attachment '{0}': {1}".format(filename, e))
© www.soinside.com 2019 - 2024. All rights reserved.