Giter VIP home page Giter VIP logo

python-polarion's Introduction

Python-polarion

Build status Coverage Test Documentation Status Downloads

This package allows the user to access many Polarion items like workitems, test run, plans and documents.

Feature overview

This package can, among others, read, modify and create:

  • Workitems
  • Test runs from templates
  • Plans
  • Documents

Work with attachments in workitems and test runs. Work with custom field in workitems and documents.

Installation

pip install polarion

Getting started

Creating the Polarion client and getting workitems, test runs or plans:

from polarion import polarion
client = polarion.Polarion('http://example.com/polarion', 'user', 'password')
project = client.getProject('Python')
workitem = project.getWorkitem('PYTH-510')
run = project.getTestRun('SWQ-0001')
plan = project.getPlan('00002')

Modifying workitems:

workitem.setDescription('Some description..')
workitem.addComment('test comment', 'sent from Python')
workitem.addHyperlink('google.com', workitem.HyperlinkRoles.EXTERNAL_REF)

Or test run results:

run = project.getTestRun('SWQ-0001')
run.records[0].setResult(record.Record.ResultType.PASSED, ' Comment with test result')

Adding workitems to a plan:

plan.addToPlan(workitem)
plan.removeFromPlan(workitem)

More examples to be found in the quick start section of the documentation. Go to the documentation

How does it work?

This project uses the SOAP API of Polarion. This API exposes most of the user interactions you can do with Polarion like creating or editing workitems, plans and test runs. The API is divided in seven different services which you can find from your Polarion instance at the url http://domain.com/polarion/ws/services. Each of the services provides a WSDL file detailing the available functions. (Also available form you local instance at http://domain.com/polarion/ws/services/TrackerWebService?wsdl) For this project the TrackerWebService, PlanningWebService and TestManagementWebService are the most used ones.

In general the project attempts for the objects (like workitems) to behave like Python objects which you can modify and are saved in the background. Where the API provide operation to preform an action that API call is used, and the object is reloaded from polarion to reflect the changes locally.

The API does not allow access to the project administration.

Dependencies

The package uses; requests, urllib3 and zeep.

It is tested for Python version 3.7 through 3.12. Python 3.6 support has been dropped in 1.3.0.

Known issues or missing features

  • No way of knowing the test run possible statuses.
  • Deleting work items used in documents does not remove the reference from the document.

python-polarion's People

Contributors

adamszelig avatar ajahraus avatar anjalizope avatar blelevier avatar dependabot[bot] avatar ergorion avatar fieschkon avatar flominatortm avatar futsch1 avatar jesper-raemaekers avatar lionnelc avatar mg-diego avatar newmesstuff avatar remiheens avatar schperplata avatar taubmannpeter avatar the-working-rene avatar therealevahill avatar thijssassen avatar tristanfaure avatar vjacobjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-polarion's Issues

Attachment download fails

The getAttachment functions uses the url from the attachment which points to the svn location of a file. Which can work if the login details of Polarion match those of SVN, but the better solution would be to use the url polarion provides via the interface.

I found this out when a fresh install with Polarion 21r2 no longer allows the attachment tests to pass. It gives an 401 unauthorized error although the exception doesn't show this.

This issue is for reference as i will fix this "shortly"

error when accessing a server without a valid certificate

Hi!

I'm trying to access a company internal polarion server which is reaching its end of life. Therefore, no more maintenance is done, and the certificate has either expired or somehow else got invalid.

When trying to access this server, I get the exception:
SSLCertVerificationError: ("hostname '' doesn't match either of '.some-simliar', '.but-not-really', '*.same-domain.com'",)

I was searching for a flag in python-polarion, but could not find any. Then I tried to set a flag on the level of the libs that python-polarion is using:
I have tried different approaches, e.g. : (based on stack overflow entries)
import ssl
ssl.match_hostname = lambda cert, hostname: True
or (based on the above and own investigation, as the exception seems not to be thrown by the ssl module)
from urllib3.packages.ssl_match_hostname import match_hostname
match_hostname = lambda cert, hostname: True

But none of the above helps.
I'm asking for:
a) do you know of a working work around that does not require a change in python-polarion?
b) would you be so kind enough to consider a change in python-polarion whereby one could switch off certification validation?

Thanx in advance for your help,
Axel

