Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
 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 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
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 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)
Beispiel #11
0
 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)
Beispiel #12
0
 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)
Beispiel #13
0
 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)
class MyTest(unittest.TestCase):  #封装测试环境的初始化
    token = Fun.take_token('../common/token.json')

    def setUp(self):
        print("start test")
        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 tearDown(self):
        print("end test")
        pass
 def test_1_getToken(self):
     print("get Token")
     url1 = self.url1 = Login_getToken.login_url
     header1 = Login_getToken.header
     body1 = Login_getToken.body
     data1_1 = json.dumps(body1)
     #进行post请求
     r = requests.post(url=self.url1, data=data1_1, headers=header1)
     #获取token值
     response = r.json()
     token = str(response["data"])
     #将字符串里的单引号替换成双引号
     token = re.sub('\'', '\"', token)
     token = re.sub('accessToken', 'Authorization', token)
     #保存到文件token.json
     Fun.save_to_jsonfile('../common/token.json', token)
     print("status_code:" + str(r.status_code))
     print("response:" + str(r.text))
Beispiel #16
0
class MyTest(unittest.TestCase):  #封装测试环境的初始化
    token = Fun.take_token('../common/token.json')

    def setUp(self):
        print("-----start test Recipe_Interfaces-----")
        pass

    def test_1_GetRecipeCatalogs(self):
        print("get Recipe Catalogs Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getRecipeCatalogs_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_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_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_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_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 tearDown(self):
        print("-----end test Basic Support-----")
        pass
Beispiel #17
0
 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")
Beispiel #18
0
 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_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)
Beispiel #20
0
class MyTest(unittest.TestCase):  #封装测试环境的初始化
    token = Fun.take_token('../common/token.json')

    def setUp(self):
        print("-----start test Basic Support-----")
        pass

    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)

    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_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_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 tearDown(self):
        print("-----end test Basic Support-----")
        pass
Beispiel #21
0
class MyTest(unittest.TestCase):  #封装测试环境的初始化
    token = Fun.take_token('../common/token.json')

    def setUp(self):
        print("-----start test Shopping Cart Interfaces-----")
        pass

    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_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_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 tearDown(self):
        print("-----end test Basic Support-----")
        pass
Beispiel #22
0
import requests
import unittest
from testPlan.common.commonFun import BasicSupport_Element, Fun
import json
token = Fun.take_token('../common/token.json')

#def get_url(url, params ,headers):
# url = url
# params = params
# headers = headers
# response = requests.get(url = url , params = params,headers= headers)
# d = json.loads(response.text)
# assert response.status_code == 200
# assert d["retInfo"] == "success", "retInfo not right"
# assert "retBody" in d.keys()
# print("status_code_IPLocation:" + str(response.status_code))
# print(response.text)
#  print("pass")

url = "https://solution.home-connect.cn/sfmapi/service/v1/recipe/getRecipeCatalogs"
data1 = {
    "header": {
        "timestamp": "2014-11-12 15:48:00",
        "deviceCode": "BE080A300QZ225H00002",
        "ver": "v1.0",
        "sign": "18c8c29f0898ac4b8b0a7a6afdb436aa"
    },
    "data": {}
}
data2 = json.dumps(data1)
#data3 = json.loads(data1)
Beispiel #23
0
class MyTest(unittest.TestCase):  #封装测试环境的初始化
    token = Fun.take_token('../common/token.json')

    def setUp(self):
        print("-----start test Recipe_Interfaces-----")
        pass

    def test_01_GetRecipeCatalogs(self):
        print("get Recipe Catalogs Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getRecipeCatalogs_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_02_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_03_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_04_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_05_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_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 test_07_getRankingRecipe(self):
        print("get Ranking Recipe Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getRankingRecipe_url
        head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token)
        data1 = Recipe_Interfaces.data7
        data1_1 = json.dumps(data1)
        Fun.post_url(url=url1, data=data1_1, headers=head1)

    def test_08_getChosenRecipe(self):
        print("get Chosen Recipe Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getChosenRecipe_url
        head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token)
        data1 = Recipe_Interfaces.data8
        data1_1 = json.dumps(data1)
        Fun.post_url(url=url1, data=data1_1, headers=head1)

    def test_09_getHotMenus(self):
        print("get Hot Menus Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getHotMenus_url
        head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token)
        data1 = Recipe_Interfaces.data9
        data1_1 = json.dumps(data1)
        Fun.post_url(url=url1, data=data1_1, headers=head1)

    def test_10_getVideos(self):
        print("get Videos Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getVideos_url
        head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token)
        data1 = Recipe_Interfaces.data10
        data1_1 = json.dumps(data1)
        Fun.post_url(url=url1, data=data1_1, headers=head1)

    def test_11_getRecipeByTime(self):
        print("get Recipe By Time Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getRecipeByTime_url
        head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token)
        data1 = Recipe_Interfaces.data11
        data1_1 = json.dumps(data1)
        Fun.post_url(url=url1, data=data1_1, headers=head1)

    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_13_addCollect(self):
        print("add Collect Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.addCollect_url
        head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token)
        data1 = Recipe_Interfaces.data13
        data1_1 = json.dumps(data1)
        Fun.post_url(url=url1, data=data1_1, headers=head1)

    def test_14_getCollect(self):
        print("get Collect Test")
        token = self.token
        url1 = self.url1 = Recipe_Interfaces.getCollect_url
        head1 = Fun.merge_Two_Dicts(Recipe_Interfaces.header1, token)
        data1 = Recipe_Interfaces.data14
        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 tearDown(self):
        print("-----end test Basic Support-----")
        pass
Beispiel #24
0
 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)