def test_01_Login1(self): #开始第一个get请求获取sessionid和sessiondata self.url1 = Login_Element.login_url1 params1 = Login_Element.params1 self.params1 = params1 response1 = requests.get(url=self.url1, params=self.params1) print("status_code1:" + str(response1.status_code)) sessionid = Fun.getSessionId(response1.text) self.sessionid = sessionid sessiondata = Fun.getSessionData(response1.text) self.sessiondata = sessiondata #开始第二个post请求 self.url2 = Login_Element.login_url2 message2 = {"sessionId": sessionid, "sessionData": sessiondata} message2_2 = Fun.merge_Two_Dicts(Login_Element.message2, message2) header2 = Login_Element.header2 print(message2_2) print(type(message2_2)) response2 = requests.post(url=self.url2, data=message2_2, headers=header2) print("status_code2:" + str(response2.status_code)) #获取token请求 self.url3 = Login_Element.login_url3 message3 = {"sessionId": sessionid} header3 = Login_Element.header3 response3 = requests.post(url=self.url3, data=message3, headers=header3) print("status_code3:" + str(response3.status_code)) print("token:" + response3.text) token_info = Fun.re_write(response3.text) Fun.save_to_jsonfile('../common/token.json', token_info)
def test_06_getSeasonIngredientList(self): print("get Season Ingredient List Test") token = self.token url1 = self.url1 = Recipe_Interfaces.getSeasonIngredientList_url head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token) data1 = Recipe_Interfaces.data6 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def getStatus(self): #写死getStatus请求 token = Fun.take_token('../common/token.json') print("Get Appliance's Status Interface Test") url1 = Url.server + "/api/homeappliances/BOSCH-WTU879H00W-68A40E03C617/status" header = {'Content-Type': 'application/json'} header1_1 = Fun.merge_Two_Dicts(header, token) response1 = requests.get(url=url1, params={}, headers=header1_1) return response1
def test_4_TimeSynchronizationInterface(self): print("Time Synchronization Interface Test") token = self.token self.url4 = BasicSupport_Element.TimeSynchronization_url self.params = {} self.head4_4 = Fun.merge_Two_Dicts(BasicSupport_Element.header4, self.token) Fun.get_url(self.url4, self.params, self.head4_4)
def test_12_getRecipeByIngredients(self): print("get Recipe By Ingredients Test") token = self.token url1 = self.url1 = Recipe_Interfaces.getRecipeByIngredients_url head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token) data1 = Recipe_Interfaces.data12 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_04_BrowseTheItemsInTheShoppingCart(self): print("Browse the items in the shopping cart Test") token = self.token url1 = self.url1 = ShoppingCartInterfaces.BrowseTheItemsInTheShoppingCart_url head1 = Fun.merge_Two_Dicts(ShoppingCartInterfaces.header1, token) data1 = ShoppingCartInterfaces.data4 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_02_DeleteItemsInShoppingCart(self): print("Delete items in shopping cart Test") token = self.token url1 = self.url1 = ShoppingCartInterfaces.DeleteItemsInShoppingCart_url head1 = Fun.merge_Two_Dicts(ShoppingCartInterfaces.header1, token) data1 = ShoppingCartInterfaces.data2 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_03_ModifyProductInShoppingCart(self): print("Modify product in shopping cart Test") token = self.token url1 = self.url1 = ShoppingCartInterfaces.ModifyProductInShoppingCart_url head1 = Fun.merge_Two_Dicts(ShoppingCartInterfaces.header1, token) data1 = ShoppingCartInterfaces.data3 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_15_delCollect(self): print("del Collect Test") token = self.token url1 = self.url1 = Recipe_Interfaces.delCollect_url head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token) data1 = Recipe_Interfaces.data15 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_01_AddToCart(self): print("Add to shopping cart Test") token = self.token url1 = self.url1 = ShoppingCartInterfaces.AddToCart_url head1 = Fun.merge_Two_Dicts(ShoppingCartInterfaces.header1, token) data1 = ShoppingCartInterfaces.data1 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_5_getRecipeDetails(self): print("Get recipe details Test") token = self.token url1 = self.url1 = Recipe_Interfaces.GetRecipeDetails_url head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token) data1 = Recipe_Interfaces.data5 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_4_getSearchRecipe(self): print("get Search Recipe Test") token = self.token url1 = self.url1 = Recipe_Interfaces.getSearchRecipe_url head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token) data1 = Recipe_Interfaces.data4 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_3_GetRecipeList(self): print("Get Recipe List Test") token = self.token url1 = self.url1 = Recipe_Interfaces.getRecipeList_url head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token) data1 = Recipe_Interfaces.data3 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_2_GetRecipeHotCatalogs(self): print("get Recipe Hot Catalogs Test") token = self.token url1 = self.url1 = Recipe_Interfaces.getRecipeHotCatalogs_url head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token) data1 = Recipe_Interfaces.data1 data1_1 = json.dumps(data1) Fun.post_url(url=url1, data=data1_1, headers=head1)
def test_3_WeatherforecastInterface(self): print("Weather forecast Interface Test") token = self.token self.url3 = BasicSupport_Element.WeatherforecastInterface_url heaad3_3 = Fun.merge_Two_Dicts(BasicSupport_Element.header3, token) response3 = requests.get(url=self.url3, params={}, headers=heaad3_3) d = json.loads(response3.text) assert response3.status_code == 200 assert d["retInfo"] == "success", "retInfo not right" assert "retBody" in d.keys() print("status_code_IPLocation:" + str(response3.status_code)) print("pass")
def test_2_Realtimeweather(self): print("Real time weather Interface Test") token = self.token self.url2 = BasicSupport_Element.Realtimeweather_url heaad2_2 = Fun.merge_Two_Dicts(BasicSupport_Element.header2, token) response2 = requests.get(url=self.url2, params={}, headers=heaad2_2) d = json.loads(response2.text) assert response2.status_code == 200 assert d["retInfo"] == "success", "retInfo not right" assert "retBody" in d.keys() print("status_code_IPLocation:" + str(response2.status_code)) print("pass")
def test_1_getStatus(self): token = self.token print("Get Appliance's Status Interface Test") self.url1 = Url.server + "/api/homeappliances/BOSCH-WTU879H00W-68A40E03C617/status" header = {'Content-Type': 'application/json'} header1_1 = Fun.merge_Two_Dicts(header, token) response1 = requests.get(url=self.url1, params={}, headers=header1_1) d = json.loads(response1.text) assert response1.status_code == 200 assert d["msg"] == "成功", "retInfo not right" assert "status" in d["data"].keys() print("Get Appliance's Status pass") print("response code :" + str(response1.status_code)) print("r.elapsed.millisecond :" + str(response1.elapsed.microseconds / 1000)) print("response data :" + response1.text)
def test_1_IPLocationInterface(self): print("IP Location Interface Test") token = self.token self.url1 = BasicSupport_Element.IPLocation_url head1_1 = Fun.merge_Two_Dicts(BasicSupport_Element.header1, token) Fun.post_url(self.url1, data={}, headers=head1_1)