I'm trying to delete the attachments from a Test Case definition on Rally using pyral:
del_attachment = rally.deleteAttachment('TestCase',filename)
any suggestions, what is going wrong ?
On
passing a string of the FormattedID of the artifact should work because pyral tries to identify the type of artifact and retrieve it for you in the call below..
art_type, artifact = self._realizeArtifact(artifact)
have look at the code for _realizeArtifact...
def _realizeArtifact(self, artifact):
"""
Helper method to identify the artifact type and to retrieve it if the
artifact value is a FormattedID. If the artifact is already an instance
of a Rally entity, then all that needs to be done is deduce the art_type
from the class name. If the artifact argument given is neither of those
two conditions, return back a 2 tuple of (False, None).
Once you have a Rally instance of the artifact, return back a
2 tuple of (art_type, artifact)
"""
art_type = False
if 'pyral.entity.' in str(type(artifact)):
# we've got the artifact already...
art_type = artifact.__class__.__name__
elif self.FORMATTED_ID_PATTERN.match(artifact):
# artifact is a potential FormattedID value
prefix = artifact[:2]
if prefix[1] in string.digits:
prefix = prefix[0]
art_type = self.ARTIFACT_TYPE[prefix]
response = self.get(art_type, fetch=True, query='FormattedID = %s' % artifact)
if response.resultCount == 1:
artifact = response.next()
else:
art_type = False
else: # the supplied artifact isn't anything we can deal with here...
pass
return art_type, artifact
If you look at the code of
pyral, you get the following signature:So the first argument is an artifact (i.e. the test case object), not a string.
The could should be like this: