示例#1
0
 def batchRunCases(self,taskID,cases):    # need use with zentaos - ext testtask
     orderedDict=OrderedDict()
     orderedDict['taskID']=taskID
     res=requests.post(url='{}?{}'.format(self.endpoint,util.super_model_pack('testtask','extBatchRun',orderedDict)),data=cases,headers=self.cookie)
     if str(res.status_code).startswith('2'):
         return res.content.decode()
     return None
示例#2
0
 def unlink_test_case(self,taskID,caseID,rowID=None):   # need use with zentaos - ext testtask
     if rowID is None:
         orderedDict=OrderedDict()
         orderedDict.__setitem__('taskID',taskID)
         orderedDict.__setitem__('caseID',caseID)
         res=requests.get(url='{}?{}'.format(self.endpoint, util.super_model_pack(self.module_name, 'extUnlinkCase', orderedDict)), headers=self.cookie)
     else:
         res=requests.get(url=self.endpoint,params={'caseID':rowID,'m':self.module_name,'f':'unlinkCase','confirm':'yes','t':'json'},headers=self.cookie)
     if str(res.status_code).startswith('2'):
         return json.loads(res.content.decode())
     return None
示例#3
0
 def get_products(self):
      res=requests.get(url='{}?{}'.format(self.endpoint,util.super_model_pack(self.module_name,'getList')),headers=self.cookie)
      result=None
      if str(res.status_code).startswith('2'):
         try:
           content=json.loads(res.content.decode())
           if content.get('status')=='success':
               data=json.loads(content.get('data'))
               result={data[k]['code']:k for k in data.keys()}
         except Exception as e:
             logging.error(e.__traceback__)
      return result
示例#4
0
 def get_test_cases_by_productId(self,productId,**kwargs):
      res=requests.get(url='{}?{}'.format(self.endpoint,util.super_model_pack(self.module_name,'getModuleCases',{'productID':productId})),headers=self.cookie)
      result=None
      if str(res.status_code).startswith('2'):
         try:
             content=json.loads(res.content.decode())
             if content.get('status')=='success':
                 result=json.loads(content.get('data'))
                 if len(kwargs)>0:
                     result={k:result.get(k) for k in result.keys() if util.filter(result.get(k),**kwargs)}
         except Exception as e:
             logging.error(e.__traceback__)
      return result
示例#5
0
 def get_builds_by_project(self,projectID):
      orderedDict=OrderedDict()
      orderedDict.__setitem__('projectID',projectID)
      res=requests.get(url='{}?{}'.format(self.endpoint,util.super_model_pack('build','getProjectBuilds',orderedDict)),headers=self.cookie)
      result=None
      if str(res.status_code).startswith('2'):
          try:
              content=json.loads(res.content.decode())
              if content.get('status')=='success':
                  result=json.loads(content.get('data'))
          except Exception as e:
              logging.error(e.__traceback__)
      return result
示例#6
0
 def get_test_task_by_productId(self,productId,**kwargs):
      result=None
      orderDict=OrderedDict()
      orderDict.__setitem__('productID',productId)
      res=requests.get(url='{}?{}'.format(self.endpoint, util.super_model_pack(self.module_name, 'getProductTasks', orderDict)), headers=self.cookie)
      if str(res.status_code).startswith('2'):
          try:
              content=json.loads(res.content.decode())
              if content.get('status')=='success':
                 result=json.loads(content.get('data'))
          except Exception as e:
              logging.error(e.__traceback__)
      return result
示例#7
0
 def batch_get_test_cases(self,cases):
     '''
     :param cases: json type cases id : version   example: cases = { 'cases[case_id]':case_version , ...... }
     :return: json cases info, if version = 0 , get latest version of the cases , else get spec. version of the cases
     '''
     res=requests.post(url='{}?{}'.format(self.endpoint,util.super_model_pack(self.module_name,'extBatchGetById')),data=cases,headers=self.cookie)
     result=None
     if str(res.status_code).startswith('2'):
         try:
             content=json.loads(res.content.decode())
             if content.get('status')=='success':
                  result=json.loads(content.get('data'))
         except Exception as e:
             logging.error(e.__traceback__)
     return result
示例#8
0
 def get_project_build_pairs(self,projectID,productID,branch=None,params=None):
      orderedDict=OrderedDict()
      orderedDict.__setitem__('projectID',projectID)
      orderedDict.__setitem__('productID',productID)
      if branch:
          orderedDict.__setitem__('branch',branch)
      if params:
          orderedDict.__setitem__('params',params)
      res=requests.get(url='{}?{}'.format(self.endpoint,util.super_model_pack(self.module_name,'getProjectBuildPairs',orderedDict)),headers=self.cookie)
      result=None
      if str(res.status_code).startswith('2'):
          try:
              content=json.loads(res.content.decode())
              if content.get('status')=='success':
                  result=json.loads(content.get('data'))
          except Exception as e:
              logging.error(e.__traceback__)
      return result
示例#9
0
 def get_test_case_by_id(self,id,version=0):
       '''
       :param id: case id
       :param version: case version
       :return: json case info, if version = 0 , get latest version of the case , else get spec. version of the case
       '''
       orderDict=OrderedDict()
       orderDict.__setitem__('caseID',id)
       orderDict.__setitem__('version',version)
       result=None
       res=requests.get(url='{}?{}'.format(self.endpoint,util.super_model_pack(self.module_name,'getById',orderDict)),headers=self.cookie)
       if str(res.status_code).startswith('2'):
           try:
               content=json.loads(res.content.decode())
               if content.get('status')=='success':
                    result=json.loads(content.get('data'))
           except Exception as e:
               logging.error(e.__traceback__)
       return result
示例#10
0
 def get_projects(self, status, limit=0, productID=0, branch=0):
     STATUS = ["all", "undone", "wait", "running"]
     if not status in STATUS:
         return None
     orderedDict = OrderedDict()
     orderedDict.__setitem__("status", status)
     orderedDict.__setitem__("limit", limit)
     orderedDict.__setitem__("productID", productID)
     orderedDict.__setitem__("branch", branch)
     res = requests.get(
         url="{}?{}".format(self.endpoint, util.super_model_pack(self.module_name, "getList", orderedDict)),
         headers=self.cookie,
     )
     result = None
     if str(res.status_code).startswith("2"):
         try:
             content = json.loads(res.content.decode())
             if content.get("status") == "success":
                 data = json.loads(content.get("data"))
                 result = {key: data.get(key).get("name") for key in data.keys()}
         except Exception as e:
             logging.error(e.__traceback__)
     return result