Chapter7: 利用Python的Testlink模块上传测试结果,取代Jenkins中的Testlink插件

本系列文章见总链接:

总章:TestStand+Jenkins+Testlink 自动化测试平台搭建

 

需要在Python环境中安装Testlink-API-Python-client。TestLink-API-Python-client is a Python XML-RPC client for Testlink

下载链接:https://pypi.org/project/TestLink-API-Python-client/

源代码:https://github.com/lczub/TestLink-API-Python-client

示例代码:https://github.com/lczub/TestLink-API-Python-client/blob/master/doc/usage.rst

安装Testlink模块: pip install TestLink-API-Python-client

在Jenkins Job中的配置

Execute Windows Batch Command in Jenkins Job

 

 

 代码:

@echo on
cd "%WORKSPACE%\%BUILD_NUMBER%"
for /F "delims=" %%i in ('findstr /r /c:"<property name=" Report_JUnit.xml') do set UUTResult="%%i"
echo %UUTResult% | findstr /c:"Passed" 1>nul
set "testresultlevel=%errorlevel%"
if %errorlevel% == 0 (set exec_status=p) else (set exec_status=f)
set "test_case_name=%ScriptName:~0,-4%"
set "custom_fields_name=%test_case_name%.1Main"
set "custom_fields=AutoTest"
for /f tokens^=8^ delims^=^" %%i in ('findstr /i "time=.*>" Report_JUnit.xml') do set "exec_duration=%%i"

set "exec_notes=%BUILD_URL%;;Project: %Project%;UnitType: %UnitType%;RunningMode: %RunningMode%;SystemInUse: %SystemInUse%;PublicORBritishSystem: %PublicORBritishSystem%;ScriptPath: %ScriptPath%;ScriptName: %ScriptName%;test_plan_name: %test_plan_name%;test_suite_name: %test_suite_name%;build_name: %build_name%;"
set "exec_junit_xml_path=%WORKSPACE%\Report_JUnit.xml"

@echo off
echo url = %TestlinkURL%
echo key = %TestlinkKEY%
echo test_project_name = %Project%
echo test_plan_name = %test_plan_name%
echo test_suite_name = %test_suite_name%
echo test_case_name = %test_case_name%
echo build_name = %build_name%
echo custom_fields_name = %custom_fields_name%
echo exec_status = %exec_status%
echo exec_duration(seconds) = %exec_duration%
echo exec_notes = %exec_notes%
echo exec_junit_xml_path = %exec_junit_xml_path%

@echo on
C:\Python27\python.exe c:\jenkins\UpdateTestExecutionINTestlink.py %TestlinkURL% %TestlinkKEY% "%Project%" "%test_plan_name%" "%test_suite_name%" "%test_case_name%" "%build_name%" "%custom_fields%" "%custom_fields_name%" %exec_status% %exec_duration% "%exec_notes%" "%exec_junit_xml_path%"

exit %testresultlevel%

 

UpdateTestExecutionINTestlink.py 代码:

# -*- coding:UTF-8 -*-
import testlink
import time
import sys

print("url: %s" %sys.argv[1])     #Testlink api address
print("key: %s" %sys.argv[2])     #Testlink developer key for specified user
print("test_project_name: %s" %sys.argv[3])   #test project name in Testlink
print("test_plan_name: %s" %sys.argv[4])      #test plan name for current test execution 
print("test_suite_name: %s" %sys.argv[5])     #test suite name of the test case
print("test_case_name: %s" %sys.argv[6])      #test case name
print("build_name: %s" %sys.argv[7])          #the build name, would be the SW version
print("custom_fields: %s" %sys.argv[8])       #the custom fields defined in Testlink
print("custom_fields_name: %s" %sys.argv[9])  #the custom fields value in test case
print("exec_status: %s" %sys.argv[10])        #the test status for current test execution
print("exec_duration(seconds): %s" %sys.argv[11])    #the duration for current test execution
print("exec_notes: %s" %sys.argv[12].replace(";","\n"))     #the useful information of jenkins job would be uploaded to Testlink
print("exec_junit_xml_path: %s" %sys.argv[13])     #the path of the Junit type XML file for current test execution results
url = sys.argv[1]
key = sys.argv[2]
test_project_name = sys.argv[3]
test_plan_name = sys.argv[4]
test_suite_name = sys.argv[5]
test_case_name = sys.argv[6]
build_name = sys.argv[7]
dict_key = sys.argv[8]
custom_fields = {}
custom_fields[dict_key] = sys.argv[9]
exec_status = sys.argv[10]
exec_duration = sys.argv[11]
exec_duration=round(float(exec_duration)//float(60.0) + float(exec_duration)%float(60.0)/float(60.0),2)     #convert the time from seconds to minutes
print("exec_duration(minutes): %s" %exec_duration)
exec_notes = sys.argv[12].replace(";","\n")+"\nTime: "+str(exec_duration)+" minutes\n"     #replace ; with \n . Then the note in Testlink would be readable
print("exec_notes: %s" %exec_notes)
exec_junit_xml_path = sys.argv[13]

tlc = testlink.TestlinkAPIClient(url,key)
for project in projects:
    print("testProject",project["id"],project["name"])    #print all project with id and name
for project in projects:
    if project["name"]==test_project_name:                
        project_id=project["id"]                          #get the project id by the known name
        print("project_id: %s" %project_id)
test_plans=tlc.getProjectTestPlans(project_id)            
for test_plan in test_plans:
    if test_plan["name"]==test_plan_name:
        test_plan_id=test_plan["id"]                      #get the test plan id by the known name
        print("test_plan_id: %s" %test_plan_id)
test_suites=tlc.getTestSuitesForTestPlan(test_plan_id)    #get the test suites by test plan id
for test_suite in test_suites:
    if test_suite["name"]==test_suite_name:
        test_suite_id=test_suite["id"]                    #get the test suite id by test suite name
        print("test_suite_id: %s" %test_suite_id)
test_cases=tlc.getTestCasesForTestSuite(test_suite_id,True,None)
for test_case in test_cases:
    if test_case["name"] == test_case_name:
        test_case_id=test_case["id"]                      #get the test case id by test case name
        print("test_case_id: %s" %test_case_id)
localtime=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())            #define the current time stamp

