Exemplo n.º 1
0
def _getMethodsArgDefinition(methodName):
    """ returns argument definition for api methodName """

    try:
        return _apiMethodsArgs[methodName]
    except KeyError:
        raise TLArgError('apiMethod %s not registered!' % methodName)
Exemplo n.º 2
0
    def _generate_testplanid(self):
        """This won't necessarily be able to create a testplanid. It requires a planname and projectname."""
        if 'testplanname' not in self:
            raise TLArgError("Need testplanname to generate a testplan for results.")

        tp = self.tls.createTestPlan(self['testplanname'], self.testprojectname,
                                     notes=self.testplannotes)
        self['testplanid'] = tp[0]['id']
        return self['testplanid']
Exemplo n.º 3
0
 def getPlatformID(self, platformname, _firstrun=True):
     """
     This is hardcoded for platformname to always be self.platformname
     """
     platforms = self.tls.getTestPlanPlatforms(self.testplanid)
     for platform in platforms:
         # https://github.com/Brian-Williams/TestLink-API-Python-client/issues/1
         if platform['name'].lower() == platformname.lower():
             return platform['id']
     # Platformname houses platform creation as platform creation w/o a name isn't possible
     if not self.platformname:
         raise TLArgError(
             "Couldn't find platformid for {}.{}, "
             "please provide a platformname to generate.".format(self.testplanid, self.platformname)
         )
     if _firstrun is True:
         return self.getPlatformID(self.platformname, _firstrun=False)
     else:
         raise TLArgError("PlatformID not found after generated from platformname '{}' "
                          "in test plan {}.".format(self.platformname, self.testplanid))
 def getPlatformID(self, platformname, _firstrun=True):
     """
     This is hardcoded for platformname to always be self.platformname
     """
     platforms = self.tls.getTestPlanPlatforms(self.testplanid)
     for platform in platforms:
         if platform['name'] == platformname:
             return platform['id']
     # Platformname houses platform creation as platform creation w/o a name isn't possible
     if not self.platformname:
         raise TLArgError(
             "Couldn't find platformid for {}.{}, "
             "please provide a platformname to generate.".format(
                 self.testplanid, platformname))
     if _firstrun is True:
         return self.getPlatformID(self.platformname, _firstrun=False)
     else:
         raise TLArgError(
             "PlatformID not found after generated from platformname '{}' "
             "in test plan {}.".format(self.platformname, self.testplanid))
Exemplo n.º 5
0
def registerMethod(methodName,
                   apiArgsPositional=[],
                   apiArgsOptional=[],
                   otherArgsMandatory=[]):
    """ extend _apiMethodsArgs with a new definition structure for METHODNAME

        definitions structure is
        key(apiMethodeName) = ( [default positional apiArgs], [all apiArgs], 
                                 [other mandatory non api Args] )
       [all apiArgs] includes all positional and optional args without other 
       mandatory Args  """

    if methodName in _apiMethodsArgs:
        raise TLArgError('apiMethod %s already registered!' % methodName)

    allArgs = apiArgsPositional[:]
    for argName in apiArgsOptional:
        if not argName in allArgs:
            allArgs.append(argName)
    _apiMethodsArgs[methodName] = (apiArgsPositional[:], allArgs,
                                   otherArgsMandatory[:])
Exemplo n.º 6
0
 def createTestCase(self, *argsPositional, **argsOptional):
     """ createTestCase: Create a test case
     positional args: testcasename, testsuiteid, testprojectid, authorlogin,
                      summary
     optional args : preconditions, importance, execution, order, internalid,
                     checkduplicatedname, actiononduplicatedname
                     
     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()
     """ 
     
     # store current stepsList as argument 'steps', when argsOptional defines
     # no own 'steps' item
     if self.stepsList:
         if argsOptional.has_key('steps'):
             raise TLArgError('confusing createTestCase arguments - ' +
                              '.stepsList and method args define steps')
         argsOptional['steps'] = self.stepsList
         self.stepsList = []
     return super(TestlinkAPIClient, self).createTestCase(*argsPositional, 
                                                          **argsOptional)