jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
57 stars 35 forks source link

addAttachmentToTestStep method fail with Exception "java.rmi.RemoteException: Invalid test record index: 'x' ('x' test records exist)" #55

Closed Razofiter closed 2 years ago

Razofiter commented 2 years ago

Hello,

First I want to give my appreciations for making this module! Now, to my issue, when a call the method in the bellow manner:

test_case_record.addAttachmentToTestStep(step_index=step_index, file_path=file_path, title='Dummy attachment')

the execution fails with

java.rmi.RemoteException: Invalid test record index: 0 (0 test records exist)

The _test_caserecord variable (has _index set to 0, so I understand the first part of the exception) is valid and the corresponding work item retrieved with getWorkitem method has test steps, so my guess is that the wrong test run is accessed, as it does not find any test record objects.

Please, let me know if you have a clue. Thanks!

P.S. I set the corresponding test step result before trying to do attachments, as the note from documentation suggests

Attachments to the test steps can only be uploaded if the test step result has been set.

EDIT: If for instance, a test run has more than one record, trying to add attachments to the steps of each record updates the exception in a way that somehow only previous test records are noticed. To be more concrete, if my test run has 3 records, each one having 3 steps, I get the following exceptions when trying to add attachments:

java.rmi.RemoteException: Invalid test record index: 0 (0 test records exist) java.rmi.RemoteException: Invalid test record index: 0 (0 test records exist) java.rmi.RemoteException: Invalid test record index: 0 (0 test records exist) java.rmi.RemoteException: Invalid test record index: 1 (1 test records exist) java.rmi.RemoteException: Invalid test record index: 1 (1 test records exist) java.rmi.RemoteException: Invalid test record index: 1 (1 test records exist) java.rmi.RemoteException: Invalid test record index: 2 (2 test records exist) java.rmi.RemoteException: Invalid test record index: 2 (2 test records exist) java.rmi.RemoteException: Invalid test record index: 2 (2 test records exist)

Razofiter commented 2 years ago

Last EDIT: Solved it! Must also set the record result and only for that specific record you can attach to its steps.