Rally Software

 View Only
  • 1.  Using pyral to update collections

    Posted Jul 01, 2019 09:47 PM
    Pyral 1.42. Need to update the TestCases collection in a TestSet.

    The addCollectionItems method requires a target with a valid _type attribute. The documentation seems to indicate that this class of object is returned from a .get() call.  I can't line these up to give me a collection that will work with addCollectionItems nor can I see what the entity string would be.

    I also tried just by supplying the list of test cases in a post call - that didn't work either.


  • 2.  RE: Using pyral to update collections

    Broadcom Employee
    Posted Jul 01, 2019 11:53 PM
    Hey Derek,

    Most likely the error you're getting is because your TestSet object isn't properly constructed. I've uploaded an example for you that's working. Notice in that example:
    - Line 26: the TestSet is constructed by iterating over the response objects.
    - The TestCases are added into an array which is passed to the addCollectionItems function.

    To use this example, simply replace lines 9-11 with your ApiKey, Workspace and Project names. Also, replace the filters in lines 14 and 30 to match what you need to get your the test set and test cases you need.

    If you have any questions, please let me know.

    If you'd like to share your code that throws that error, please feel free to include your file. The _type will be part of the TestSet object (or any Rally object) only once it's constructed, otherwise it's unset. Perhaps you are working with raw data (such as the response objects) but didn't properly cast it into the TestSet object. It's just my guess.

    I hope this helps. Let me know.

    Sagi


  • 3.  RE: Using pyral to update collections

    Posted Jul 02, 2019 01:10 AM
    Thanks Sagi

    I'm not seeing the upload yet - I assume it will appear at some point.

    In essence I need to replicate the "Add Existing Test Cases" UI capability so that we can do them in bulk direct from the test plan(s). Creating new test sets by hand and then mapping the test cases to them is very time consuming and error prone at the scale we're doing it.

    Derek


  • 4.  RE: Using pyral to update collections
    Best Answer

    Broadcom Employee
    Posted Jul 02, 2019 03:32 AM
      |   view attached
    My apologies, I think the .py file suffix is blocked by the server. I renamed the file to .txt and uploaded again.
    Let me know if you received.

    Sagi

    Attachment(s)

    txt
    UpdateTestSet.txt   1 KB 1 version


  • 5.  RE: Using pyral to update collections

    Posted Jul 02, 2019 10:26 AM
    Got it.

    This

    myFetch = "ObjectID,Name,FormattedID,TestCases,_type"

    was the key. Specifically requesting _type in the fetch. The blanket 'get everything' fetch doesn't return it (for me anyway) which is weird.

    Thanks


  • 6.  RE: Using pyral to update collections

    Broadcom Employee
    Posted Jul 02, 2019 11:49 AM
    Cool. Good deal. Glad it helped.

    Sagi


  • 7.  RE: Using pyral to update collections

    Posted Nov 18, 2020 07:05 PM
    Edited by Eduardo Duran Nov 18, 2020 11:57 PM
      |   view attached

     I'm trying to use addCollectionItems with pyral 1.4.2 and observed this error as well, even if I have fetch requesting the _type explicitly

      (AttributeError: 'list' object has no attribute '_type')

    In my case, I would like to add a Tag to a Portfolio item. My example attached


    Would really appreciate if someone points me in the right direction
    Ed


    <update> I was able to update the Tags of the portfolioItem using rally.update

    seems my mistake was to confuse Tags as collection items (so the use of addCollectionItems is not appropriate)

    this does work

    updateDict = {
    'FormattedID': Feature_id,
    'Tags': tags,
    }
    rally.update('Feature', updateDict)

    Attachment(s)