def setUpClass(self): LC = LoadConfig() domain = LC.read_domain() interface = LC.read_interface('findpasswordvalid') self.url = MyTools.montage_url(domain, interface[0]) self.para = interface[1] Log.info("findpasswordvalid Test Start")
def test002(self): Log.info("lockorunlock test002") # 执行sql设置用户状态为冻结状态 sql = 'update mpc.sec_user set status = 2 where id = 22' self.Sql.insert_update_mysql(sql) loginsess = Login(self.loginurl, self.loginpara, 'chenjinsong', '11111111').get_login_session() F1 = LockOrUnlock(sess=loginsess, url=self.url, para=self.para, userid=22, operation=1) F1.Test_success_check(F1.res)
def setUpClass(self): LC = LoadConfig() domain = LC.read_domain() interface = LC.read_interface('getcollectinfo') self.url = MyTools.montage_url(domain, interface[0]) self.para = interface[1] # print self.para Log.info("getcollectinfo Test Start")
def test001(self): # success case Log.info("logout test001") Logout1 = Logout(url=self.url, para=self.para, loginurl=self.loginurl, loginpara=self.loginpara, username='******', passwd='11111111') Logout1.Test_success_check(Logout1.res)
def setUpClass(self): LC = LoadConfig() domain = LC.read_domain() interface = LC.read_interface('sendsmscode') self.url = MyTools.montage_url(domain, interface[0]) self.para = interface[1] interface2 = LC.read_interface('validsmscode') self.url2 = MyTools.montage_url(domain, interface2[0]) self.para2 = interface2[1] Log.info("sendsmscode/validsmscode Test Start")
def setUpClass(self): LC = LoadConfig() domain = LC.read_domain() interface = LC.read_interface('findpasswordset') self.url = MyTools.montage_url(domain, interface[0]) self.para = interface[1] # interface needs to call interface findpasswordvalid interface2 = LC.read_interface('findpasswordvalid') self.validurl = MyTools.montage_url(domain, interface2[0]) self.validpara = interface2[1] Log.info("findpasswordset Test Start")
def setUpClass(self): LC = LoadConfig() domain = LC.read_domain() interface = LC.read_interface('logout') self.url = MyTools.montage_url(domain, interface[0]) self.para = interface[1] # interface needs login interface2 = LC.read_interface('login') self.loginurl = MyTools.montage_url(domain, interface2[0]) self.loginpara = interface2[1] Log.info("logout Test Start")
def setUpClass(self): LC = LoadConfig() domain = LC.read_domain() interface = LC.read_interface('queryfilerel') self.url = MyTools.montage_url(domain, interface[0]) self.para = interface[1] # interface need login session interface2 = LC.read_interface('login') self.loginurl = MyTools.montage_url(domain, interface2[0]) self.loginpara = interface2[1] Log.info("queryfilerel Test Start")
def test002(self): Log.info("findpasswordset test002") Valid1 = FindPasswordValid(self.validurl, self.validpara, '18252023049', '666666') Valid1.Test_success_check(Valid1.res) sleep(2) # generate passwd passwd = MyTools.generate_passwd_int8() Set1 = FindPasswordSet(self.url, self.para, 35, passwd, '18252023049', '666666') Set1.Test_failure_nouser_check() sleep(1)
def setUpClass(self): LC = LoadConfig() domain = LC.read_domain() interface = LC.read_interface('favorited') self.url = MyTools.montage_url(domain, interface[0]) self.para = interface[1] # interface need login session interface2 = LC.read_interface('login') self.loginurl = MyTools.montage_url(domain, interface2[0]) self.loginpara = interface2[1] # print self.para Log.info("favorited Test Start")
def add_message(self, sessiondata, url, params, file_path='../../lib/images/test.jpg'): print os.getcwd() res_dict = {} #处理传入值 url = str(url) try: session = sessiondata['session'] except: session = sessiondata file_type = mimetypes.guess_type(file_path)[0] if 'image/pjpeg' == file_type: file_type = 'image/jpeg' elif 'image/x-png' == file_type: file_type = 'image/png' fa = open(file_path, 'rb') filestream = fa.read() params = params.replace('\'', '"') params = json.loads(params) resp = session.get( 'http://message.ba.qbao.com/message/toListMessage.html') resp = session.post( url, data=params, files={'portionMembers-file': (file_path, filestream)}) fa.close() Log.info(resp) res_dict = self._make_res(session, resp) return res_dict
def upload_imgs_request(self, sessiondata, url, params, name, file_path='./lib/images/test.jpg'): """ """ res_dict = {} #处理传入值 url = str(url) try: session = sessiondata['session'] except: session = sessiondata file_type = mimetypes.guess_type(file_path)[0] if 'image/pjpeg' == file_type: file_type = 'image/jpeg' elif 'image/x-png' == file_type: file_type = 'image/png' fa = open(file_path, 'rb') filestream = fa.read() params = params.replace('\'', '"') params = json.loads(params) resp = session.post(url, data=params, files={name: (file_path, filestream)}) fa.close() Log.info(resp) res_dict = self._sessobj._make_res(session, resp) return res_dict
def tearDownClass(self): Log.info("queryfilerel Test End")
def test002(self): # failure case Log.info("login test002") Login2 = Login(self.url, self.para, 'chenjinsong', '11111112') Login2.Test_login_failure_check()
def test001(self): Log.info("queryfilerel test001") loginsess = Login(self.loginurl, self.loginpara, 'chenjinsong', '11111111').get_login_session() F1 = QueryFileRel(loginsess, self.url, self.para, 1, 'mpcAppInstall') F1.Test_success_check(F1.res)
def tearDownClass(self): Log.info("logout Test End")
def result_cmp(self, sqllist, responselist): """结果比较,responselist包含或者等于sqllist返回1,sqllist与responselist都为string Example: | Json Cmp | sqllist | responselist | """ #全部转化为小写,且去除key中的下划线,由于两个结果集中的value预期相同,所以转换value中的下划线无影响 try: sqllist = ''.join(sqllist.lower().split('_')).replace( 'null', "' '").replace('none', "' '") responselist = ''.join(responselist.lower().split('_')).replace( 'null', "' '").replace('none', "' '") global true global false except Exception as e: raise AssertionError("can't lower or split" + str(e)) #sqllist = sqllist.replace("'", "\"") #responselist = responselist.replace("'", "\"") try: #Log.info('sqllist:' + sqllist.replace('true',"1")) #Log.info('responselist len:' + responselist.replace('none',"' '")) #转化为list sqltemp = eval(sqllist) restemp = eval(responselist) except Exception as e: raise AssertionError("can't convert to list " + str(e)) #raise AssertionError('Case task_do Failed,'+'doUserTask.html接口返回出错:') #templist = json.loads(sqllist) #responselist = json.loads(responselist) if (type(sqltemp) == list and type(restemp) == list): lengths = len(sqltemp) lengthr = len(restemp) #比较长度 if (lengths != lengthr): Log.info('sqllist len:' + str(lengths) + 'responselist len:' + str(lengthr)) return -1 #长度为0为空,返回成功 elif 0 == lengths: return 1 #两个list对比,response包含sql结果 for i in range(lengthr): for k, v in sqltemp[i].items(): if str(sqltemp[i][k]) == str(restemp[i][k]): pass else: Log.info(k + ':' + str(sqltemp[i][k]) + ' not equal' + k + ':' + str(restemp[i][k])) return -1 Log.info('List Compare Complete, Success...') return 1 elif (type(sqltemp) == dict and type(restemp) == dict): ''' 精确匹配 realdict = sorted(sqltemp.items(), key=lambda d: d[0]) expectdict = sorted(restemp.items(), key=lambda d: d[0]) if cmp(realdict,expectdict)!=0: Log.info('Not Equal') return -1 return 1 ''' for k, v in sqltemp.items(): if str(sqltemp[k]) in ['', ' ', None, "' '"] and str( restemp[k]) in ['', ' ', None, "' '"]: pass elif str(sqltemp[k]) == str(restemp[k]): pass else: raise AssertionError(k + ': ' + str(sqltemp[k]) + ' Not Equal ' + k + ': ' + str(restemp[k])) #Log.info(k + ': '+ str(sqltemp[k]) + ' not equal' + k + ': '+ str(restemp[k])) #return -1 Log.info('Dict Compare Complete, Success...') return 1 else: Log.info('Unknow Type') return -1
def test001(self): # success case Log.info("findpasswordvalid test001") F1 = FindPasswordValid(self.url, self.para, '17612151210', '666666') F1.Test_success_check(F1.res)
def tearDownClass(self): Log.info("lockorunlock Test End")
def test002(self): Log.info("favorited test002") loginsess = Login(self.loginurl, self.loginpara, 'chenjinsong', '11111111').get_login_session() F1 = Favorited(loginsess, self.url, self.para, 22, 15, False) F1.Test_success_check(F1.res)
def tearDownClass(self): Log.info("favorited Test End")
def test002(self): # success case Log.info("findpasswordvalid test002") F1 = FindPasswordValid(self.url, self.para, '17612151210', '666667') F1.Test_failure_check()
def tearDownClass(self): Log.info("findpasswordset Test End")
def test003(self): Log.info("sendsmscode/validsmscode Test003") Send1 = SendSmsCode(self.url, self.para, '17612151211') Send1.Test_failure_check()
def test001(self): # success case Log.info("getcalculatedtrend test001") Get1 = GetCalculatedTrend(self.url, self.para) Get1.Test_success_check(Get1.res)
def tearDownClass(self): Log.info("getcalculatedtrend Test End")
def test002(self): Log.info("sendsmscode/validsmscode Test002") Send1 = SendSmsCode(self.url, self.para, '17612151210') Send1.Test_success_check(Send1.res) Send2 = ValidSmsCode(self.url2, self.para2, '17612151210', '666667') Send2.Test_failure_check()
def test001(self): # success case Log.info("getcollectinfo test001") Get1 = GetCollectInfo(self.url, self.para) Get1.Test_success_check(Get1.res)
def tearDownClass(self): Log.info("sendsmscode/validsmscode Test End") pass
def tearDownClass(self): Log.info("getcollectinfo Test End")