jesper-raemaekers / python-polarion

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

getLinkedItems() #124

Closed davehorner closed 1 year ago

davehorner commented 1 year ago

Hello, Thanks for the very nice library. I am wanting to get a list of the linked items and see no way of doing so currently with python-polarion. I'm asking if this might be possible and if so some guidance on implementing such functionality? I can help with a PR if I do find a way. Thanks.

jesper-raemaekers commented 1 year ago

Hi,

I thought this was in there, but it turns out there was no direct method to do this. Have a look at the commit above to get started. This will be in the package some time soon.

davehorner commented 1 year ago

tried to use this today. I cloned the latest code and verified the new methods were there. I did a pip install -e .

I now see.

client = polarion.Polarion(purl, puser, ppass)
zeep.exceptions.LookupError: No type 'PdfProperties' in namespace http://ws.polarion.com/TrackerWebService-types. Available types are: {http://ws.polarion.com/TrackerWebService-types}EnumOptionId, {http://ws.polarion.com/TrackerWebService-types}Baseline, {http://ws.polarion.com/TrackerWebService-types}Folder, {http://ws.polarion.com/TrackerWebService-types}Approval, {http://ws.polarion.com/TrackerWebService-types}ArrayOfApproval, {http://ws.polarion.com/TrackerWebService-types}Attachment, {http://ws.polarion.com/TrackerWebService-types}ArrayOfAttachment, {http://ws.polarion.com/TrackerWebService-types}Category, {http://ws.polarion.com/TrackerWebService-types}ArrayOfCategory, {http://ws.polarion.com/TrackerWebService-types}ArrayOfEnumOptionId, {http://ws.polarion.com/TrackerWebService-types}Comment, {http://ws.polarion.com/TrackerWebService-types}ArrayOfComment, {http://ws.polarion.com/TrackerWebService-types}ExternallyLinkedWorkItem, {http://ws.polarion.com/TrackerWebService-types}ArrayOfExternallyLinkedWorkItem, {http://ws.polarion.com/TrackerWebService-types}Hyperlink, {http://ws.polarion.com/TrackerWebService-types}ArrayOfHyperlink, {http://ws.polarion.com/TrackerWebService-types}LinkedOslcResource, {http://ws.polarion.com/TrackerWebService-types}ArrayOfLinkedOslcResource, {http://ws.polarion.com/TrackerWebService-types}LinkedWorkItem, {http://ws.polarion.com/TrackerWebService-types}ArrayOfLinkedWorkItem, {http://ws.polarion.com/TrackerWebService-types}Custom, {http://ws.polarion.com/TrackerWebService-types}ArrayOfCustom, {http://ws.polarion.com/TrackerWebService-types}PlanningConstraint, {http://ws.polarion.com/TrackerWebService-types}ArrayOfPlanningConstraint, {http://ws.polarion.com/TrackerWebService-types}PriorityOptionId, {http://ws.polarion.com/TrackerWebService-types}TimePoint, {http://ws.polarion.com/TrackerWebService-types}WorkRecord, {http://ws.polarion.com/TrackerWebService-types}ArrayOfWorkRecord, {http://ws.polarion.com/TrackerWebService-types}WorkItem, {http://ws.polarion.com/TrackerWebService-types}FieldDiff, {http://ws.polarion.com/TrackerWebService-types}Change, {http://ws.polarion.com/TrackerWebService-types}ActivityCustomValue, {http://ws.polarion.com/TrackerWebService-types}ActivityCustomValueEntry, {http://ws.polarion.com/TrackerWebService-types}ActivityComment, {http://ws.polarion.com/TrackerWebService-types}ContextId, {http://ws.polarion.com/TrackerWebService-types}Activity, {http://ws.polarion.com/TrackerWebService-types}EnumOption, {http://ws.polarion.com/TrackerWebService-types}WorkflowAction, {http://ws.polarion.com/TrackerWebService-types}CustomField, {http://ws.polarion.com/TrackerWebService-types}CustomFieldType, {http://ws.polarion.com/TrackerWebService-types}LanguageDefinition, {http://ws.polarion.com/TrackerWebService-types}LinkedResource, {http://ws.polarion.com/TrackerWebService-types}ImportedComment, {http://ws.polarion.com/TrackerWebService-types}ModuleComment, {http://ws.polarion.com/TrackerWebService-types}ArrayOfModuleComment, {http://ws.polarion.com/TrackerWebService-types}Module, {http://ws.polarion.com/TrackerWebService-types}WikiPageAttachment, {http://ws.polarion.com/TrackerWebService-types}ArrayOfWikiPageAttachment, {http://ws.polarion.com/TrackerWebService-types}WikiPage, {http://ws.polarion.com/TrackerWebService-types}ActivitySource, {http://ws.polarion.com/TrackerWebService-types}ArrayOfPriorityOptionId, {http://ws.polarion.com/TrackerWebService-types}PriorityOpt, {http://ws.polarion.com/TrackerWebService-types}EnumCustomFieldType

zeep.exception. Maybe there are some other modifications in main that are problematic? I can wait for the next release, just wanted to give it a go. thanks.

bigblondewolf commented 1 year ago

I am also interested in getLInkedItems(), so I installed the module from the github repo and tried it. I cannot reproduce your error. Here's what I did, maybe you can try to replicate. I did this in a virtualenv to keep my system clean - make sure to source venv/bin/activate - this will change your prompt to (venv), do not proceed if not, otherwise you may break something else:

mkdir test_linked_wi
cd test_linked_wi
virtualenv venv
source venv/bin/activate
pip install --upgrade pip
pip install git+https://github.com/jesper-raemaekers/python-polarion.git#egg=polarion

I used the following simple script to test (change all MY_ labels to your needs):

#!/usr/bin/env python3

from polarion import polarion

pol = polarion.Polarion("https://MY_POLARION_ADDRESS", MY_USERNAME, MY_TOKEN)
prj = pol.getProject("MY_PROJECT")
wi = prj.getWorkitem("MY_WORKITEM_ID")
print(wi)
for lwi in wi.getLinkedItem():
    print("\t{}".format(lwi))
davehorner commented 1 year ago

@bigblondewolf thanks for the additional detail, glad to hear it is working for you.

I didn't use virtual environments when testing, I did so now.

conda create -n myenv
conda activate --stack myenv
conda install -n myenv pip
pip install git+https://github.com/jesper-raemaekers/python-polarion.git#egg=polarion

Installs fine, still getting an error self.PdfProperties = self.getTypeFromService('Tracker', 'ns2:PdfProperties')

raise exceptions.LookupError(
zeep.exceptions.LookupError: No type 'PdfProperties' in namespace http://ws.polarion.com/TrackerWebService-types.

Probably my environment, but I'm not sure. Looks related to https://github.com/jesper-raemaekers/python-polarion/commit/096a2edaa1f6521a69e58e65e911becf885eb1aa Available types are displayed from the TrackerWebService-types; I did not see the pdf in the list. Maybe my server is older and doesn't include the pdf functionality?

bigblondewolf commented 1 year ago

Yes, that looks like added in the commit you mention. Your TrackerWebService probably doesn't have the PdfProperties, but I don't know whether it's version or config.

Can you go to https://\<your-polarion-server>/ws/services/TrackerWebService?wsdl and check if PdfProperties is in the list? I won't be very helpful if it is not, but you can always comment out line#174 from polarion.py and check the rest of the functionality you're interested in.

davehorner commented 1 year ago

thanks. I was able to get it working when I commented out the line 174 as you suggested.

the wsdl does not contain "pdf" in the entire document.

https://github.com/jesper-raemaekers/python-polarion/commit/096a2edaa1f6521a69e58e65e911becf885eb1aa would be a breaking change for those of us with no PdfProperties

jesper-raemaekers commented 1 year ago

Just checking in, what is your polarion version?

jesper-raemaekers commented 1 year ago

I also made a patch, see https://github.com/jesper-raemaekers/python-polarion/commit/705337fa9ea4982e18035c644b193e0f7c1d3dbe Can you try this and see if this resolves the issue?

davehorner commented 1 year ago

checked out the origin/PDF_properties_optional branch and found that the code works without modification. thank you.

bigblondewolf commented 1 year ago

I also made a patch, see https://github.com/jesper-raemaekers/python-polarion/commit/705337fa9ea4982e18035c644b193e0f7c1d3dbe Can you try this and see if this resolves the issue?

Grammar police here, typo in comment on line#184 :)

davehorner commented 1 year ago

@bigblondewolf lol nice catch.

davehorner commented 1 year ago

It is working for many; but I have found myself in an exception.

Workitem not retrieved from Polarion (line 131 workitem.py)

self._polarion_item is all None when the exception occurs.

image

I think there may be an issue if the work item links to other projects. this has a parent and relates to. two different projects. it is using a project that is different than the linked_item.workItemURI's specified project.

It's nice to return a WorkItem but ('link type', 'PRJ-###') would be a fine interface too.

jesper-raemaekers commented 1 year ago

I also made a patch, see 705337f Can you try this and see if this resolves the issue?

Grammar police here, typo in comment on line#184 :)

Will update it later.

It is working for many; but I have found myself in an exception.

Workitem not retrieved from Polarion (line 131 workitem.py)

self._polarion_item is all None when the exception occurs.

image

I think there may be an issue if the work item links to other projects. this has a parent and relates to. two different projects. it is using a project that is different than the linked_item.workItemURI's specified project.

It's nice to return a WorkItem but ('link type', 'PRJ-###') would be a fine interface too.

I will also take a look at this. I will test it with links across projects but i also agree with you that the interface could not fetch them all. This can take some time for work item that have many links. Most likely I will implement both variants of this.

davehorner commented 1 year ago

Last night I have a work item that was changed while doing reporting. The item was changed in a way that I don't understand. It shows a "Test Steps" field was changed in event email. The thing is, we don't use Test Steps and its not visible on the item. Strange. I know I didn't edit the edit via the web interface and it happened while I was testing.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.

jesper-raemaekers commented 1 year ago

So, i guess 2 months qualifies as 'I'll look at it later' :)

So it works just fine retrieving workitems across projects. I did add a check in https://github.com/jesper-raemaekers/python-polarion/commit/42c2b610c07aa9f2a33097e3208d906fb4f59dbf to prevent that exception that you had. I'll go ahead and merge these changes discussed here to main so that is will be released at some point.

@davehorner for that email notification, I'm not to sure how to start debugging it. Added tests steps is not done the same way as other properties of a workitem so that should not occur when not changing it.

davehorner commented 1 year ago

@jesper-raemaekers thank you for addressing my concern with the modification and "Test Steps" field.

Added tests steps is not done the same way as other properties of a workitem so that should not occur when not changing it.

Whatever that different way is, it changed an item. I just looked now and I think I may have another candidate, this one removed a test step. I'm not certain how to corral this issue.

Thank you for getting these features into further release. It is very handy.