def test_bookcreatepost(self): ''' bookcreatepost图书类型接口用例 ''' header = {'Content-Type': 'application/json;charset=UTF-8'} data = { 'accessTime': self.accesstime, 'accessId': self.accessId, 'background': '#768699-#768699', 'words': '分享一本我最近看过的书,希望你也喜欢~', 'type': 'book', 'hobbyId': '1084336' } data['accessSign'] = App_sign().get_sign(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) print(resq.json()) # try: assert resq.status_code == 200 assert resq.json()['success'] == True assert 'pid' in resq.json() assert resq.json( )['postCover'] == r"https://cover.intelcupid.com/book/cover/1084336.jpg" allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_wordcreatepost(self): ''' wordcreatepost图书类型接口用例 ''' header = { 'Content-Type': 'application/json;charset=UTF-8' } data = { 'accessTime': self.accesstime, 'accessId': self.accessId, 'background': '#ffffff', 'fontStyle': 'center', 'words': 'api', 'type': 'words', 'fontColor': '#333333' } data['accessSign'] = App_sign().get_sign(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) print(resq.json()) # try: assert resq.status_code == 200 assert resq.json()['success'] == True assert 'pid' in resq.json() assert resq.json()['postCover'] == "#FFFFFF񑘕" allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_startflash(self): ''' startflash接口用例 ''' url = ReadConfig().get_host('online_host') + ReadConfig().get_path( 'app_path') + 'v1/startflash' header = {'Content-Type': 'application/json;charset=UTF-8'} data = { "accessId": self.accessId, "accessTime": self.accesstime, "location": [116.428268432617, 39.918750762939] } data['accessSign'] = App_sign().get_sign(data) # print(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(url, data=json.dumps(data), headers=header) # print(resq.json()) # # try: assert resq.status_code == 200 assert resq.json()['success'] == True assert 'flashProfile' in resq.json() allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_messagelistselect(self): ''' selectmessagelist接口用例 ''' header = { 'Content-Type': 'application/json;charset=UTF-8', 'Accept': '*/*' } data = { 'accessTime': self.accesstime, 'accessId': self.accessId, 'gender': 1, 'findStatus': [1, 3], 'waiting': 1 } data['accessSign'] = App_sign().get_sign(data) # print(type(data)) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) print(resq.json()) # # try: assert resq.status_code == 200 assert resq.json()['success'] == True assert 'messageList' in resq.json() allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_bookhobbies(self): ''' bookhobbies图书类型接口用例 ''' header = {'Content-Type': 'application/json;charset=UTF-8'} data = { 'accessTime': self.accesstime, 'accessId': self.accessId, 'skip': 0, 'sortByHot': 0, 'type': 'book', 'keyWords': '' } data['accessSign'] = App_sign().get_sign(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) # print(resq.json()) # try: assert resq.status_code == 200 assert resq.json()['success'] == True assert 'hobbies' in resq.json() assert len(resq.json()['hobbies']) == 10 allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_stopflash(self): ''' stopflash接口用例 ''' url = ReadConfig().get_host('online_host') + ReadConfig().get_path( 'app_path') + 'v1/stopflash' header = {'Content-Type': 'application/json;charset=UTF-8'} data = {'accessId': self.accessId, 'accessTime': self.accesstime} data['accessSign'] = App_sign().get_sign(data) resq = requests.post(url, data=json.dumps(data), headers=header) assert resq.status_code == 200 assert resq.json()['success'] == True allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def get_musicpid(): accessId = ReadConfig().get_accessid('accessId') accesstime = PublicUtils().location_time() url = ReadConfig().get_host('online_host') + ReadConfig().get_path( 'app_path') + 'v1/userposts' header = {'Content-Type': 'application/json;charset=UTF-8'} get_data = { 'accessId': accessId, 'uid': accessId, 'accessTime': accesstime } get_data['accessSign'] = App_sign().get_sign(get_data) resq = requests.post(url, data=json.dumps(get_data), headers=header) # print(resq.json()) return resq.json()
def test_passrecent(self): ''' passrecent接口用例 ''' header = {'Content-Type': 'application/json;charset=UTF-8'} data = {'accessTime': self.accesstime, 'accessId': self.accessId} data['accessSign'] = App_sign().get_sign(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) # try: assert resq.status_code == 200 assert resq.json()['success'] == True assert 'userList' in resq.json() allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_myprofile(self): ''' myprofile接口用例 ''' header = {'Content-Type': 'application/json;charset=UTF-8'} data = { "accessId": self.accessId, "accessTime": self.accesstime, "allowAppNotice": 1 } data['accessSign'] = App_sign().get_sign(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) # allure.attach(json.dumps(resq.json(),ensure_ascii=False), "响应", allure.attachment_type.JSON) # try: assert resq.status_code == 200 assert resq.json()['success'] == True allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_delmusic(self, get_musicpid): header = {'Content-Type': 'application/json;charset=UTF-8'} music_pid = get_musicpid['posts'][0]['pid'] del_data = { 'accessTime': self.accesstime, 'accessId': self.accessId, 'pid': music_pid } del_data['accessSign'] = App_sign().get_sign(del_data) allure.attach(json.dumps(del_data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(del_data), headers=header) # print(resq.json()) assert resq.status_code == 200 assert resq.json()['success'] == True allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_pass(self): ''' pass接口用例 ''' header = {'Content-Type': 'application/json;charset=UTF-8'} data = { 'accessTime': self.accesstime, 'accessId': self.accessId, 'targetId': '5d0a41711e5d874a41593310', 'inspectTime': 0 } data['accessSign'] = App_sign().get_sign(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) assert resq.status_code == 200 assert resq.json()['success'] == True allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)
def test_updatepreference(self): ''' updatepreference接口用例 ''' header = {'Content-Type': 'application/json;charset=UTF-8'} data = { 'accessTime': self.accesstime, 'accessId': self.accessId, 'gender': 1, 'recommend': 1 } data['accessSign'] = App_sign().get_sign(data) allure.attach(json.dumps(data), '接口数据', allure.attachment_type.JSON) resq = requests.post(self.url, data=json.dumps(data), headers=header) # try: assert resq.status_code == 200 assert resq.json()['success'] == True # assert 'suggestInfo' in resq.json() assert resq.json()['shuffle'] == True allure.attach(json.dumps(resq.json(), ensure_ascii=False), "响应", allure.attachment_type.JSON)