Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step with index 0 cannot be deleted #123

Closed
ndk58 opened this issue Jul 26, 2023 · 1 comment
Closed

Step with index 0 cannot be deleted #123

ndk58 opened this issue Jul 26, 2023 · 1 comment

Comments

@ndk58
Copy link

ndk58 commented Jul 26, 2023

I implemented a script that imports all the tests from XML files. Each XML is one test case.
When I re-import an existing test (due to a test update, for example), instead of checking and updating all steps, I made it simple: I delete all the steps and re-import them from scratch.

Now, the issue is that I cannot delete all the steps. If I have 4 steps, for example, I can delete step 4,3,2; then, when I try to delete the last one (with index 0), I get the following error.

Traceback (most recent call last): File "/home/mark/testing/polarion/import_test_cases.py", line 56, in <module> add.perform() File "/home/mark/testing/polarion/import_test_cases.py", line 40, in perform import_xml.import_single_testcase(self.client, self.project, self.directory + x, workitems) File "/home/mark/testing/polarion/import_xml.py", line 76, in import_single_testcase workitem.removeTestStep(i) File "/home/mark/.local/lib/python3.10/site-packages/polarion/workitem.py", line 612, in removeTestStep service.setTestSteps(self.uri, self._polarion_test_steps.steps.TestStep) File "/home/mark/.local/lib/python3.10/site-packages/zeep/proxy.py", line 46, in __call__ return self._proxy._binding.send( File "/home/mark/.local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 123, in send envelope, http_headers = self._create( File "/home/mark/.local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 73, in _create serialized = operation_obj.create(*args, **kwargs) File "/home/mark/.local/lib/python3.10/site-packages/zeep/wsdl/definitions.py", line 224, in create return self.input.serialize(*args, **kwargs) File "/home/mark/.local/lib/python3.10/site-packages/zeep/wsdl/messages/soap.py", line 79, in serialize self.body.render(body, body_value) File "/home/mark/.local/lib/python3.10/site-packages/zeep/xsd/elements/element.py", line 232, in render self._render_value_item(parent, value, render_path) File "/home/mark/.local/lib/python3.10/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item return self.type.render(node, value, None, render_path) File "/home/mark/.local/lib/python3.10/site-packages/zeep/xsd/types/complex.py", line 307, in render element.render(node, element_value, child_path) File "/home/mark/.local/lib/python3.10/site-packages/zeep/xsd/elements/indicators.py", line 256, in render element.render(parent, element_value, child_path) File "/home/mark/.local/lib/python3.10/site-packages/zeep/xsd/elements/element.py", line 226, in render self.validate(value, render_path) File "/home/mark/.local/lib/python3.10/site-packages/zeep/xsd/elements/element.py", line 264, in validate raise exceptions.ValidationError( zeep.exceptions.ValidationError: Expected at least 1 items (minOccurs check) 0 items found. (setTestSteps.testSteps)

The code I used is a simple loop (I tried few solutions):
// if the workitem exists, all the steps are deleted, before re-importing them
if exists:
if workitem.hasTestSteps():
i = len(workitem.getTestSteps()) - 1
logging.info("tot steps: " + str(len(workitem.getTestSteps())))
while i >= 0:
logging.info("i = " + str(i))
workitem.removeTestStep(i)
i -= 1

@jesper-raemaekers
Copy link
Owner

Hi,
Looks like zeep did not get the correct minimum in an array. I've create a patch for this and this will be released soon. Look at the commit if you need the solution sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants