lczub / TestLink-API-Python-client

A Python client to use the TestLink API
104 stars 63 forks source link

KeyError thrown in getProjectIDByNode #149

Open elapfra opened 2 years ago

elapfra commented 2 years ago

Hi,

Thanks for this library, it works great.

However, I encounter this error while running "TestLinkExample.py"

Traceback (most recent call last):
  File "/home/elapfra/code/TestLink-API-Python-client/example/TestLinkExample.py", line 713, in <module>
    response = myTestLink.copyTCnewVersion(newTestCaseID_B, 
  File "/home/elapfra/code/TestLink-API-Python-client/src/testlink/testlinkapi.py", line 188, in copyTCnewVersion
    return self._copyTC(origTestCaseId, changedAttributes, origVersion, 
  File "/home/elapfra/code/TestLink-API-Python-client/src/testlink/testlinkapi.py", line 258, in _copyTC
    origArgItems['testprojectid'] = self.getProjectIDByNode(origTestCaseId)
  File "/home/elapfra/code/TestLink-API-Python-client/src/testlink/testlinkapi.py", line 166, in getProjectIDByNode
    node_path = self.getFullPath(int(a_nodeid))[a_nodeid]
KeyError: 563

It seems to me the dict should be accessed by string. This works. node_path = self.getFullPath(int(a_nodeid))[str(a_nodeid)]

lczub commented 2 years ago

Hello Elapfra, thanks for your response. It is interesting, cause before I published the releases the examples were working . So maybe it is an issue driven by special version combinations.

Could you tell me the versions from your current used

That might help to understand what happens.

Regards Luiko

elapfra commented 2 years ago

Hi,

Thanks for the quick feedback.

I'm using the HEAD commit from this project (1fb0cd24)

VERSION = '0.8.2-dev148' TL_RELEASE = '1.9.20-fixed'

I deployed the bitnami container version of testlink

$ curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-testlink/master/docker-compose.yml > docker-compose.yml
$ docker-compose up -d

But their library is behind, so I copied latest libs from testlink project (branch testlink_1_9_20_fixed)

 git clone https://github.com/TestLinkOpenSourceTRMS/testlink-code.git
 docker cp lib testlinkcode_testlink_1:/opt/bitnami/testlink/.

Python 3.6 venv

Platform: "linux-x86_64" Python version: "3.6"

lczub commented 2 years ago

Hello Elapfra, that is real interesting. I tried to reproduce it and run also in failing TestLinkExample, but in a much earlier section (see issue #150 )

copy test in testlinkapi_offline_test.py are still working

I like to investigate this, but it will take a while.

Regards Luiko

elapfra commented 2 years ago

Hi @lczub

For you information, I succesfully ran all the TestLink-API-Python-client examples (as you said it was after applying changes to the latest testlink-code project, and other changes to this project).

For what it's worth, I captured all changes I made to this project here, you could have a look if you are interested. https://github.com/elapfra/TestLink-API-Python-client/commits/1.9.20_fixed

Thanks,

lczub commented 2 years ago

Thanks for sharing your changes - observed that you also had issue with uploadExecutionAttachmemts I will fix the failures step by step during the next days and will use #150 as overall log for the process. Hope will come soon to step getProjectIDByNode.

lczub commented 2 years ago

Hello Elapfra, with the latest #150 commit, I was able to run the examples without errors against TL 1.9.20_fixed and 1.9.19. I only disabled the failing uploadAttachment steps .

The copyTCnewVersion steps work without any code change.

My tests uses py 3.9 and TL server build with docker-compose from scratch as described in TestLink-API-Python-clinet/docker/README.md

Unfortunately, I'm not able to reproduce your issue.

Regards Luiko