import unittestimport jsonfrom demo import RunMainclass TestMethod(unittest.TestCase): def setUp(self): self.run=RunMain() def test_01(self): url='http://api-app.meizu.com/apps/public/category/layout' data={ "custom_icon":"1", "device_model":"M57AC", "firmware":"Flyme OS 5.1.0.6QY", "imei":"868905020250933", "language":"zh-CN", "locale":"CN", "max":"50", "mpv":"appsv5", "mzos":"5", "net":"wifi", "os":"22", "screen_size":"1080x1920", "sn":"A1CEBN3223GS", "start":"0", "v":"5.0.8", "vc":"210" } # run=RunMain() res=self.run.run_main(url,'POST',data) print res def test_02(self): url='http://api-app.meizu.com/apps/public/category/layout' data={ "custom_icon":"1", "device_model":"M57AC", "firmware":"Flyme OS 5.1.0.6QY", "imei":"868905020250934", "language":"zh-CN", "locale":"CN", "max":"50", "mpv":"appsv5", "mzos":"5", "net":"wifi", "os":"22", "screen_size":"1080x1920", "sn":"A1CEBN3223GS", "start":"0", "v":"5.0.8", "vc":"210" } res=self.run.run_main(url,'POST',data) print resif __name__ == '__main__': unittest.main()——————————————————————————————————————————————#coding=utf-8import jsonimport requestsclass RunMain: def __init__(self,url,method,data=None): self.res=self.run_main(url,method,data) def send_get(self,url,data): res=requests.get(url=url,data=data).json() return json.dumps(res,indent=2,sort_keys=True) def send_post(self,url,data): res=requests.post(url=url,data=data).json() return json.dumps(res,indent=2,sort_keys=True) def run_main(self,url,method,data=None): res=None if method=='GET': res=self.send_get(url,data) else: res=self.send_post(url,data) return resif __name__ == '__main__': url='http://api-app.meizu.com/apps/public/category/layout' data={ "custom_icon":"1", "device_model":"M57AC", "firmware":"Flyme OS 5.1.0.6QY", "imei":"868905020250933", "language":"zh-CN", "locale":"CN", "max":"50", "mpv":"appsv5", "mzos":"5", "net":"wifi", "os":"22", "screen_size":"1080x1920", "sn":"A1CEBN3223GS", "start":"0", "v":"5.0.8", "vc":"210" } run=RunMain(url,'POST',data) print run.res # print run.run_main(url,'POST',data)
添加回答
举报
0/150
提交
取消