RedHatQE / pylero

Python wrapper for the Polarion WSDL API
https://redhatqe.github.io/pylero/
MIT License
37 stars 25 forks source link

Could not update testrun description with pylero-cmd #114

Closed guazhang closed 1 year ago

guazhang commented 2 years ago

$ pylero-cmd update --run="test_123" --description="a test run" Update the existing run: test_123 Set Description to a test run Traceback (most recent call last): File "/home/guazhang/.local/lib/python3.10/site-packages/suds/transport/http.py", line 89, in send fp = self.u2open(u2request, timeout=request.timeout) File "/home/guazhang/.local/lib/python3.10/site-packages/suds/transport/http.py", line 140, in u2open return url.open(u2request, timeout=tm) File "/usr/lib64/python3.10/urllib/request.py", line 525, in open response = meth(req, response) File "/usr/lib64/python3.10/urllib/request.py", line 634, in http_response response = self.parent.error( File "/usr/lib64/python3.10/urllib/request.py", line 563, in error return self._call_chain(args) File "/usr/lib64/python3.10/urllib/request.py", line 496, in _call_chain result = func(args) File "/usr/lib64/python3.10/urllib/request.py", line 643, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 500: 500

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/guazhang/.local/lib/python3.10/site-packages/suds/client.py", line 771, in send reply = self.options.transport.send(request) File "/home/guazhang/.local/lib/python3.10/site-packages/suds/transport/https.py", line 66, in send return HttpTransport.send(self, request) File "/home/guazhang/.local/lib/python3.10/site-packages/suds/transport/http.py", line 106, in send raise TransportError(e.msg, e.code, e.fp) suds.transport.TransportError: 500

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/guazhang/.local/bin/pylero-cmd", line 245, in cli() File "/usr/lib/python3.10/site-packages/click/core.py", line 1137, in call return self.main(args, kwargs) File "/usr/lib/python3.10/site-packages/click/core.py", line 1062, in main rv = self.invoke(ctx) File "/usr/lib/python3.10/site-packages/click/core.py", line 1668, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3.10/site-packages/click/core.py", line 763, in invoke return __callback(args, **kwargs) File "/home/guazhang/.local/bin/pylero-cmd", line 237, in update update_obj.update_runs( File "/home/guazhang/.local/lib/python3.10/site-packages/pylero/cli/cmd.py", line 390, in update_runs self.update_run(run, template, plannedin, assignee, status, description) File "/home/guazhang/.local/lib/python3.10/site-packages/pylero/cli/cmd.py", line 355, in update_run tr.update() File "/home/guazhang/.local/lib/python3.10/site-packages/pylero/test_run.py", line 1160, in update self.session.test_management_client.service.updateTestRun(self._suds_object) File "/home/guazhang/.local/lib/python3.10/site-packages/suds/client.py", line 586, in call return client.invoke(args, kwargs) File "/home/guazhang/.local/lib/python3.10/site-packages/suds/client.py", line 728, in invoke result = self.send(soapenv, timeout=timeout) File "/home/guazhang/.local/lib/python3.10/site-packages/suds/client.py", line 776, in send return self.process_reply(content, e.httpcode, tostr(e)) File "/home/guazhang/.local/lib/python3.10/site-packages/suds/client.py", line 840, in process_reply raise WebFault(fault, replyroot) suds.WebFault: Server raised fault: 'java.lang.IllegalArgumentException: type cannot be null'

waynesun09 commented 1 year ago

This could be reproduce from 0.0.1 -> 0.0.8

Issue is the description is a custom Text field and with using the pylero-cmd it pass a suds object with description custom field description as:

   customFields = 
      (ArrayOfCustom){
         Custom[] = 
            (Custom){
               key = "description"
               value = "Just a test"
            },
  ...

While the expected filed should be:

   customFields = 
      (ArrayOfCustom){
         Custom[] = 
            (Custom){
               key = "description"
               value = 
                  (Text){
                     type = "text/plain"
                     content = "just a test"
                     contentLossy = False
                  }
            },
  ...

The custom field is set with: https://github.com/RedHatQE/pylero/blob/main/src/pylero/test_run.py#L1134

This could be reproduce with directly use the lib:

# cat tmp_bug.py
from pylero.test_run import TestRun

tr = TestRun(project_id=TestRun.default_project, test_run_id="test run name")
tr.description = "Just a test"
tr.update()

The issue is the description is a Text object, so when update the value should only update the Text object content.

With update the script:

# cat tmp_bug.py
from pylero.test_run import TestRun

tr = TestRun(project_id=TestRun.default_project, test_run_id="test run name")
tr.description.content = "Just a test"
tr.update()

and it works.

leelavg commented 1 year ago

fixed by #140