lczub / TestLink-API-Python-client

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

TestLinkExample fails running against latest testlink_1_9_20_fixed #150

Open lczub opened 2 years ago

lczub commented 2 years ago

issue #149 reports failing TestLinkExample running against testlink_1_9_20_fixed in sample line 713 - myTestLink.copyTCnewVersion()

try to reproduce this with new build TL Server with testlink_1_9_20_fixed, using testlink-pg-docker - build-and-run-testlink-1920fixed lets fail running TestLinkExample already in sample line 367 -


createBuild [{'status': True, 'operation': 'createBuild', 'id': '1', 'message': 'Success!'}]
New Build 'TestlinkAPIClient v0.8.2-dev148' - id: 1
Traceback (most recent call last):
  File "D:\git\TestLink-API-Python-client\example\TestLinkExample.py", line 367, in <module>
    response = myTestLink.assignTestCaseExecutionTask( myTestUserName, 
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkdecorators.py", line 112, in wrapperAddDevKey
    return methodAPI(self, *argsPositional, **argsOptional)
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkdecorators.py", line 99, in wrapperWithArgs
    return self.callServerWithPosArgs(methodAPI.__name__, 
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkapigeneric.py", line 1597, in callServerWithPosArgs
    self._checkResponse(response, methodNameAPI, argsOptional) 
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkapigeneric.py", line 2181, in _checkResponse
    raise testlinkerrors.TLResponseError(
testlink.testlinkerrors.TLResponseError: 3041: Test plan (name:TestPlan_API A) has no platforms linked
assignTestCaseExecutionTask({'buildid': '1', 'platformname': 'Big Birds 39', 'devKey': '48072c25257af9f477a22c97a3858337', 'user': 'pyTLapi', 'testplanid': '2', 'testcaseexternalid': 'NPROAPI39-1'})```
elapfra commented 2 years ago

Hi,

I have also experienced this issue. I believe this is the result of a design change in testlink-code which breaks backward compatibility.

Platforms now have on_design and on_execution flags, which are disabled by default as depicted below. image

I could not update TestLink-API-Python-Client project to succesfully enable the on_execution flag when creation a platform (I believe testlink project does not support it yet).

Instead I had to modify the testlink server project code to set the on_execution flag to 1 when creation the platform.

For what it's worth, here is the change in testlink-code project

diff --git a/lib/functions/tlPlatform.class.php b/lib/functions/tlPlatform.class.php
index 4d6674eac..4ab073db1 100644
--- a/lib/functions/tlPlatform.class.php
+++ b/lib/functions/tlPlatform.class.php
@@ -71,7 +71,7 @@ class tlPlatform extends tlObjectWithDB
               "," . \$this->tproject_id .
               ",'" . \$this->db->prepare_string(\$platform->notes) . "'" .
               "," . (\$platform->enable_on_design ? 1 : 0) . 
-              "," . (\$platform->enable_on_execution ? 1 : 0) . ")";
+              "," . (\$platform->enable_on_execution ? 1 : 1) . ")";
       \$result = \$this->db->exec_query(\$sql);

       if( \$result ) {
lczub commented 2 years ago

Hello Elapfra, thanks for your explanation. I start now to understand and must apologize, that I haven't yet implemented the known api change #139.

Guess that would give us the required switches platformOnDesign and platformOnExecution.

Let me try this out

Luiko

lczub commented 2 years ago

createPlatform accepts now new optional args platformondesign and platformonexecution ( see #139) sample

newPlatForm = myTestLink.createPlatform(NEWPROJECT, NEWPLATFORM_A, 
        notes='Platform for Big Birds, unique name, only used in this project',
        platformondesign=True, platformonexecution=True)
lczub commented 2 years ago

next hidden error in TestLinkExample occurs in line 435

reportTCResult [{'status': True, 'operation': 'reportTCResult', 'overwrite': False, 'message': 'Success!', 'id': '6'}]
Traceback (most recent call last):
  File "D:\git\TestLink-API-Python-client\example\TestLinkExample.py", line 435, in <module>
    newAttachment = myTestLink.uploadExecutionAttachment(a_file, newResultID_B, 
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkdecorators.py", line 168, in wrapperAddAttachment
    return methodAPI(self, *argsPositional, **argsAttachment)
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkdecorators.py", line 99, in wrapperWithArgs
    return self.callServerWithPosArgs(methodAPI.__name__, 
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkapigeneric.py", line 1612, in callServerWithPosArgs
    self._checkResponse(response, methodNameAPI, argsOptional) 
  File "D:\git\TestLink-API-Python-client\src\testlink\testlinkapigeneric.py", line 2196, in _checkResponse
    raise testlinkerrors.TLResponseError(
testlink.testlinkerrors.TLResponseError: 6002: (uploadExecutionAttachment) - Error inserting attachment on DB
uploadExecutionAttachment({'filename': 'MyPyExampleApiClient.py', 'filetype': 'text/x-python', 'content': {'filename': 'TestLinkExample.py', 'filetype': 'text/x-python', 'content': b'Iy ...0K\n'}, 'devKey': '48072c25257af9f477a22c97a3858337', 'executionid': '6', 'title': 'Textfile Example', 'description': 'Text Attachment Example for a TestCase Execution'})

observed releated warning in testlinklog.log

[>>][61648dff1ea9e731534020][DEFAULT][/lib/api/xmlrpc/v1/xmlrpc.php][21/Oct/11 19:18:23]
        [21/Oct/11 19:18:23][WARNING][<nosession>][GUI]
                E_WARNING
base64_decode() expects parameter 1 to be string, array given - in /var/www/html/lib/api/xmlrpc/v1/xmlrpc.class.php - Line 5834
[<<][61648dff1ea9e731534020][DEFAULT][/lib/api/xmlrpc/v1/xmlrpc.php][21/Oct/11 19:18:23][21/Oct/11 19:18:23][took 0.017026 secs]