newBuild = tlc.createBuild(test_plan_id,build_name,'Build created automatically with Python')    #Create the build in Testlink

newResult = tlc.reportTCResult(testcaseid=test_case_id,testplanid=test_plan_id,status=exec_status,guess=True,testcaseexternalid=None,platformname=None,buildname=build_name,customfields=custom_fields,execduration=exec_duration,timestamp=localtime,notes=exec_notes)
print(newResult)
newAttachment = tlc.uploadExecutionAttachment(exec_junit_xml_path,newResult[0]['id'],test_case_name,'Description')

在Python中查看方法使用:

Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 20:49:36) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import testlink
>>> tlc = testlink.TestlinkAPIClient("http://10.90.69.239:8181/testlink-1.9.20/lib/api/xmlrpc/v1/xmlrpc.php","740c93c48fa88452c4e172c15b161ffc")
>>> print tlc.whatArgs('reportTCResult')
reportTCResult(<testcaseid>, <testplanid>, <buildname>, <status>, <notes>, [testcaseexternalid=<testcaseexternalid>], [buildid=<buildid>], [platformid=<platformid>], [platformname=<platformname>], [guess=<guess>], [bugid=<bugid>], [customfields=<customfields>], [overwrite=<overwrite>], [user=<user>], [execduration=<execduration>], [timestamp=<timestamp>], [steps=<steps>], [devKey=<devKey>])
 Reports a result for a single test case

        args variations: testcaseid - testcaseexternalid
                         buildid - buildname
                         platformid - platformname

        customfields : dictionary with customfields names + values
            VERY IMPORTANT: value must be formatted in the way it's written to db
        overwrite    : if present and true, then last execution for
                       (testcase,testplan,build,platform) will be overwritten.
        user : if present and user is a valid login (no other check will be done)
               it will be used when writing execution.
        execduration : Exec (min) as float (2.5 = 2min 30sec)
        timestamp    : 'YYYY-MM-DD hh:mm[:ss]'#
        steps        : [{'step_number' : 6, 'result' : 'p', 'notes" : 'a_note'},
                        {'step_number' : 7, 'result' : 'f', 'notes" : 'blabla'}]

>>> print tlc.whatArgs('uploadExecutionAttachment')
uploadExecutionAttachment(<attachmentfile>, <executionid>, <title>, <description>, [filename=<filename>], [filetype=<filetype>], [content=<content>], [devKey=<devKey>])
 Uploads an attachment for an execution

        executionid - execution ID

        mandatory non api args: attachmentfile
        - python file descriptor pointing to the file
        - or a valid file path

        default values for filename, filetype, content are determine from
        ATTACHMENTFILE, but user could overwrite it, if user want to store the
        attachment with a different name

>>>

 

>>> help(testlink.TestlinkAPIClient)
Help on class TestlinkAPIClient in module testlink.testlinkapi:

class TestlinkAPIClient(testlink.testlinkapigeneric.TestlinkAPIGeneric)
 |  client for XML-RPC communication between Python and TestLink
 |
 |  Inherits TestLink API methods from the generic client TestlinkAPIGeneric.
 |
 |  Defines Service Methods like "countProjects" and change the
 |  configuration for positional and optional arguments in a way, that often
 |  used arguments are positional.
 |  - see _changePositionalArgConfig()
 |  - configuration of positional arguments is consistent with v0.4.0
 |
 |  Changes on Service Methods like "countProjects" should be implemented in
 |  this class or sub classes
 |  Changes of TestLink API methods should be implemented in generic API
 |  TestlinkAPIGeneric.
 |
 |  Method resolution order:
 |      TestlinkAPIClient
 |      testlink.testlinkapigeneric.TestlinkAPIGeneric
 |      __builtin__.object
 |
 |  Methods defined here:
 |
 |  __init__(self, server_url, devKey, **kwargs)
 |      call super for init generell slots, init sepcial slots for teststeps
 |      and define special positional arg settings
 |
 |  appendStep(self, actions, expected_results, execution_type)
 |      appendStep :
 |      Appends a step to the steps list
 |
 |  copyTCnewTestCase(self, origTestCaseId, origVersion=None, **changedAttributes)
 |      creates a test case with values from test case ORIGTESTCASEID
 |
 |      ORIGVERSION specifies the test case version, which should be copied,
 |                  default is the max version number
 |
 |      if the new test case should differ from the original test case, changed
 |      api arguments could be defined as key value pairs.
 |      Example for changed test suite and importance:
 |      -  copyTCnewTestCaseVersion('4711', testsuiteid = '1007',
 |                                          importance = '1')
 |
 |      Remarks for some special keys:
 |      'testsuiteid': defines, in which test suite the TC-copy is inserted.
 |               Default is the same test suite as the original test case.
 |      'steps': must be a complete list of all steps, changed and unchanged steps
 |               Maybe its better to change the steps in a separat call using
 |               createTestCaseSteps with action='update'.
 |
 |  copyTCnewVersion(self, origTestCaseId, origVersion=None, **changedAttributes)
 |      creates a new version for test case ORIGTESTCASEID
 |
 |      ORIGVERSION specifies the test case version, which should be copied,
 |                  default is the max version number
 |
 |      if the new version should differ from the original test case, changed
 |      api arguments could be defined as key value pairs.
 |      Example for changed summary and importance:
 |      -  copyTCnewVersion('4711', summary = 'The summary has changed',
 |                                  importance = '1')
 |      Remarks for some special keys:
 |      'steps': must be a complete list of all steps, changed and unchanged steps
 |               Maybe its better to change the steps in a separat call using
 |               createTestCaseSteps with action='update'.
 |
 |  countBuilds(self)
 |      countBuilds :
 |      Count all the Builds
 |
 |  countPlatforms(self)
 |      countPlatforms :
 |      Count all the Platforms in TestPlans
 |
 |  countProjects(self)
 |      countProjects :
 |      Count all the test project
 |
 |  countTestCasesTP(self)
 |      countProjects :
 |      Count all the test cases linked to a Test Plan
 |
 |  countTestCasesTS(self)
 |      countProjects :
 |      Count all the test cases linked to a Test Suite
 |
 |  countTestPlans(self)
 |      countProjects :
 |      Count all the test plans
 |
 |  countTestSuites(self)
 |      countProjects :
 |      Count all the test suites
 |
 |  createTestCase(self, *argsPositional, **argsOptional)
 |      createTestCase: Create a test case
 |      positional args: testcasename, testsuiteid, testprojectid, authorlogin,
 |                       summary
 |      optional args : steps, preconditions, importance, executiontype, order,
 |                      internalid, checkduplicatedname, actiononduplicatedname,
 |                      status, estimatedexecduration
 |
 |      argument 'steps' will be set with values from .stepsList,
 |      - when argsOptional does not include a 'steps' item
 |      - .stepsList can be filled before call via .initStep() and .appendStep()
 |
 |      otherwise, optional arg 'steps' must be defined as a list with
 |      dictionaries , example
 |          [{'step_number' : 1, 'actions' : "action A" ,
 |              'expected_results' : "result A", 'execution_type' : 0},
 |               {'step_number' : 2, 'actions' : "action B" ,
 |              'expected_results' : "result B", 'execution_type' : 1},
 |               {'step_number' : 3, 'actions' : "action C" ,
 |              'expected_results' : "result C", 'execution_type' : 0}]
 |
 |  echo(self, message)
 |
 |  getProjectIDByName(self, projectName)
 |
 |  getProjectIDByNode(self, a_nodeid)
 |      returns project id , the nodeid belongs to.
 |
 |  getTestCaseByVersion(self, testCaseID, version=None)
 |      Gets testcase information based on the version.
 |
 |      :param testCaseID: test case to search for
 |      :param version: version to search for defaults to None. None searches for latest
 |      :return: test case info dictionary
 |
 |  getTestCaseIDByName(self, *argsPositional, **argsOptional)
 |      getTestCaseIDByName : Find a test case by its name
 |      positional args: testcasename,
 |      optional args : testsuitename, testprojectname, testcasepathname
 |
 |      testcasepathname : Full test case path name,
 |              starts with test project name , pieces separator -> ::
 |
 |      server return can be a list or a dictionary
 |      - optional arg testprojectname seems to create a dictionary response
 |
 |      this methods customize the generic behaviour and converts a dictionary
 |      response into a list, so methods return will be always a list
 |
 |  initStep(self, actions, expected_results, execution_type)
 |      initStep :
 |      Initializes the list which stores the Steps of a Test Case to create
 |
 |  listKeywordsForTC(self, internal_or_external_tc_id)
 |      Returns list with keyword for a test case
 |      INTERNAL_OR_EXTERNAL_TC_ID defines
 |      - either the internal test case ID (8111 or '8111')
 |      - or the full external test case ID ('NPROAPI-2')
 |
 |      Attention:
 |      - the tcversion_id is not supported
 |      - it is not possible to ask for a special test case version, cause TL
 |        links keywords against a test case and not a test case version
 |
 |  listKeywordsForTS(self, internal_ts_id)
 |      Returns dictionary with keyword lists for all test cases of
 |      test suite with id == INTERNAL_TS_ID
 |
 |  listProjects(self)
 |      listProjects :
 |      Lists the Projects (display Name & ID)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  stepsList
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __author__ = 'Luiko Czub, Olivier Renault, James Stock, TestLink-API-P...
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from testlink.testlinkapigeneric.TestlinkAPIGeneric:
 |
 |  __str__(self)
 |
 |  about(self)
 |      Gives basic information about the API
 |
 |  addPlatformToTestPlan(self, *argsPositional, **argsOptional)
 |      Adds a platform to a test plan
 |
 |  addTestCaseKeywords(self, *argsPositional, **argsOptional)
 |      adds list of keywords to a set of test cases
 |
 |      expects as arg <keywords> a dictionary with
 |        <testcaseexternalid> as a key and <list of keywords> as value
 |
 |      example:
 |        {'TC-4711' : ['KeyWord02'], 'TC-4712' : ['KeyWord01', KeyWord03']}
 |
 |        adds to test case 'TC-4711' the keyword 'KeyWord02'
 |        adds to test case 'TC-4712' the keywords 'KeyWord01' + KeyWord03'
 |
 |  addTestCaseToTestPlan(self, *argsPositional, **argsOptional)
 |      Add a test case version to a test plan
 |
 |  assignRequirements(self, *argsPositional, **argsOptional)
 |      Assign Requirements to a test case
 |      It is possible to assign multiple requirements, belonging to different
 |      requirement specifications. (the internal IDs must be known!)
 |
 |      Argument REQUIREMENTS expects an array of dictionaries, example:
 |      .assignRequirements('GPROAPI4-2', 6652,
 |                         [{'req_spec' : 6729, 'requirements' : [6731]},
 |                          {'req_spec' : 6733, 'requirements' : [6735, 6737]}])
 |      This would assign to testcase 'GPROAPI4-2' (in testproject with id 6652)
 |      a) requirement with ID 6731 of requirement spec 6729 AND
 |      b) requirements with ID 6735 and 6737 of requirement spec 6733
 |
 |  assignTestCaseExecutionTask(self, *argsPositional, **argsOptional)
 |      assigns a user to a test case execution task
 |
 |      user                 login name => tester
 |      testplanid           test plan id
 |      testcaseexternalid   format PREFIX-NUMBER
 |
 |      args variations:     buildid - buildname
 |                           platformid - platformname
 |      build information is general mandatory
 |      platform information is required, when test plan has assigned platforms
 |
 |  callServerWithPosArgs(self, methodNameAPI, *argsPositional, **argsOptional)
 |      concat argsPositional and argsOptional before calling
 |      server method methodNameAPI
 |
 |  checkDevKey(self, *argsPositional, **argsOptional)
 |      check if Developer Key exists
 |      returns true if everything OK, otherwise error structure
 |
 |  connectionInfo(self)
 |      print current SERVER URL and DEVKEY settings and servers VERSION
 |
 |  createBuild(self, *argsPositional, **argsOptional)
 |      Creates a new build for a specific test plan
 |
 |      active      : 1 (default) = activ  0 = inactiv
 |      open        : 1 (default) = open   0 = closed
 |      releasedate : YYYY-MM-DD
 |      copytestersfrombuild : valid buildid tester assignments will be copied.
 |
 |  createPlatform(self, *argsPositional, **argsOptional)
 |      Creates a platform for test project
 |
 |  createTestCaseSteps(self, *argsPositional, **argsOptional)
 |      creates new test steps or updates existing test steps
 |
 |      action - possible values: 'create','update','push'
 |          create: if step exist NOTHING WILL BE DONE
 |          update: if step DOES NOT EXIST will be created else will be updated.
 |          push: NOT IMPLEMENTED YET (TL 1.9.9)
 |                shift down all steps with step number >= step number provided
 |                and use provided data to create step number requested.
 |      steps - each element is a hash with following keys
 |          step_number,actions,expected_results,execution_type
 |      args variations: testcaseid - testcaseexternalid
 |      version - optional if not provided LAST ACTIVE version will be used
 |                if all versions are INACTIVE, then latest version will be used.
 |
 |  createTestPlan(self, *argsPositional, **argsOptional)
 |      create a test plan
 |
 |      args variations: testprojectname - prefix
 |
 |      supports also pre 1.9.14 arg definition, where 'testprojectname'
 |      was mandatory ('prefix' comes as alternative with 1.9.14)
 |
 |      examples:
 |      - createTestPlan('aTPlanName', 'aTProjectName')
 |      - createTestPlan('aTPlanName', testprojectname='aTProjectName')
 |      - createTestPlan('aTPlanName', prefix='aTProjectPrefix')
 |
 |  createTestProject(self, *argsPositional, **argsOptional)
 |      Create a test project
 |
 |      options : dictionary with keys
 |                  requirementsEnabled, testPriorityEnabled,
 |                  automationEnabled,inventoryEnabled
 |               and values 0 (false) and 1 (true)
 |
 |  createTestSuite(self, *argsPositional, **argsOptional)
 |      create a test suite
 |
 |  deleteExecution(self, *argsPositional, **argsOptional)
 |      delete an execution
 |
 |      Default TL server configuration does not allow deletion of exections
 |      see Installation & Configuration Manual Version 1.9
 |          chap. 5.8. Test execution settings
 |          $tlCfg->exec_cfg->can_delete_execution
 |
 |  deleteTestCaseSteps(self, *argsPositional, **argsOptional)
 |      deletes test cases steps
 |
 |      steps - each element is a step_number
 |      version - optional if not provided LAST ACTIVE version will be used
 |
 |  deleteTestPlan(self, *argsPositional, **argsOptional)
 |      Delete a test plan and all related link to other items
 |
 |  deleteTestProject(self, *argsPositional, **argsOptional)
 |      Delete a test project and all related link to other items
 |
 |  doesUserExist(self, *argsPositional, **argsOptional)
 |      Checks if user name exists
 |      returns true if everything OK, otherwise error structure
 |
 |  getAllExecutionsResults(self, *argsPositional, **argsOptional)
 |      Gets ALL EXECUTIONS for a particular testcase on a test plan.
 |          If there are no filter criteria regarding platform and build,
 |          result will be get WITHOUT checking for a particular platform and build.
 |
 |      mandatory arg: testplanid - identifies the test plan
 |
 |      mandatory args variations: testcaseid - testcaseexternalid
 |      - test case information is general mandatory
 |
 |      optional args:  buildid
 |                      platformid
 |
 |      options : dictionary with key 'getBugs' and
 |                                values 0 (false = default) or 1 (true)
 |
 |  getBuildsForTestPlan(self, *argsPositional, **argsOptional)
 |      Gets a list of builds within a test plan
 |
 |      returns an empty list, if no build is assigned
 |
 |  getExecCountersByBuild(self, *argsPositional, **argsOptional)
 |      Gets execution metrics information for a testplan
 |
 |  getExecutionSet(self, *argsPositional, **argsOptional)
 |      Gets a set of EXECUTIONS for a particular testcase on a test plan.
 |          If there are no filter criteria regarding platform and build, result
 |          will be get WITHOUT checking for a particular platform and build.
 |
 |      mandatory arg: testplanid - identifies the test plan
 |
 |      mandatory args variations: testcaseid - testcaseexternalid
 |      - test case information is general mandatory
 |
 |      optional args variations:  buildid - buildname
 |                                 platformid - platformname
 |
 |      options : dictionary with key 'getOrderDescending' and
 |                                values 0 (false = default) or 1 (true)
 |
 |  getFirstLevelTestSuitesForTestProject(self, *argsPositional, **argsOptional)
 |      get set of test suites AT TOP LEVEL of tree on a Test Project
 |
 |      returns an empty list, if no suite is assigned (api error 7008)
 |      - details see comments for decoMakerApiCallReplaceTLResponseError
 |
 |  getFullPath(self, *argsPositional, **argsOptional)
 |      Gets full path from the given node till the top using nodes_hierarchy_table
 |
 |      nodeid = can be just a single id or a list with ids
 |               ATTENTION: id must be an integer.
 |
 |  getIssueTrackerSystem(self, *argsPositional, **argsOptional)
 |      Get Issue Tracker System by name
 |
 |  getLastExecutionResult(self, *argsPositional, **argsOptional)
 |      Gets the result of LAST EXECUTION for a particular testcase on a test plan.
 |      If there are no filter criteria regarding platform and build,
 |      result will be get WITHOUT checking for a particular platform and build.
 |
 |      following optional arguments could only used with
 |      TL version >= 1.9.9
 |      - platformid, platformname, buildid, buildname
 |
 |      TL version >= 1.9.11
 |      - options : dictionary with key value pair
 |                          'getBugs' : True / False
 |
 |  getLatestBuildForTestPlan(self, *argsPositional, **argsOptional)
 |      Gets the latest build by choosing the maximum build id for a specific test plan
 |
 |  getProjectKeywords(self, *argsPositional, **argsOptional)
 |      Gets a dictionary of valid keywords for a project
 |
 |      returns an empty dictionary, if no keywords are defined
 |
 |  getProjectPlatforms(self, *argsPositional, **argsOptional)
 |      Gets a dictionary of platforms for a project
 |
 |      returns an empty dictionary, if no platform is assigned
 |
 |  getProjectTestPlans(self, *argsPositional, **argsOptional)
 |      Gets a list of test plans within a project
 |
 |      returns an empty list, if no testplan is assigned
 |
 |  getProjects(self, *argsPositional, **argsOptional)
 |      Gets a list of all projects
 |
 |      returns an empty list, if no test project exist
 |
 |  getReqCoverage(self, *argsPositional, **argsOptional)
 |      Get requirement coverage.
 |          Retrieve the test cases associated to a requirement
 |
 |      mandatory arg:
 |          testprojectid    - identifies the test project
 |          requirementdocid - identifies the requirement
 |
 |  getReqSpecCustomFieldDesignValue(self, *argsPositional, **argsOptional)
 |      Gets a Custom Field of a Requirement Specification in Design Scope.
 |
 |  getRequirementCustomFieldDesignValue(self, *argsPositional, **argsOptional)
 |      Gets a Custom Field of a Requirement Specification in Design Scope.
 |
 |  getRequirements(self, *argsPositional, **argsOptional)
 |      Get requirements.
 |
 |      mandatory arg: testprojectid - identifies the test project
 |
 |      optional args: testplanid, platformid
 |
 |  getTestCase(self, *argsPositional, **argsOptional)
 |      get test case specification using external or internal id
 |
 |      attention - be careful with testcaseexternalid - it must include an '-'.
 |      otherwise TL (<=1.9.8) returns
 |      <ProtocolError for xmlrpc.php: 500 Internal Server Error>
 |
 |  getTestCaseAssignedTester(self, *argsPositional, **argsOptional)
 |      Gets the result of LAST EXECUTION for a particular testcase on a
 |      test plan.
 |
 |      testplanid           test plan id
 |      testcaseexternalid   format PREFIX-NUMBER
 |
 |      args variations:     buildid - buildname
 |                           platformid - platformname
 |      build information is general mandatory
 |      platform information is required, when test plan has assigned platforms
 |
 |  getTestCaseAttachments(self, *argsPositional, **argsOptional)
 |      Gets attachments for specified test case.
 |
 |      args variations: testcaseid - testcaseexternalid
 |
 |      version - optional, if not present, the latest test case version
 |                will be used
 |
 |      The attachment file content is Base64 encoded. To save the file to disk
 |      in client, Base64 decode the content and write file in binary mode.
 |
 |  getTestCaseBugs(self, *argsPositional, **argsOptional)
 |      Returns all bugs linked to a particular testcase on a test plan.
 |      If there are no filter criteria regarding platform and build,
 |      result will be get WITHOUT checking for a particular platform and build.
 |
 |
 |      testplanid       test plan id
 |
 |      args variations: testcaseid - testcaseexternalid  (mandatory!)
 |                       buildid - buildname
 |                       platformid - platformname
 |      test case information is general mandatory
 |
 |  getTestCaseCustomFieldDesignValue(self, *argsPositional, **argsOptional)
 |      Gets value of a Custom Field with scope='design' for a given Test case
 |
 |      details =  changes output information
 |          null or 'value' => just value
 |          'full' => a map with all custom field definition
 |                        plus value and internal test case id
 |          'simple' => value plus custom field name, label, and type (as code).
 |
 |      attention - be careful with testcaseexternalid - it must include an '-'.
 |      otherwise TL (<=1.9.8) returns
 |      <ProtocolError for xmlrpc.php: 500 Internal Server Error>
 |
 |  getTestCaseCustomFieldExecutionValue(self, *argsPositional, **argsOptional)
 |      Gets a Custom Field of a Test Case in Execution Scope.
 |
 |  getTestCaseCustomFieldTestPlanDesignValue(self, *argsPositional, **argsOptional)
 |      Gets a Custom Field of a Test Case in Test Plan Design Scope.
 |
 |  getTestCaseKeywords(self, *argsPositional, **argsOptional)
 |      Gets a dictionary of keywords for a given Test case
 |
 |      args variations: testcaseid - testcaseexternalid  (mandatoy!)
 |
 |      returns an empty dictionary, if no keywords are defined
 |
 |  getTestCasesForTestPlan(self, *argsPositional, **argsOptional)
 |      List test cases linked to a test plan
 |
 |      details - default is 'full',
 |                'simple', 'details' ??
 |
 |      args variations:     keywordid - keywords
 |
 |      returns an empty list, if no build is assigned
 |
 |  getTestCasesForTestSuite(self, *argsPositional, **argsOptional)
 |      List test cases within a test suite alphabetically
 |
 |      details - default is 'simple',
 |                use 'full' if you want to get summary,steps & expected_results
 |                or 'only_id', if you just need an ID list
 |
 |      deep - True/False - default is True
 |             if True, return also test case of child suites
 |
 |      getkeywords - True/False - default is False
 |             if True AND details='full', dictionary includes for each test
 |             case, which as assigned keywords, an additional key value pair
 |             'keywords'
 |
 |      returns an empty list, if no build is assigned
 |
 |  getTestPlanByName(self, *argsPositional, **argsOptional)
 |      Gets info about target test project
 |
 |  getTestPlanCustomFieldDesignValue(self, *argsPositional, **argsOptional)
 |      Gets a Custom Field of a Test Plan in Design Scope.
 |
 |  getTestPlanPlatforms(self, *argsPositional, **argsOptional)
 |      Returns the list of platforms associated to a given test plan
 |
 |      returns an empty list, if no platform is assigned (api error 3041)
 |      - details see comments for decoMakerApiCallReplaceTLResponseError
 |
 |  getTestProjectByName(self, *argsPositional, **argsOptional)
 |      Gets info about target test project
 |
 |  getTestSuite(self, *argsPositional, **argsOptional)
 |      Returns list with all test suites named TESTUITENAME defined for
 |      test project using PREFIX
 |
 |  getTestSuiteAttachments(self, *argsPositional, **argsOptional)
 |      Gets attachments for specified test suite.
 |      The attachment file content is Base64 encoded. To save the file to disk
 |      in client, Base64 decode the content and write file in binary mode.
 |
 |  getTestSuiteByID(self, *argsPositional, **argsOptional)
 |      Return a TestSuite by ID
 |
 |  getTestSuiteCustomFieldDesignValue(self, *argsPositional, **argsOptional)
 |      Gets a Custom Field of a Test Suite in Design Scope.
 |
 |  getTestSuitesForTestPlan(self, *argsPositional, **argsOptional)
 |      List test suites within a test plan alphabetically
 |
 |      returns an empty list, if no suite is assigned
 |
 |  getTestSuitesForTestSuite(self, *argsPositional, **argsOptional)
 |      get list of TestSuites which are DIRECT children of a given TestSuite
 |
 |      returns an empty list, if no TestSuite is assigned
 |
 |  getTotalsForTestPlan(self, *argsPositional, **argsOptional)
 |      Gets the summarized results grouped by platform.
 |
 |  getUserByID(self, *argsPositional, **argsOptional)
 |      returns user data for account with USERID in users table, column ID
 |
 |      * if everything ok returns an array on just one element with following user data
 |      *
 |      * firstName,lastName,emailAddress,locale,isActive,defaultTestprojectID,
 |      * globalRoleID
 |      * globalRole    array with role info
 |      * tprojectRoles array
 |      * tplanRoles    array
 |      * login
 |      * dbID
 |      * loginRegExp
 |      *
 |      * ATTENTION: userApiKey will be set to NULL, because is worst that access to user password
 |
 |  getUserByLogin(self, *argsPositional, **argsOptional)
 |      returns user data for account with login name USER
 |
 |          if everything ok returns an array on just one element with following user data
 |      *
 |      * firstName,lastName,emailAddress,locale,isActive,defaultTestprojectID,
 |      * globalRoleID
 |      * globalRole    array with role info
 |      * tprojectRoles array
 |      * tplanRoles    array
 |      * login
 |      * dbID
 |      * loginRegExp
 |      *
 |      * ATTENTION: userApiKey will be set to NULL, because is worst that access to user password
 |
 |  ping(self)
 |      alias for methodAPI sayHello
 |
 |  removePlatformFromTestPlan(self, *argsPositional, **argsOptional)
 |      Removes a platform from a test plan
 |
 |  removeTestCaseKeywords(self, *argsPositional, **argsOptional)
 |      removes list of keywords from a set of test cases
 |
 |      expects as arg <keywords> a dictionary with
 |        <testcaseexternalid> as a key and <list of keywords> as value
 |
 |      example:
 |        {'TC-4711' : ['KeyWord02'], 'TC-4712' : ['KeyWord01', KeyWord03']}
 |
 |        removes from test case 'TC-4711' the keyword 'KeyWord02'
 |        removes from test case 'TC-4712' the keywords 'KeyWord01' + KeyWord03'
 |
 |  repeat(self, *argsPositional, **argsOptional)
 |      Repeats a message back
 |
 |  reportTCResult(self, *argsPositional, **argsOptional)
 |      Reports a result for a single test case
 |
 |      args variations: testcaseid - testcaseexternalid
 |                       buildid - buildname
 |                       platformid - platformname
 |
 |      customfields : dictionary with customfields names + values
 |          VERY IMPORTANT: value must be formatted in the way it's written to db
 |      overwrite    : if present and true, then last execution for
 |                     (testcase,testplan,build,platform) will be overwritten.
 |      user : if present and user is a valid login (no other check will be done)
 |             it will be used when writing execution.
 |      execduration : Exec (min) as float (2.5 = 2min 30sec)
 |      timestamp    : 'YYYY-MM-DD hh:mm[:ss]'#
 |      steps        : [{'step_number' : 6, 'result' : 'p', 'notes" : 'a_note'},
 |                      {'step_number' : 7, 'result' : 'f', 'notes" : 'blabla'}]
 |
 |  sayHello(self)
 |      Lets you see if the server is up and running
 |
 |  setTestCaseExecutionType(self, *argsPositional, **argsOptional)
 |      Update execution type for a test case version
 |
 |      possible executiontype values
 |      1 = TESTCASE_EXECUTION_TYPE_MANUAL, 2 = TESTCASE_EXECUTION_TYPE_AUTO
 |
 |  setTestCaseTestSuite(self, *argsPositional, **argsOptional)
 |      move a test case to a different Test Suite
 |
 |      mandatory arg:
 |          testcaseexternalid - identifies the test case
 |          testsuiteid        - identifies the test suite
 |
 |  testLinkVersion(self)
 |      Returns the TestLink Version
 |      usable with TL>= 1.9.9 , returns '<= 1.9.8' for older versions
 |
 |  unassignTestCaseExecutionTask(self, *argsPositional, **argsOptional)
 |      assigns a user to a test case execution task
 |
 |      testplanid           test plan id
 |      testcaseexternalid   format PREFIX-NUMBER
 |
 |      args variations:     buildid - buildname
 |                           platformid - platformname
 |                           user (login name) - action ('unassignAll')
 |      build information is general mandatory
 |      platform information is required, when test plan has assigned platforms
 |      if action=='unassignAll', user information is not needed
 |      - otherwise, TL itself will set action to 'unassignOne' and expects a
 |        valid user information (login name => tester)
 |
 |  updateBuildCustomFieldsValues(self, *argsPositional, **argsOptional)
 |      Update value of Custom Field with scope='design' for a given Build
 |
 |      customfields  : dictionary with customfields names + values
 |      VERY IMPORTANT: value must be formatted in the way it's written to db
 |
 |  updateTestCase(self, *argsPositional, **argsOptional)
 |      Update an existing test case
 |
 |      steps     array - each element is a hash with following keys
 |                step_number,actions,expected_results,execution_type
 |      user      login name used as updater - optional
 |                if not provided will be set to user that request update
 |
 |      Not all test case attributes will be able to be updated using this method
 |
 |  updateTestCaseCustomFieldDesignValue(self, *argsPositional, **argsOptional)
 |      Update value of Custom Field with scope='design' for a given Test case
 |
 |      customfields : dictionary with customfields names + values
 |           VERY IMPORTANT: value must be formatted in the way it's written to db
 |
 |  updateTestSuite(self, *argsPositional, **argsOptional)
 |      update a test suite
 |
 |      mandatory arg: testsuiteid - identifies the test suite to be change
 |
 |      mandatory args variations: testprojectid or prefix
 |      - test project information is general mandatory
 |
 |      optional args:
 |      - testsuitename - if defined, test suite name will be changed
 |      - details       - if defined test suite details will be changed
 |      - order         - if defined, order inside parent container is changed
 |
 |  updateTestSuiteCustomFieldDesignValue(self, *argsPositional, **argsOptional)
 |      Update value of Custom Field with scope='design' for a given Test Suite
 |
 |      customfields  : dictionary with customfields names + values
 |      VERY IMPORTANT: value must be formatted in the way it's written to db
 |
 |  uploadAttachment(self, attachmentfile, *argsPositional, **argsOptional)
 |      Uploads an attachment for an execution
 |
 |      fkid    - The Attachment Foreign Key ID
 |      fktable - The Attachment Foreign Key Table
 |
 |      mandatory non api args: attachmentfile
 |      - python file descriptor pointing to the file
 |      - or a valid file path
 |
 |      default values for filename, filetype, content are determine from
 |      ATTACHMENTFILE, but user could overwrite it, if user want to store the
 |      attachment with a different name
 |
 |  uploadExecutionAttachment(self, attachmentfile, *argsPositional, **argsOptional)
 |      Uploads an attachment for an execution
 |
 |      executionid - execution ID
 |
 |      mandatory non api args: attachmentfile
 |      - python file descriptor pointing to the file
 |      - or a valid file path
 |
 |      default values for filename, filetype, content are determine from
 |      ATTACHMENTFILE, but user could overwrite it, if user want to store the
 |      attachment with a different name
 |
 |  uploadRequirementAttachment(self, attachmentfile, *argsPositional, **argsOptional)
 |      Uploads an attachment for a Requirement.
 |
 |      requirementid - The Requirement ID
 |
 |      mandatory non api args: attachmentfile
 |      - python file descriptor pointing to the file
 |      - or a valid file path
 |
 |      default values for filename, filetype, content are determine from
 |      ATTACHMENTFILE, but user could overwrite it, if user want to store the
 |      attachment with a different name
 |
 |  uploadRequirementSpecificationAttachment(self, attachmentfile, *argsPositional, **argsOptional)
 |      Uploads an attachment for a Requirement Specification.
 |
 |      reqspecid - The Requirement Specification ID
 |
 |      mandatory non api args: attachmentfile
 |      - python file descriptor pointing to the file
 |      - or a valid file path
 |
 |      default values for filename, filetype, content are determine from
 |      ATTACHMENTFILE, but user could overwrite it, if user want to store the
 |      attachment with a different name
 |
 |  uploadTestCaseAttachment(self, attachmentfile, *argsPositional, **argsOptional)
 |      Uploads an attachment for a Test Case.
 |
 |      testcaseid - Test Case INTERNAL ID
 |      version    - Test Case version number
 |
 |      mandatory non api args: attachmentfile
 |      - python file descriptor pointing to the file
 |      - or a valid file path
 |
 |      default values for filename, filetype, content are determine from
 |      ATTACHMENTFILE, but user could overwrite it, if user want to store the
 |      attachment with a different name
 |
 |  uploadTestProjectAttachment(self, attachmentfile, *argsPositional, **argsOptional)
 |      Uploads an attachment for a Test Project.
 |
 |      testprojectid - The Test Project ID
 |
 |      mandatory non api args: attachmentfile
 |      - python file descriptor pointing to the file
 |      - or a valid file path
 |
 |      default values for filename, filetype, content are determine from
 |      ATTACHMENTFILE, but user could overwrite it, if user want to store the
 |      attachment with a different name
 |
 |  uploadTestSuiteAttachment(self, attachmentfile, *argsPositional, **argsOptional)
 |      Uploads an attachment for a Test Suite.
 |
 |      testsuiteid - The Test Suite ID
 |
 |      mandatory non api args: attachmentfile
 |      - python file descriptor pointing to the file
 |      - or a valid file path
 |
 |      default values for filename, filetype, content are determine from
 |      ATTACHMENTFILE, but user could overwrite it, if user want to store the
 |      attachment with a different name
 |
 |  whatArgs(self, methodNameAPI)
 |      returns for METHODNAME a description with
 |      - positional, optional and other (non api) mandatory args
 |      - methods doc/help string
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from testlink.testlinkapigeneric.TestlinkAPIGeneric:
 |
 |  devKey
 |
 |  server
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from testlink.testlinkapigeneric.TestlinkAPIGeneric:
 |
 |  __version__ = '0.8.1'

 

posted on 2020-09-16 14:44  swee632  阅读(832)  评论(0编辑  收藏  举报

导航