Example #1
0
 def __init__(self,path):
     self._name=None
     self.path=path
     self._header=None
     self.prop=Properties.getProperties()
     self._content=None
     self._dict_content=None
 def setUpClass(cls):
     prop=Properties.getProperties()
     prop.set('zentaos.host', 'localhost')
     prop.set('zentaos.port', '7086')
     prop.set('zentaos.user','jenkins')
     prop.set('zentaos.pwd','jenkins')
     cls.suite_data=ZentaosDataMapper.Test_Suite_Data()
def requestBuilder(data):
    prop=Properties.getProperties()
    if isinstance(data,dict):
      try:
        req=APIRequest()
        if IS_FULL_URL(data['requestPath'].strip()):
           req.url=data['requestPath'].strip()
        else:
           req.url='{}{}'.format(_url(prop.get('tomcat.host'),prop.get('tomcat.port')),data['requestPath'].strip())
        if str(data.get('requestMethod')).upper() in METHODS:
           req.method=data['requestMethod']
        else:
           req.method=DEFUALT_METHOD
        if data.get('requestParameters'):
            if data.get('requestParameters')!='':req.params=Utils.to_json(data['requestParameters'].strip())
        if data.get('requestBody'):
            if data.get('requestBody')!='':req.data=Utils.to_json(data['requestBody'].strip())
        if data.get('requestJson'):
            if data.get('requestJson')!='':req.json=Utils.to_json(data['requestJson'].strip())
        if data.get('requestHeader'):
            if data.get('requestHeader')!='':req.headers=Utils.to_json(data['requestHeader'].strip())
        if data.get('keywords'):
            if 'needUserToken:Y'.upper() in data.get('keywords').upper():
               if 'mogoroom-partner' in data['requestPath'] and not prop.get('status.partner'):
                    if req.data:
                        for key,value in prop.get('partner.token').items():
                            req.data[key]=value
                    else:
                        req.data=prop.get('partner.token')
        return req.prepare()
      except:
        raise ValueError("Worng args. for build HTTP request.")
Example #4
0
 def __init__(self,data,exec_time):
     # self._suite=None
     self.exec_time=exec_time
     self.data=data
     self._split_data=None
     self._status=None
     self.prop=Properties.getProperties()
     self._module_set=None
 def setUpClass(cls):
     property = Properties.getProperties()
     # property.set('zentaos.host', '192.168.30.45')
     # property.set('zentaos.port', '36654')
     # property.set('zentaos.user','jenkins')
     # property.set('zentaos.pwd','jenkins')
     property.set('zentaos.host', '192.168.60.60')
     property.set('zentaos.port', '7086')
     property.set('zentaos.user','jenkins')
     property.set('zentaos.pwd','jenkins')
     cls.client = ZentaosClient.ZentaosClient()
 def test_reporter(self):
     prop = Properties.getProperties()
     prop.set("test.host", "192.168.30.45")
     prop.set("test.port", "38811")
     prop.set("jenkins.port", "8080")
     prop.set("jenkins.host", "192.168.30.45")
     data = []
     for case_id in self.client.get_cases_by_suite("API_Test_Suite_129"):
         data.append(self.client.get_case_by_id(case_id))
     analy = analysis.result_analysis(data=data, exec_time="Sun Oct 25 23:59:25 2015")
     report = Reporter.HtmlReporter(anaylsis=analy, std_out=logging)
     report.save()
 def setUpClass(cls):
     property = Properties.getProperties()
     # property.set('zentaos.host', '192.168.30.45')
     # property.set('zentaos.port', '36654')
     # property.set('zentaos.user','jenkins')
     # property.set('zentaos.pwd','jenkins')
     # property.set('zentaos.host', '192.168.60.60')
     property.set('zentaos.host', 'localhost')
     property.set('zentaos.port', '7086')
     property.set('zentaos.user','jenkins')
     property.set('zentaos.pwd','jenkins')
     cls.m=model.Model()
 def _setup(self,sql_list):
     prop=Properties.getProperties()
     if prop.get('mysql.connection_pool') is None:
         prop.set('mysql.connection_pool',schema.DataBaseConnectionPool(connection_url=prop.get('test.mysqlquery')))
     connection=None
     try:
        connection=prop.get('mysql.connection_pool').get_connection()
        for _sql in sql_list:
            prop.get('mysql.connection_pool').execute(connection,_sql)
        connection.commit()
     except Exception as e:
            connection.rollback()
            raise e
     finally:
            if connection:connection.close()