Exception on script end

Hi!

I'm using python-polarion (0.1.14) with python 3.8 under Win10 to access two different Polarion servers. Whenever my script ends, I get the following output:

Exception ignored in: <function Polarion.del at 0x000001D9CE0ADF70>
Traceback (most recent call last):
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\polarion.py", line 43, in del
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\proxy.py", line 46, in call
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 127, in send
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\transports.py", line 107, in post_xml
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\transports.py", line 73, in post
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 590, in post
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 528, in request
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 448, in prepare_request
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\cookies.py", line 544, in merge_cookies
File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\cookies.py", line 352, in update
File "C:\Users\sa4238x\Anaconda3\lib\copy.py", line 92, in copy
ImportError: sys.meta_path is None, Python is likely shutting down

It's not a real functional problem, still it's not nice.
Thanx,
Axel

Error retrieving existing Test Run

At https://python-polarion.readthedocs.io/en/latest/testrun.html, there is an example of how to get a test run: existing_test_run = self.checking_project.getTestRun('test-id'). I'm able to get my Project and modify a Work Item.

However, when attempting to test_run = project.getTestRun('ABC-123'), I get the error below. FWIW, I'm using Python 3.9.6 on macOS Catalina (10.15.7) if that is a factor.

Any suggestions on how to resolve this? Thanks!

Exception ignored in: <function Polarion.__del__ at 0x10d4f89d0>
Traceback (most recent call last):
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/polarion/polarion.py", line 43, in __del__
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/zeep/proxy.py", line 46, in __call__
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 127, in send
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/zeep/transports.py", line 107, in post_xml
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/zeep/transports.py", line 73, in post
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/requests/sessions.py", line 590, in post
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/requests/sessions.py", line 532, in request
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/requests/sessions.py", line 711, in merge_environment_settings
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/requests/utils.py", line 776, in get_environ_proxies
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/site-packages/requests/utils.py", line 760, in should_bypass_proxies
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/urllib/request.py", line 2647, in proxy_bypass
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/urllib/request.py", line 2624, in proxy_bypass_macosx_sysconf
  File "/Users/ppoon/anaconda3/envs/polarion/lib/python3.9/urllib/request.py", line 2566, in _proxy_bypass_macosx_sysconf
ImportError: sys.meta_path is None, Python is likely shutting down

editApproval

Hello,
I tried to implement editApproval function for workitem:

