def test_frequencyDetailRecommended(self):
     url_frequencyDetailRecommended = self.host + '/zybook3/u/p/api.php?Act=frequencyDetail&key=MF0035&zyeid=0ad7a0cf-8ba4-4423-9adb-70006f663317&usr=j29095364&rgt=7&p1=XTpV6PJ%2FeDcDAOW8d1xT0h8e&pc=10&p2=124001&p3=17129056&p4=501656&p5=16&p6=&p7=__aea4c9dd6d4f9ccd&p9=2&p12=&p16=R9&p21=3&p22=6.0&p25=17129056&p26=23&p28='
     res = request_base.send_method('get', url_frequencyDetailRecommended,
                                    '')
     res1 = json.loads(res)
     self.assertEqual(res1['code'], 0, msg='相等')
     print('测试通过')
Esempio n. 2
0
 def test_yizhiGame(self):
     url_yizhiGame='https://api.gamecenter.viaweb.cn/list?vmedia=84'
     res=request_base.send_method('get',url_yizhiGame,'')
     #print(res)
     res1=json.loads(res)
     print(res1)
     print (len(res1['list']['others']))
     for i in res1['list']['others']:
         
         # print (res1['list']['others'][i]['c_end'])
         # s_icon=res1['list']['others'][i]['s_icon']
         # long_icon=res1['list']['others'][i]['long_icon']
         # clk_url=res1['list']['others'][i]['clk_url']
         # print (c_end)
         # print (s_icon)
         c_end=i.get('c_end')
         s_icon=i.get('s_icon')
         long_icon=i.get('long_icon')
         clk_url=i.get('clk_url')
         print (i.get('c_end'))
         c_start=i.get('c_start')
         
         #print(c_end.startswith('#'))
         #self.assertEqual(res1['code'],0,msg='错误')
         self.assertTrue(c_end.startswith('#'),msg='c_end的返回值需要以#开头')
         self.assertTrue(s_icon.startswith('http'),msg='s_icon的返回值需要以http开头')
         self.assertTrue(s_icon.endswith('.png') or s_icon.endswith('.jpg'),msg='s_icon的返回值需要以.png或者jpg结尾')
         self.assertTrue(long_icon.startswith('http'),msg='long_icon的返回值需要以http开头')
         self.assertTrue(long_icon.endswith('.png') or s_icon.endswith('.jpg'),msg='s_icon的返回值需要以.png或者jpg结尾')
         self.assertTrue(clk_url.startswith('http'),msg='clk_url的返回值需要以http开头')
         self.assertTrue(c_start.startswith('#'),msg='c_start的返回值需要以#开头')
         print ('开始又一次的遍历啦啦啦啦啦啦========================================================================')
 def test_frequencyFemale(self):
     url_frequencyFemale = self.host + '/zybk/api/channel/index?key=MF0037&page=1&repairReport=1&sign=cUzzulX4fITOcTxkGtvYRC9cyH3PSwPkhGKfJ+Jk91jp7+GF0gqC8T7Q93V8ce6pB5tk4p54fQXTnfys3aqPZuZAiRat7fLwwwHSaRCpxo03pvZ9zlPdBV02UieBzXPtpV0FtmCmnDgWYDF89HF06Jb+LtShR+2snxFChzFv0+Y=&timestamp=1597559946204&pluginVersion=107&a0=null&pk=null&today=0&zyeid=0ad7a0cf-8ba4-4423-9adb-70006f663317&usr=j29095364&rgt=7&p1=XTpV6PJ%2FeDcDAOW8d1xT0h8e&pc=10&p2=124001&p3=17129056&p4=501656&p5=16&p6=&p7=__aea4c9dd6d4f9ccd&p9=2&p12=&p16=R9&p21=3&p22=6.0&p25=17129056&p26=23&p28='
     res = request_base.send_method('get', url_frequencyFemale, '')
     res1 = json.loads(res)
     self.assertEqual(res1['code'], 0, msg='相等')
     # self.assertEqual(res['code'],0,msg='相等')
     print('测试通过')
Esempio n. 4
0
    def test_01(self):
        url_floating = 'https://dj.palmestore.com/zycl/api/pop/floating?sign=HMqVQkLEjQ2M+RZxI0m6VIVRhMqFB6AUI70L1RNImMDkNhERL1PsXfTMfd6MsHOAgwx4Z9ApNbbmC0uHzs1T1z5gDJwt5qFbpO9cbImBKm6BxrE7hZBsO89M9kRxOGldrmh9+te2VMQcYz5oXUD6gRvS+C2AJA228e+QC4/EMWo=&timestamp=1595131928511&usr=j28130897&zyeid=e7a5feb3-2b54-4525-9047-a5651a61f985&usr=j28130897&rgt=7&p1=V3WygQ4dlCADADL64yvBGhkY&pc=10&p2=132630&p3=17120056&p4=501656&p5=12&p6=&p7=__3e932cc0f202a00f&p9=2&p12=&p16=vivo+Y51A&p21=3&p22=5.1.1&p25=17120056&p26=22 HTTP/1.1'
        '''
        mock 书城悬浮窗的接口测试用例
        res=self.get_request(url_floating)
        sucess_test=mock.Mock(return_value=res)
        self.assertEqual(res,sucess_test())

        '''
        res = request_base.send_method('get', url_floating, '')
        print(res)
