def __readConfig(path): p = Properties() p.load(path) for kv in p.list(): key = __toHump(kv[0]) value = kv[1] print 'read config',key,value globals()[key] = value
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 __init__(self,path): self._name=None self.path=path self._header=None self.prop=Properties.getProperties() self._content=None self._dict_content=None
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.")
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 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 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 _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()
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
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()
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()
'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'mysite.wsgi.application' # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases from utils import Properties dbProperties = Properties("db.properties").getProperties() DATABASES = { 'default': { 'ENGINE': dbProperties['mysql']['engine'], 'NAME': dbProperties['mysql']['name'], 'USER': dbProperties['mysql']['user'], 'PASSWORD': dbProperties['mysql']['password'], 'HOST': dbProperties['mysql']['host'], 'PORT': dbProperties['mysql']['port'], } } # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us'
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 __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 _format_match(path): formatList=Properties.getProperties().get('test.fileformat').split(',') preffix,suffix=os.path.splitext(path) return suffix in formatList
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
cookies['pgv_pvi'] = '6435798016' cookies['CXID'] = 'A84044F23F0795CB5C8AE198BE21C454' cookies['browser_width'] = '1349' cookies['browser_height'] = '643' cookies['IPLOC'] = 'CN6101' cookies['ABTEST'] = '0|1435634810|v1' cookies['weixinIndexVisited'] = '1' cookies['_ga'] = 'GA1.2.1719920014.1435720096' cookies['ld'] = 'z6VUIkllll2qALdMlllllVQ6YlUlllllNvREDkllll9lllllRAoll5@@@@@@@@@@' cookies['PHPSESSID'] = '4b5vlhjli7t88upl3dcatj69b5' cookies['SUIR'] = '526480D59FA58524CEAA48DBA0AEB407' cookies['SNUID'] = '222AF1A4D0D4CB00EF6EB117D16E77B8' cookies['sct'] = '25' cookies['LSTMV'] = '619%2C75' cookies['LCLKINT'] = '5427' keywordDic = properties.initPropers('./keyword') url = 'http://weixin.sogou.com/weixin' client = MongoClient('42.96.141.125',27017) db = client.testdb collections = db.collection_names() # for col in collections: # print col, '\'s count is', db[col].count() for k, v in keywordDic.items(): if k in collections: print 'skip ', k continue queryStr = {} queryStr['query'] = v for x in xrange(1, 11): queryStr['page'] = x r = requests.get(url, params = queryStr, headers = headers, cookies = cookies)
def setUpClass(cls): prop=Properties.getProperties() prop.set('test.fileformat','.csv') prop.set('test.datafolder','../DataFolder') cls.prop=prop
def config(self): if not self._config: self._config=Properties.getProperties() return self._config
def __init__(self): self._default_account=None self.name='partner' self.prop=Properties.getProperties()
def __init__(self,anaylsis,std_out): self.prop=Properties.getProperties() self.std_out=std_out self.anaylsis=anaylsis
def __init__(self,data): self.data=data self.prop=Properties.getProperties() self._run_queue=None self._file_set=None
def __init__(self): self.prop=Properties.getProperties() self._suites=None