def test_get_historysport001(self): Returndata = Moudle("Wristband_Alpha").bind() self.headers = Returndata[1] r = Request().post_wirst_request(method=self.method, url=self.url, data=self.parm, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect['code']) Assertions().assert_code(r['status_code'], self.expect['status_code'])
def test_bind_device001(self): r = Request().post_wirst_request(self.method, self.url, self.parm, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect['code']) Assertions().assert_code(r['status_code'], self.expect['status_code']) Assertions().assert_time(r['time_total'], self.expect['respones_time']) Assertions().assert_code(r['message'], self.expect['message']) Assertions().assert_code(r['data']['rst'], self.expect['data']['rst'])
def test_bind_device003(self): self.parm3['device_token'] = self.wirst_cookies headers = self.headers.copy() headers['access_token'] = 'AAAAAAAAAAAAAAAA' r = Request().post_wirst_request(self.method, self.url, self.parm3, header=headers) print(r) Assertions().assert_code(r['code'], self.expect3['code']) Assertions().assert_code(r['status_code'], self.expect3['status_code'])
def test_bind_device002(self): self.parm2['device_token'] = self.wirst_cookies headers = self.headers.copy() headers['firmware_ver'] = '' r = Request().post_wirst_request(self.method, self.url, self.parm2, header=headers) print(r) Assertions().assert_code(r['code'], self.expect2['code']) Assertions().assert_code(r['status_code'], self.expect2['status_code'])
def test_unbind_device002(self): Returndata = Moudle("Wristband_Alpha").bind() self.parm2['device_token'] = Returndata[0] self.headers = Returndata[1] r = Request().post_wirst_request(method=self.method, url=self.url, data=self.parm2, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect2['code']) Assertions().assert_code(r['status_code'], self.expect2['status_code'])
def test_unbind_device001(self): Returndata = Moudle("Wristband_Alpha").bind() self.parm['device_token'] = Returndata[0] self.headers = Returndata[1] r = Request().post_wirst_request(method=self.method, url=self.url, data=self.parm, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect['code']) Assertions().assert_code(r['status_code'], self.expect['status_code']) Assertions().assert_time(r['time_total'], self.expect['respones_time']) Assertions().assert_code(r['message'], self.expect['message']) Assertions().assert_code(r['data']['rst'], self.expect['data']['rst'])
def get_functions(self): self.get_functions_url = self.host + "/app/v2/wristband/get_functions" self.get_functions_parm = {"tz": "Asia/Shanghai", "version": "2.12.0"} r = Request().post_wirst_request(method="post", url=self.get_functions_url, data=self.get_functions_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def get_token_data(self): self.get_token_url = self.host + "/app/v2/wristband/get_token" self.get_token_parm = {"tz": "Asia/Shanghai", "did": "RY.HP1.418337"} rdict = Request().post_wirst_request(method="post", url=self.get_token_url, data=self.get_token_parm, header=self.headers) Assertions().assert_code(rdict['status_code'], 200)
def get_band_bg_list(self): self.get_band_bg_list_url = self.host + "/app/v2/wristband/get_band_bg_list?tz=Asia%2FShanghai" self.get_band_bg_list_parm = {} r = Request().get_wirst_request(method="get", url=self.get_band_bg_list_url, data=self.get_band_bg_list_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def user_info(self): self.user_info_url = self.host + "/app/v2/wristband/user_info" self.user_info_parm = {"tz": "Asia/Shanghai"} rdict = Request().post_wirst_request(method="post", url=self.user_info_url, data=self.user_info_parm, header=self.headers) Assertions().assert_code(rdict['status_code'], 200) return rdict['data']['uid']
def get_defaultconn(self): self.get_defaultconn_url = self.host + "/app/v2/wristband/get_defaultconn" self.get_defaultconn_parm = { "tz": "Asia/Shanghai", "mac": "2C:AA:8E:00:AB:95" } r = Request().post_wirst_request(method="post", url=self.get_defaultconn_url, data=self.get_defaultconn_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def get_heart_rate_history(self): self.get_heart_rate_history_url = self.host + "/app/v2/wristband/get_heart_rate_history" start_time = datetime.datetime.now().strftime("%Y-%m-%d") self.get_heart_rate_history_parm = { "date": start_time, "tz": "Asia\/Shanghai" } r = Request().post_wirst_request(method="post", url=self.get_heart_rate_history_url, data=self.get_heart_rate_history_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def unbind(self): self.unbind_url = self.host + "/app/v3/user/unbind" self.unbind_parm = { "tz": "Asia/Shanghai", "did": "RY.HP1.418337", "device_token": self.device_token } r = Request().post_wirst_request(method="post", url=self.unbind_url, data=self.unbind_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def upload_taglog(self): self.upload_taglog_url = self.host + "/app/v3/upload/taglog" self.upload_taglog_parm = { "tz": "Asia/Shanghai", "datas": "CoMCCoACCiEKCE9QUE8gUjExEgE5GhBhYjZhYTdmNDQ1MzkzZmZiIAAySwpJCAgSLgoRMkM6QUE6OEU6MDA6QUI6OTUSDVJZLkhQMS40MTgzMzcaCDEuMC43Ljc5IgAaFQiijL36BRINQXNpYS9TaGFuZ2hhaTpBCj8KJgoRMkM6QUE6OEU6MDA6QUI6OTUSDVJZLkhQMS40MTgzMzcaACIAEhUImIy9+gUSDUFzaWEvU2hhbmdoYWlCSwpJCAYSLgoRMkM6QUE6OEU6MDA6QUI6OTUSDVJZLkhQMS40MTgzMzcaCDEuMC43Ljc5IgAaFQimjL36BRINQXNpYS9TaGFuZ2hhaQ==" } r = Request().post_wirst_request(method="post", url=self.upload_taglog_url, data=self.upload_taglog_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def get_sport_history(self): self.get_sport_history_url = self.host + "/app/v2/wristband/get_sport_history" self.get_sport_history_parm = { "tz": "Asia/Shanghai", "skip": 0, "limit": 50, "tz": "Asia\/Shanghai" } r = Request().post_wirst_request(method="post", url=self.get_sport_history_url, data=self.get_sport_history_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def upload_band_bg(self): new_headers = self.headers.copy() new_headers[ 'Content-Type'] = 'multipart/form-data; boundary=abbe3833-66e4-4845-a44d-5c9bbeb27c6f' self.upload_band_bg_url = self.host + "/app/v2/wristband/upload_band_bg" # file_path = 'C://Users//EDZ//PycharmProjects//untitled//ApiTest//Testdata//space_flight.png' self.upload_band_bg_parm = { 'pic_id': (None, 'o_7'), 'file_path': ('space_flight.png', open(self.file_path, 'rb'), 'image/png') } r = Request().post_wirst_request(method="post", url=self.upload_band_bg_url, data=self.upload_band_bg_parm, header=new_headers) Assertions().assert_code(r['status_code'], 200)
def data_upload(self): self.data_upload_url = self.host + "/app/v2/wristband/data_upload" self.data_upload_parm = { "tz": "Asia/Shanghai", "data": [ "Cg1SWS5IUDEuNDE4MzM3Eg0IARIJCHyIAYCc7cgBEi4IARIqCAIaIwoeCPbisvoFELXvsvoFIAAoADAAOABAAEgAUIDhAVgAoAEAiAEA" ], "tz": "Asia\/Shanghai" } r = Request().post_wirst_request(method="post", url=self.data_upload_url, data=self.data_upload_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def get_heart_rate(self): self.get_heart_rate_url = self.host + "/app/v2/wristband/get_heart_rate" start_time = datetime.datetime.now().strftime("%Y-%m-%d") end_time = (datetime.datetime.now() + datetime.timedelta(days=6)).strftime("%Y-%m-%d") self.get_heart_rate_parm = { "tz": "Asia/Shanghai", "type": "multiday", "start": start_time, "end": end_time, "tz": "Asia\/Shanghai" } r = Request().post_wirst_request(method="post", url=self.get_heart_rate_url, data=self.get_heart_rate_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200)
def bind(self): self.bind_url = self.host + "/app/v3/user/bind" self.bind_parm = { "tz": "Asia/Shanghai", "did": "RY.HP1.418337", "mac": "2C:AA:8E:00:AB:95", "nonce": 141361162, "sn": 144, "sign": "AAAAAAAAAAAAAAAAAAAAAJemS1kss+AgcguKwa1M51aWLi9xnWNAKOeX7rCTosjR", "sign_version": 2, "device_token": self.Returndata[0], "model": "RY.HP1" } r = Request().post_wirst_request(method="post", url=self.bind_url, data=self.bind_parm, header=self.headers) Assertions().assert_code(r['status_code'], 200) self.device_token = self.bind_parm['device_token'] return self.device_token, self.headers
def test_bind_device006(self): self.parm6['device_token'] = self.wirst_cookies + 'Greey' r = Request().post_wirst_request(self.method, self.url, self.parm6, header=self.headers) print(r) Assertions().assert_code(r['code'], self.expect6['code']) Assertions().assert_code(r['status_code'], self.expect6['status_code'])