Esempio n. 5
0
 def test_login(self):
     url_login=self.host+'/dj_user/out/login/loginByPhoneV2?usr=j27871222&rgt=7&p1=V3WygQ4dlCADADL64yvBGhkY&pc=10&p2=124011&p3=17126056&p4=501656&p5=12&p6=&p7=__3e932cc0f202a00f&p9=2&p12=&p16=vivo+Y51A&p21=3&p22=5.1.1&p25=17126056&p26=22 HTTP/1.1'
     data={
         'channelId':'124011',
         'device':'vivo+Y51A',
         'imei':'__624900019789808',
         'pCode':'1',
         'phone':'11111111111',
         'sign':'w9HtPZD+vP+KcL5FYddDXkMrFiaHBJJEUFJ+1ZSa8VBjsPG93g2RRkSugoGUDFhIO0FhPtC+Ra/D13n0JYC/tmYhXToqHKvh/cCSSt6Z0FAfd7yHwl2s3VxUPoAhWNHjqIOTjrK4CmjJeKpR/wTsj2GIiVnXpdY3E6yPsgoYHAo=',
         'timestamp':'1595756193375',
         'userName':'******',
         'versionId':'17126056'
     }
     res=request_base.send_method('post',url_login,data)
     print(res)
     res1=json.loads(res)
     self.assertEqual(res1['code'],0,msg='相等')
     print('测试通过')
Esempio n. 6
0
 def test_myTab(self):
     url_myTab=self.host+'/zyuc/api/user/my/tab?sign=V3z41RGggYY2NhLOa1UZk4lUEEsvUP2LShuluZgZc/1I4lcw6h8mTh/NfCRqZTDoAt7wj+EgA7KuzyZJIGsa//YQDOPpfCV2FGB/JfqPLUdDK7VLng+W8gtw7BjYF2Xl4qLQOEMnEcim3KFY3Tb1vu23plv0YTruIO1bERLUB3w=&timestamp=1595756193640&usr=j28331372&zyeid=f622652b-52d3-4059-84e2-75b52d6dffad&usr=j28331372&rgt=7&p1=V3WygQ4dlCADADL64yvBGhkY&ku=j28331372&kt=7c589265807dc50ff4dc70ef29c4cbc1&pc=10&p2=124011&p3=17126056&p4=501656&p5=12&p6=&p7=__3e932cc0f202a00f&p9=2&p12=&p16=vivo+Y51A&p21=3&p22=5.1.1&p25=17126056&p26=22 HTTP/1.1'
     res=request_base.send_method('get',url_myTab,'')
     print(res)
     res1=json.loads(res)
     self.assertEqual(res1['code'],0,msg='错误')
Esempio n. 7
0
 def run_case(self):
     max_rows = handle_excel.get_rows()
     for i in range(max_rows - 1):
         # print(handle_excel.get_rows_value(i+2))
         data_value = handle_excel.get_rows_value(i + 2)
         method = data_value[4]
         data = data_value[5]
         excepect_method = data_value[7]
         if i == 3:
             url = data_value[3]
             res = request_base.send_method(method, url, data)
             res1 = json.loads(res)
         else:
             url = self.host_server + data_value[3]
             # print(request_base.send_method(method,url,data))
             res = request_base.send_method(method, url, data)
             res1 = json.loads(res)
             '''
             将通过实际的url/code 对应的msg 与接口文档中的(即code_message.json文件中的 url/code 对应的message是否一致来定测试是否通过)
             '''
             code = str(res1.get("code"))
             msg = res1["msg"]
             message = handleResult.get_value(data_value[3], code)
             print(len(msg), message, '================================>')
         if excepect_method == "code+message":
             if message == msg:
                 print("接口测试通过")
                 handle_excel.excel_write_data(i + 2, 10, "通过")
             else:
                 print("接口测试不通过")
                 handle_excel.excel_write_data(i + 2, 10, "失败")
                 handle_excel.excel_write_data(i + 2, 11, res)
             print('已成功执行1个接口测试代码code+message')
         elif excepect_method == "code":
             print(data_value[8])
             if data_value[8] == code:
                 print("接口测试通过")
                 handle_excel.excel_write_data(i + 2, 10, "通过")
             else:
                 print("接口测试不通过")
                 handle_excel.excel_write_data(i + 2, 10, "失败")
                 handle_excel.excel_write_data(i + 2, 11, res)
             print('已成功执行1个接口测试代码code')
         else:
             excepect_result_json = handleResult.get_result_json(
                 data_value[3])
             f*g = handleResult.handle_result_json(res1,
                                                   excepect_result_json)
             if f*g == True:
                 print("接口测试通过")
                 handle_excel.excel_write_data(i + 2, 10, "通过")
             else:
                 print("接口测试不通过")
                 handle_excel.excel_write_data(i + 2, 10, "失败")
                 handle_excel.excel_write_data(i + 2, 11, res)
             print('已成功执行1个接口测试代码JSON')
     emailSubject = "发送接口测试邮件"
     emailContent = "今日接口定时任务执行完毕,请查看邮件~~~"
     file_path = base_path + "/Case/"
     file_name = "case.xlsx"
     self.get_post_email(emailSubject, emailContent, file_path, file_name)
