コード例 #1
0
    def test_channels(self, url, headers, expect_result, status_code):

        r = ApiChannels().api_get_channels(url, headers)

        print(r.json())

        self.assertEquals(status_code, r.status_code)

        self.assertEquals(expect_result, r.json()['message'])
コード例 #2
0
ファイル: test_channels.py プロジェクト: lijinglj90/shop
 def test_channels(self,url,headers,expect_result,status_code):
     # 暂时存放数据url headers
     # url = "http://ttapi.research.itcast.cn/app/v1_0/user/channels"
     # 提示token之前有Bearer和空格
     # headers = {"Content-Type":"application/json",
     #            "Authorization":"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODA2NTQ5NjEsInVzZXJfaWQiOjEyMjMyMzYwMjI0OTAzNjU5NTIsInJlZnJlc2giOmZhbHNlfQ.hUT9L-YnD4wRCNn_q9GxxMgTDC2-IhaOY9kFz5t1fAQ"}
     #  优化-调用登录方法
     s = ApiChannels().api_get_channels(url, headers)
     print(s.json())
     #  断言 响应信息 及 状态码
     #断言响应状态码
     # self.assertEqual(200, s.status_code)
     self.assertEqual(status_code, s.status_code)
     #  断言 响应信息 及 状态码
     self.assertEqual(expect_result, s.json()['message'])
コード例 #3
0
 def test_channels(self, url, headers, status_code,
                   except_result):  #测试方法一定要test开头
     #临时数据,token需先运行登录接口获取,这里的token前有个空格和Bearer
     # url = "http://ttapi.research.itcast.cn/app/v1_0/users/channels"
     # headers = {"Content-Type": "application/json", "Authorization": "Bearer wehfuiDUIwoweIUAdwexjDjdwOKDeowieuxmnNBbdww"}#这里的token是随便写的
     #调用获取用户频道列表方法
     r = ApiChannels().api_get_channels(
         url, headers)  #ApiChannels()必须要有括号才代表ApiChannels类的实例
     print "响应结果:", r.json()
     #断言 状态码和响应信息
     # self.assertEqual(200,r.status_code)
     # self.assertEqual("OK",r.json()['message'])
     #断言,使用参数化
     self.assertEqual(status_code, r.status_code)
     self.assertEqual(except_result, r.json()['message'])
コード例 #4
0
 def test_channels(self, url, headers, expect_result, status_code):
     #临时数据
     # url = "https://www.lagou.com/jobs/mList.html"
     # headers = {"Conent-Type":"value","Authorization":"Beare token信息"}
     # 调用方法 获取频道信息
     t = ApiChannels().api_get_channels(url, headers)
     #调试打印结果
     print(t.json())
     #断言 状态码
     # self.assertEquals(200,t.status_code)
     #使用参数化
     self.assertEquals(status_code, t.status_code)
     #断言 响应信息
     # self.assertEquals("ok",t.json()["message"])
     #使用参数化
     self.assertEquals(expect_result, t.json()["message"])
コード例 #5
0
ファイル: test_channels.py プロジェクト: hubiao19910129/JLPAY
    def test_channels(self,url,headers,espect_result,status_code):
        # url     = "http://172.20.6.24:8083"
        # headers = {"Content-Type":"application/json","account":"15511119876","password":"******"}
        r = ApiChannels.api_get_channels(self,url,headers)

        print(r)

        self.assertEqual(espect_result,"OK")
        self.assertEqual(status_code, 200)
コード例 #6
0
 def test_channels(self, url, headers, expect_result):
     token = WriteReadToken('token.md').read_data()[0]
     # print(token)
     headers['Authorization'] = 'Bearer {}'.format(token)
     # print(headers)
     response = ApiChannels().api_get_channels(url=url, headers=headers)
     # print(response)
     assert expect_result == response['message']
     channel = jsonpath(response, '$.data.channels[0]')[0]
     WriteReadToken('token.md').append_data(str(channel))
コード例 #7
0
    def test_channels(self, url, headers, expect_result, status_code):
        # 临时数据
        # url = "http://ttapi.research.itcast.cn/app/v1_0/user/channels"

        # 提示:token之前有个空格和Bearer
        # headers = {"Content-Type": "application/json","Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NTAyNTA4NDIsInVzZXJfaWQiOjU3LCJyZWZyZXNoIjpmYWxzZX0.MB2ZK5c8-VJHdA40r4ijLyAmIbPMpi_40tpeo3Wj4wk"}

        # 调用获取用户频道列表方法
        r = ApiChannels().api_get_channels(url, headers)

        # 调试信息 打印响应结果
        print(r.json())

        # 断言 状态码
        # self.assertEquals(200, r.status_code)

        # 使用参数化
        self.assertEquals(status_code, r.status_code)

        # 断言 响应信息
        # self.assertEquals("OK", r.json()['message'])

        # 使用参数化
        self.assertEquals(expect_result, r.json()['message'])