Example #9
0
def _get_file_list(path_list):
  partnerPath=Properties.getProperties().get('test.datafolder')
  file_list=[]
  if path_list is None:
      file_list.extend(_walk_file(partnerPath))
  else:
      for path in path_list:
        filePath='{}/{}'.format(partnerPath,path)
        if os.path.exists(filePath):
          if os.path.isdir(filePath):
             file_list.extend(_walk_file(filePath))
          else:
             file_list.append(filePath)
        else:
            logging.error('File/folder [{}] is not existing,please check [{}] folder or upload the file.'.format(filePath,partnerPath))
  return file_list
Example #10
0
def app(*args,product_to_test,test_port=None,test_module=None,thread_number=5,save_to_db=False,generate_html_report=False,
        case_to_run=None,environment_check=True,report_path=None,update_zentaos=None):
    _property=Properties.getProperties(file='property.properties'.format(test_port))
    _property.set('test.update_zentaos',update_zentaos)
    if not test_port is None:
        _property.set('test.port',test_port)
    _property.set('test.host',args[0])
    _property.set('test.project',args[1])
    if not test_module is None:
        _property.set('test.module',test_module.split(','))
    if not report_path is None:
        _property.set('test.report_path',report_path)
    if not product_to_test is None and product_to_test!='':
        _property.set('test.product_to_test',product_to_test.split(','))
    _property.set('test.thread_number',int(thread_number))
    _property.set('test.generate_html_report',generate_html_report)
    if not case_to_run is None and case_to_run!='':
        _property.set('test.case_to_run',case_to_run.split(','))
    _property.set('test.environment_check',environment_check)
    program(_property).run()
Example #11
0
def sqlValidate(self,response,execpted):
    prop=Properties.getProperties()
    if prop.get('mysql.connection_pool') is None:
        prop.set('mysql.connection_pool',schema.DataBaseConnectionPool(connection_url=prop.get('test.mysqlquery')))
    if execpted.get('sql_validation'):
      if execpted.get('sql_validation') != '':
       connection=None
       try:
         sqlList=eval(execpted.get('sql_validation').strip())
         connection=prop.get('mysql.connection_pool').get_connection()
         for execptDict in sqlList:
             actualDict=prop.get('mysql.connection_pool').execute(connection,execptDict['query'])
             if len(actualDict)!=1:
                 self.assertTrue(False,msg='Query [{}] expect one result,but return several,please check your query and results.'.format(execptDict['query']))
             actualDict=actualDict[0]
             for key in execptDict.keys():
                 if key !='query':
                     self.assertEqual(str(execptDict[key]).strip(),str(actualDict[key]).strip(),msg='Query:[{}],execpted result of [{}] is {},but actual result is {}.'.format(execptDict['query'],key,str(execptDict[key]).strip(),str(actualDict[key]).strip()))
       except Exception as e:
           raise e
       finally:
         if connection:connection.close()
Example #12
0
 def __init__(self,data):
     self.data=data
     self.prop=Properties.getProperties()
     self._run_queue=None
     self._file_set=None
Example #13
0
 def config(self):
     if not self._config:
         self._config=Properties.getProperties()
     return self._config
Example #14
0
 def __init__(self,client=None,suite_id=None,data=None,content=None):
     self._suite_id=suite_id
     self._client=client
     self._cases=data
     self._content=content
     self.prop=Properties.getProperties()
 def __init__(self):
       self._default_account=None
       self.prop=Properties.getProperties()
 def __init__(self):
     self.prop=Properties.getProperties()
     self._cookie=None
     self._url=None
     self._isLogin=None
 def setUpClass(cls):
      prop=Properties.getProperties()
      prop.set('test.fileformat','.csv')
      prop.set('test.datafolder','../DataFolder')
      cls.prop=prop
Example #18
0
def _format_match(path):
    formatList=Properties.getProperties().get('test.fileformat').split(',')
    preffix,suffix=os.path.splitext(path)
    return suffix in formatList
Example #19
0
def _walk_file(path):
    file_list=[]
    for dir,dirpath,file in os.walk(path):
          for name in file:
             if _format_match(name):
                file_list.append(os.path.join(dir,name))
             else:
                logging.error('File [{}] suffix name mismatch,currently only [{}] file is supported as data source file.'.format(name,Properties.getProperties().get('test.fileformat')))
    return file_list
Example #20
0
 def __init__(self,anaylsis,std_out):
     self.prop=Properties.getProperties()
     self.std_out=std_out
     self.anaylsis=anaylsis
Example #21
0
 def __init__(self):
         self.prop=Properties.getProperties()
         self._suites=None
 def __init__(self):
       self._default_account=None
       self.name='partner'
       self.prop=Properties.getProperties()