Esempio n. 8
0
    def run_case(self):
        '''
        获取url_data.json中的数据
        '''
        
        file_name="/config/url_data.json"
        url_data_dict=handJson.read_json(file_name)
        #handJson.get_value(key,file_path)
        i=0
        for key in url_data_dict:
            i=i+1
            '''
            每个接口的url为key
            值为列表 ['我的_登录', '是', 'post', '', '', 'code+message', '']
            '''
            url_data=url_data_dict.get(key)
            if key!='https://api.gamecenter.viaweb.cn/list?vmedia=85':

                url=self.host_server+key
                method=url_data[2]
                data=url_data[3]
                res_json=request_base.send_method(method,url,data)
                res_dict=json.loads(res_json)
                code=res_dict.get('code')
                print(type(code))
                msg=res_dict.get('msg')
            else:
                url=key
                method=url_data[2]
                data=url_data[3]
                res_json=request_base.send_method(method,url,data)
                res_dict=json.loads(res_json)
                

            '''
            通过预期结果方式、预期结果与实际的结果进行对比。比较用例是通过还是失败
            '''
            excepect_method=url_data[5]
            if excepect_method=='code+message':
                excepect_message=handleResult.get_value(key,code)
                if excepect_message==msg:
                    print("接口测试通过")
                    handle_excel.excel_write_data(i+1,10,"通过")
                else:
                    print("接口测试不通过")
                    handle_excel.excel_write_data(i+1,10,"失败")
                    handle_excel.excel_write_data(i+1,11,res_json)
            if excepect_method=='code':
                if url_data[6]==str(code):
                    print("接口测试通过")
                    handle_excel.excel_write_data(i+1,10,"通过")
                else:
                    print("接口测试不通过")
                    handle_excel.excel_write_data(i+1,10,"失败")
                    handle_excel.excel_write_data(i+1,11,res_json)
            if excepect_method=='json':
                excepect_dict=handJson.get_value(key,"/config/result.json")
                f*g=handleResult.handle_result_json(res_dict,excepect_dict)
                if f*g==True:
                    print("接口测试通过")
                    handle_excel.excel_write_data(i+1,10,"通过")
                else:
                    print("接口测试不通过")
                    handle_excel.excel_write_data(i+1,10,"失败")
                    handle_excel.excel_write_data(i+1,11,res_json)
            '''
            将数据写入Excel文件
            
            每个接口的url为key
            值为列表 ['我的_登录', '是', 'post', '', '', 'code+message', '']
          
            '''
            handle_excel.excel_write_data(i+1,1,"case"+str(i))
            handle_excel.excel_write_data(i+1,2,url_data[0])
            handle_excel.excel_write_data(i+1,3,url_data[1])
            handle_excel.excel_write_data(i+1,4,url)
            handle_excel.excel_write_data(i+1,5,url_data[2])
            handle_excel.excel_write_data(i+1,6,url_data[3])
            handle_excel.excel_write_data(i+1,7,url_data[4])
            handle_excel.excel_write_data(i+1,8,url_data[5])
            handle_excel.excel_write_data(i+1,9,url_data[6])
        emailSubject="发送接口测试邮件"
        emailContent="今日接口定时任务执行完毕,请查看邮件~~~"
        file_path=base_path+"/Case/"
        file_name="case.xlsx"
        cols_value=handle_excel.get_cols_value(10)
        for i in cols_value:
            if i=="失败":
                self.get_post_email(emailSubject,emailContent,file_path,file_name)
 def test_frequencyRecommended(self):
     url_frequencyRecommended = self.host + '/zybk/api/channel/index?key=MF0035&page=1&repairReport=1&sign=joSx8Xaa9qiAMbejBpJerNkOWx9eUV/sHr9fqp6opmCeYFyFZsTP9bi3AEkGo6o13qRWU35rCSEC4fY6B14am/rUStTjEwCBSWDo+AfzZAHM+lDyP07DFCtQtua1LkJYS0NOaBSe/SLI9ma6aPvwfUWizdmSZWWm7CyKEVtzRK0=&timestamp=1597564049136&pluginVersion=107&a0=null&pk=null&today=0&zyeid=0ad7a0cf-8ba4-4423-9adb-70006f663317&usr=j29095364&rgt=7&p1=XTpV6PJ%2FeDcDAOW8d1xT0h8e&pc=10&p2=124001&p3=17129056&p4=501656&p5=16&p6=&p7=__aea4c9dd6d4f9ccd&p9=2&p12=&p16=R9&p21=3&p22=6.0&p25=17129056&p26=23&p28='
     res = request_base.send_method('get', url_frequencyRecommended, '')
     res1 = json.loads(res)
     self.assertEqual(res1['code'], 0, msg='相等')
     print('测试通过')