def editApproval(self, approveeID, status):
service = `self._polarion.getService('Tracker')
service.editApproval(self.uri, approveeID, status)

It throws an error:
File "C:\Users\jjgl3t\AppData\Local\Programs\Python\Python38-32\lib\site-packages\polarion\workitem.py", line 157, in editApproval
service.editApproval(self.uri, approveeID, status)
File "C:\Users\jjgl3t\AppData\Local\Programs\Python\Python38-32\lib\site-packages\zeep\proxy.py", line 46, in call
return self._proxy._binding.send(
File "C:\Users\jjgl3t\AppData\Local\Programs\Python\Python38-32\lib\site-packages\zeep\wsdl\bindings\soap.py", line 135, in send
return self.process_reply(client, operation_obj, response)
File "C:\Users\jjgl3t\AppData\Local\Programs\Python\Python38-32\lib\site-packages\zeep\wsdl\bindings\soap.py", line 229, in process_reply
return self.process_error(doc, operation)
File "C:\Users\jjgl3t\AppData\Local\Programs\Python\Python38-32\lib\site-packages\zeep\wsdl\bindings\soap.py", line 329, in process_error
raise Fault(
zeep.exceptions.Fault: java.lang.NullPointerException

Process finished with exit code 1

Do you know how to implement it?

access to history of work item

I have a case where I need to get history of all my work items to measure for instance for how long item was in a particular state.
Is there any chance to get history?

Testrun result No breaks webinterface

After setting test run result to No you can no longe edit the test case result via the web inteface.

testrun.records[0].setResult(result=Record.ResultType.PASSED)
testrun.records[0].setResult(result=Record.ResultType.No)

Server reports:

Server error:

Test case result data must contain the same number of test step results as the paused test record (0), but is 3

Workitem.addHyperlink() requires an ENUM for the hyperlink_type

Since the hyperlink_type ids can be configurable and might not match the HyperlinkRoles enum values, it would be better to allow a direct str input to allow users to provide a custom value needed for their project

Something like this:

def addHyperlink(self, url, hyperlink_type: HyperlinkRoles):
    """
    Adds a hyperlink to the workitem.

    :param url: The URL to add
    :param hyperlink_type: Select internal or external hyperlink
    """
    service = self._polarion.getService('Tracker')
    if isinstance(hyperlink_type, Enum):   #convert Enum to str
        hyperlink_type = hyperlink_type.value  
    service.addHyperlink(self.uri, url, {'id': hyperlink_type})
    self._reloadFromPolarion()

Currently for my implementation I have to create a Custom Enum and pass that into the addHyperlink()

SessionId not stored for SessionWebServices

During _createSession the session id is stored in self.sessionHeaderElement. All other webservices are updated with the sessionId but the SessionWebServices not. Therefore functions like beginTransaction/endTransaction failed.

Can be fixed by adding self.services['Session']['client'].set_default_soapheaders([self.sessionHeaderElement]) after self.sessionHeaderElement = tree.find('.//{http://ws.polarion.com/session}sessionID')

Proxy

I think it could be great if we could provide proxy information while creating an instance of Polarion as optional info.

https support?

I am unable to connect to our polarion server with this library after we updated to https (full stack trace bellow). I'm not too knowledgeable with SSL certificates, so I'm not sure if this is an issue on our end or a limitation of the library. I dug this up after some research:

https://stackoverflow.com/questions/10667960/python-requests-throwing-sslerror

Per the link, perhaps a fix would be to expose the verify parameter of requests.get through new parameter for the Polarion class init. This would allow applications to specify a path to the certificate's .pem file or skip verification altogether.

I would appreciate your input.

Traceback (most recent call last):
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\connectionpool.py", line 1010, in validate_conn
conn.connect()
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\connection.py", line 416, in connect
self.sock = ssl_wrap_socket(
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\util\ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\util\ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\bjahnke\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\bjahnke\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\bjahnke\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:_projects\polarion_api_test\venv\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:_projects\polarion_api_test\venv\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='polarion.redacted.com', port=443): Max retries exceeded with url: /polarion/ws/services (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:_projects\polarion_api_test\venv\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:_projects\polarion_api_test\venv\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:_projects\polarion_api_test\venv\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:_projects\polarion_api_test\venv\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='polarion.redacted.com', port=443): Max retries exceeded with url: /polarion/ws/services (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122)')))
python-BaseException

Fill in custom fields for new work items

Hi,
I have an excel sheet with each sheet corresponding to multiple work items of same type with many attributes. I am developing python script to create work items and fill the custom fields with those attributes. Problem is for existing work item in polarion, I am able to get the custom fields as an array but for new work item, how do I fill the custom field values? There are really lot of work items and this will help me reduce lot of manual work.
Fields for already existing work item but for new work item I get nothing.

>>> tempWI.customFields
{
    'Custom': [
        {
            'key': 'field1',
            'value': {
                'id': 'lessThan6Months'
            }
        },
        {
            'key': 'field2',
            'value': 4
        },
        {
            'key': 'field3',
            'value': {
                'id': 'Expert'
            }
        }
]}

Also, polarion keeps logging me out and I have create a session every sometime. Is there a way to hold the session from logging out?
Thanks.

How to create a new testcase?

Hi,

I'm able to create a testrun and testcases but I haven't found how to add those testcases in the testrun. There is only functions to check or get existing testcase. I have tried to create a new Record object but I don't have anything for the polarion_record argument as it's a new one. Is there a way to do that?

Typo in workitem.py

line 265: if status in self.getVailableStatus():
Should be : if status in self.getAvailableStatus():

inserting a test step

Hello,
I tried to modify a test step in polarion by changing the attribute of a work item and saved it afterwards.
But the changes are not saved.
E.g.
wi = polarion.Polarion('http...', 'MyUserid', 'MyPassword').getProject('MyProjectName').getWorkitem('MyWorkitem')
wi._polarion_test_steps['steps']['TestStep'][0]['values']['Text'][1]['content']='\xa0description1'
wi.save()

Now I would expect that the first entry in the "Test Steps" in Table Entry "Step Description" would have been updated.
But that did not happen.
Did I just made it wrong or used the wrong attribute?
Sorry I also did not found anything in the descriptions.

workitem not properly created when retrieved from plan

When you retrieve a plan from polarion with
plan = project.getPlan('plan_id')
retrieve all work items from the plan with
listOfWIs = plan.getWorkitemsInPlan()
and then print the first (or any) element out like:
print (listOfWIs[0])
you will see an output like:
None: <title of work item>

In other words, workitem._id is not properly set. The remaining fields seem to be set ok.

exception when logging into Polarion server

Hi!

I'm using python-polarion (0.1.14) with python 3.8 under Win10 to access two different Polarion servers. It seems that one of them changed configuration in the last couple of weeks, because suddenly logging in creates an AttributeError exception in polarion.py:_updateServices.
I could not find any other workaround, than adding a try/except clause:

                try:
                    self.services[service]['client'].service.addComment._proxy._binding.get(
                    'addComment').input.body.type._element[1].nillable = True
                except AttributeError:
                    pass

Maybe this indicates that adding comments was disabled on the server?
Would be nice if this missing service would not keep you from logging into the server at all.
Thanx,
Axel

searchWorkitem with 'customFields' request doesn't work

Hello,

I try to get polarion workitem information with searchWrokitem method. I need just a couple of fields to retrieve to make it faster and it seems that for 'customFields' it doesn't work. For this field I get None even if a lot of workitems does have this kind of field in Polarion.

When I use getWorkitem I get 'customFields' as well, but I have other 3000 workitems and it takes a lot of time to do so, that's why I need to use searchWrokitem instead.

Used command:
workitems_design_element = project.searchWorkitem('type:sw_architecture_element', 'id', ['id', 'customFields'])

Could someone help me with this? Is there a problem with python-polarion library?

Thank you!

Do you have idea about SetLinkedResource?

Hello
I'm using your package well.
Due to company policy, resource traceability cannot be set.
I cannot connect git server directly.(Administration -> Repositories -> Configuration, Resource Traceability)

I want to input LinkedResource data manually using wsdl.
I know there is no function setLinkedResource in wsdl.
Do you have idea to update linkedresource data?

image

[Question] usage of suds vs zeep

Hi @jesper-raemaekers,

  • I only skimmed through the code and found the implementation is clean, congrats for that.
  • My question is, before picking up Zeep did you try Suds as well and how well Zeep is generating WSDL services, since polarion is not a trivial service 😅
  • If you indeed did any POC, did you see the speed improvements in zeep vs suds?

Why am I asking?

  • By any means I'm not demotivating the effort and at the same time couldn't resist opening the dialogue about duplicate effort 😄
  • We have an open source project which also provides Python API for Polarion and I'm here out of technical interest on how good it'd be to swap Suds with Zeep.

Repeating again, I'm here to get to know zeep ability of generating wsdl objects natively from your experience. If you feel the question/premise is inappropriate, please close and delete the issue.

Thanks.

addLinkedItem does not create the corresponding mirror of "role"

addLinkedItem does not create the corresponding mirror of role.

workitem_1.addLinkedItem(workitem_2, role = 'refers to') will not create a link in workitem_2 with role "is refered by" to workitem_1.
Instead, workitem_2 will have a link back to workitem_1 with role "refers to" which is not intended.

The link itself seems intact, the link create for workitem_1 is pointing to workitem_2 i.e you cannot remove/edit the link from workitem_2 but only from workitem_1.

tested in python version 3.9.7
polarion version 1.0.0

How to edit/update workItems Rich text customfields?

Am getting the following error while updating rich text customfields in work items.
Exception has occurred: ValidationError (note: full exception trace is shown but execution is paused at: )
Missing element content (updateWorkItem.content.customFields.Custom.value.content)

I have copied my code below:

Imports

from msilib.schema import CustomAction
from urllib.parse import urljoin
from polarion import polarion
import openpyxl
from openpyxl.styles.fills import PatternFill
import os

class ConnectPolarion:

def __init__(self, alm_link, username, passwd, project_name):
    self.client = polarion.Polarion(alm_link, username, passwd, skip_cert_verification=True)
    self.my_project_name = project_name
    self.my_project = self.client.getProject(self.my_project_name)
    self.all_workitems_data = {}
	
	
def update_svcp_cases(self):
    self.spaces = self.my_project.getDocumentSpaces()
    self.document = self.my_project.getDocument(f'Preliminary Collaboration/Test_SVCP')
    self.all_workitems = self.document.getWorkitems()
    #Process the work item
    self.workitem = self.my_project.getWorkitem('VMM-20804')
    print(self.workitem)
    print(self.workitem._polarion_item)
	cond_cont = self.client.TextType
    val = cond_cont(type='text/html', content='This is my string', contentLossy=False)
    self.workitem.setCustomField('conditions', val)

#---------------------------------------------
#Program Start
#---------------------------------------------
if name == "main":
link_url = 'https://alm.collins.com/polarion'
my_username = 'xxx'
my_password = 'yyy'
my_project = 'VMM_H'

myConnectPolarion = ConnectPolarion(link_url, my_username, my_password, my_project)
myConnectPolarion.update_svcp_cases()

ssh

In my case i have to establish an connection via ssh. Therefore i would like to painfully switch of verification using the request.get( SEE BELOW).

I would like to see having a parameter field on the polarion constructor to allow such things.

def _getServices(self):
        """
        Parse the list of services available in the overview
        """
        service_overview = requests.get(self.url, **verify=False**)
        service_base_url = self.url + '/'
        if service_overview.ok:
            services = re.findall("(\w+)WebService", service_overview.text)
            for service in services:
                if service not in self.services:
                    self.services[service] = {'url': urljoin(
                        service_base_url, service + 'WebService')}

Create multiple workitems in a document without creating many document revisions

Hi,
is it possible?

I can successfully create a new document with many workitems, everything is working fine, but I have big issues with creating thousands of document revisions. Each one per a new workitem I create.

I found some references to "sessions" and transactions, but I didn't manage to get it working.

Thank you and keep it up!

class WorkItem setResolution does not work on the latest version

Hello,

The setResolution method of WorkItem class does not work on the latest version 0.1.15.

The error message says as follows:

Traceback (most recent call last):
File "polarionCLI.py", line 126, in
workitem.setResolution(project_resolutions[toSetResolution])
File "C:\Users\tsuto\Documents\Polarion\polarion_cli\lib\site-packages\polarion\workitem.py", line 312, in setResolution
self.resolution.id = resolution
AttributeError: 'dict' object has no attribute 'id'

I confirmed this method does work on version 0.1.2.

Could you please look into it?

Best regards,
Tsutomu Inoue

Login to polarion fails

Since this month the login to polarion does not work anymore, I get the following error message.

Forcing soap:address location to HTTPS
('Connection aborted.', ConnectionResetError(10054, 'An existing connection was closed by the remote host', None, 10054, None))

I can still sign up through the website.
The polarion admistrator could not or would not help me.

I would be grateful for any ideas.

Thanks!

Ps: This tool has been a great help and relief for me so far.


Python: 3.9
polarion-1.1.0
zeep-4.2.1
urllib3-1.26.13


Traceback (most recent call last):
  File "C:\examplePolarion\lib\site-packages\requests\adapters.py", line 440, in send
      resp = conn.urlopen(
  File "C:\examplePolarion\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
      retries = retries.increment(
  File "C:\examplePolarion\lib\site-packages\urllib3\util\retry.py", line 550, in increment
      raise six.reraise(type(error), error, _stacktrace)
  File "C:\examplePolarion\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
      raise value.with_traceback(tb)
  File "C:\examplePolarion\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
      httplib_response = self._make_request(
  File "C:\examplePolarion\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
      self._validate_conn(conn)
  File "C:\examplePolarion\lib\site-packages\urllib3\connectionpool.py", line 1042, in validate_conn
      conn.connect()
  File "C:\examplePolarion\lib\site-packages\urllib3\connection.py", line 414, in connect
      self.sock = ssl_wrap_socket(
  File "C:\examplePolarion\lib\site-packages\urllib3\util\ssl
.py", line 453, in ssl_wrap_socket
      ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\examplePolarion\lib\site-packages\urllib3\util\ssl
.py", line 495, in _ssl_wrap_socket_impl
      return ssl_context.wrap_socket(sock)
  File "C:\Apps\Python39\lib\ssl.py", line 500, in wrap_socket
      return self.sslsocket_class._create(
  File "C:\Apps\Python39\lib\ssl.py", line 1040, in _create
      self.do_handshake()
  File "C:\Apps\Python39\lib\ssl.py", line 1309, in do_handshake
      self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was closed by the remote host

unable to connect to Polarion Gen 2

Hello Team,

was trying to connect to Polarion gen 2 link using python 3.8.2. but keep getting

requests.exceptions.SSLError: HTTPSConnectionPool(host='polariong2.com', port=443): Max retries exceeded with url: /polarion/ws/services (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))

automatic query of test steps raises server side exception

It seems that whenever I query a work item, at the end there is an additional call to getTestSteps. Unfortunately, this raises a server side exception, that is only visible if you used log level DEBUG. Is there a way to make this call to getTestSteps optional?

2022-03-29 10:28:29 DEBUG HTTP Post to https://server/polarion/ws/services/TestManagementWebService:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">soap-env:Header<ns1:sessionID xmlns:ns1="http://ws.polarion.com/session" soap-env:actor="http://schemas.xmlsoap.org/soap/actor/next" soap-env:mustUnderstand="0">-46616533766877033</ns1:sessionID></soap-env:Header>soap-env:Body<ns0:getTestSteps xmlns:ns0="http://ws.polarion.com/TestManagementWebService-impl">ns0:urisubterra:data-service:objects:/default/prefix_trunk${WorkItem}prefix-53229</ns0:uri></ns0:getTestSteps></soap-env:Body></soap-env:Envelope>
2022-03-29 10:28:29 DEBUG Resetting dropped connection: server
2022-03-29 10:28:29 DEBUG https://server:443 "POST /polarion/ws/services/TestManagementWebService HTTP/1.1" 500 None
2022-03-29 10:28:29 DEBUG HTTP Response from https://server/polarion/ws/services/TestManagementWebService (status: 500):

soapenv:Server.userExceptionjava.lang.IllegalArgumentException: testCase does not have a test steps field defined: PObject(WorkItem; subterra:data-service:objects:/default/prefix_trunk${WorkItem}prefix-53229)java.lang.IllegalArgumentException: testCase does not have a test steps field defined: PObject(WorkItem; subterra:data-service:objects:/default/prefix_trunk${WorkItem}prefix-53229)
at com.polarion.alm.tracker.internal.TestManagementService.setTestSteps(TestManagementService.java:444)
at com.polarion.alm.ws.services.TestManagementWebService.getTestSteps(TestManagementWebService.java:418)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

....

How to create a workitem from scratch?

The documentation does not give an example for creating a new workitem in Polarion from scratch.
from polarion import workitem
client1 = polarion.Polarion(url, user, password)
project= client1.getProject('project')
workitem.Workitem(client1, project)
will raise an exception:
Exception: No id, uri, polarion workitem or new workitem type specified!

Defining a new workitem type, e.g.
workitem.Workitem(client1, project, new_workitem_type='changerequest')
also raises an exception:
Fault: javax.transaction.RollbackException: Workflow initialization failed for Work Item 'prefix-73487': The required field 'title' of Work Item 'prefix-73487' is empty.
So, this goes to the server, polarion tries to create a work item, but fails due to the missing title. But looking at the source, I see now way how to hand over a title (or any other field value) for creating a work item.

I then tried to play around with
workitem.Workitem(client1, project, polarion_workitem = work_item_properties)
But this lead nowhere, because the work_item_properties seemingly need to be of type zeep.objects.WorkItem. So, maybe this could be used for copying one workitem to a new one?

Thanx a lot in advance,
Axel

[Question] Plans on unifying the effort of providing Polarion Python API

Hello again @jesper-raemaekers,

  • What are your thoughts on unifying the effort on python-polarion and RedHatQE/pylero projects?
  • The plan isn't sketched yet on how this can/should happen however just pitching the idea on whether it can happen or not and get your views

Gist (pardon if I'm condensing it too much):

  • python-polarion: more modern and cleaner approach (via new set of dependencies) in providing Python API for Polarion WSDL API
  • pylero: mostly feature complete implementation of object mappings from Polarion WSDL to Python with long history of daily usage

  • The goal isn't to takeover one on another however it's to provide a cleaner approach from best of both the projects

How to log in Polarion

Following the README.md, I try to pip install polarion and try to login Polarion.

But I got this:

Traceback (most recent call last):
  File "/Users/rabbit/Desktop/P/python-polarion.py", line 8, in <module>
    client = polarion.Polarion(USER, PASSWORD, POLARION_URL)
AttributeError: module 'polarion' has no attribute 'Polarion'

Then, I tried to import this into python, to see what happened.

Python 3.6.8 (default, Jun 14 2022, 09:19:35)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-13)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import polarion
>>> polarion.
polarion.DocumentCreator(  polarion.document
polarion.TestrunCreator(   polarion.factory
polarion.UserCreator(      polarion.record
polarion.WorkitemCreator(  polarion.testrun
polarion.addCreator(       polarion.user
polarion.base              polarion.workitem

Look like it is genuinely no attribute 'Polarion'.
Please help me, thanks.

"reuse" of document without creating links between source document and new document

Hello
I'm using "document.reuse" to create a copy of an existing document. By default the documents and contained work items from source to copy are linked with 'derived_from'.
Is there a way to use "reuse" without creating the links resp. to get a standalone copy without any links to the source document?
I would be grateful for any ideas.

Thanks!

Add xml import feature

Polarion implement an import xml feature using UI, but it is not accessible using the API.

I recode the equivalent (see MR)

exception when retrieving a workitem from the server

I know that this workitem exists, I can look at it in the web userinterface. However, when I try to get it, I get an exception. In addition, this breaks my search with projet.searchWorkitemFullItem() -- as the function also fetches all workitems from the server. When it tries to retrieve this problematic work item, the exception breaks the complete search.

wi = project.getWorkitem(workitemid)
Traceback (most recent call last):

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\workitem.py", line 52, in __init__
    self._polarion_item = service.getWorkItemById(

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\proxy.py", line 46, in __call__
    return self._proxy._binding.send(

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 135, in send
    return self.process_reply(client, operation_obj, response)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 229, in process_reply
    return self.process_error(doc, operation)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 329, in process_error
    raise Fault(

Fault: java.lang.ClassCastException: class com.polarion.platform.persistence.ipi.WeakPObjectList cannot be cast to class com.polarion.platform.persistence.IEnumOption (com.polarion.platform.persistence.ipi.WeakPObjectList and com.polarion.platform.persistence.IEnumOption are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @631cb129)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "<ipython-input-27-2ad334da8ced>", line 1, in <module>
    wi = project.getWorkitem(<id>)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\project.py", line 69, in getWorkitem
    return Workitem(self.polarion, self, id)

  File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\workitem.py", line 55, in __init__
    raise Exception(

Exception: Cannot find workitem <id> in project <projectname>

Provide the option to skip SSL verification for requests

If Polarion is used with an HTTPS connection using a self-signed certificate, some workarounds are required to make the requests package skip the certificate verification.

It would be nice to have a kwarg for the Polarion object constructor that disables SSL verification.

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

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_case_record 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)

Type hints

Hey!
Would you accept PRs with type hints? I find this package very useful and would be willing to invest some time in type-hinting this package in future months.

Transport Cookies not passed -> Could not assign Workitem

Hello,

We have a 2 server setup for Polarion in AWS, and the 2 servers run behind a load balancer.
The problem we encounter is that it happes often that we authenticate on one of the servers, and the next request goes to the other server and we get the following error:

Tag not found in polarion: Cannot find workitem <workitem_id> in project <project>
[2022-04-05 09:39:32,016] ERROR in app: Exception on /post [POST]
Traceback (most recent call last):
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/eduard/.local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/eduard/Repos/efg_devops_git-polarion-bridge/./github_polarion_bridge.py", line 433, in hook_github
add_polarion_table_entry(polarion_client, work_item, commit,
UnboundLocalError: local variable 'work_item' referenced before assignment
127.0.0.1 - - [05/Apr/2022 09:39:32] "POST /post HTTP/1.1" 500 -

My question now is, how I can pass the transport cookiejar, as well as the session id, via the library, so that our load balacer knows where to route the request?

How to Log in Polarion with SSO configured

Hello,

I'm trying to Log into Polarion using your Lib. I face the problem, that if I login into Polarion with Username and Token, it throws this error message.

Polarion Error: Cannot login because WSDL has no SessionWebService

I couldn't find any appropriate fix for this error, so maybe you know what is the fault here.

Greets

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.