class PostsDetail(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------post点赞记录列表---------------------------------- def testcase_001(self): sheet_index = 1 row = 57 print("testcase_001post点赞记录列表:") # 1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"content": "接口在" + date + "测试发布纯文字"} member_id1 = "748" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) post_id = result1["data"]["post_id"] # 2.调用动态点赞接口 payload2 = {"post_id": post_id, "praise_state": 1} # 获取token member_id = "744" urlpart2 = '/posts/praise' result2 = self.r.interface_requests_data(member_id, urlpart2, payload2) # 3.调用动态点赞列表接口 payload = {'page': 1, 'post_id': post_id} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class RewardsDescription(unittest.TestCase): def setUp(self): self.member_id = '744' self.requests = FuncRequests() #-----------------兑换商品---------------------------- def testcase_001(self): sheet_index = 8 row = 11 # 1.先调用积分接口获取goods_id,然后根据goods_id得到商品详情 urlpart = '/membership' payload = {} result1 = self.requests.interface_requests_data( self.member_id, urlpart, payload) goods_id = result1['data']['gifts'][0]['goods_id'] # 2.调用收获地址接口获取address_id,然后根据address_id得到商品详情 urlpart = '/member/address' payload = {'type': 'default'} result1 = self.requests.interface_requests_data( self.member_id, urlpart, payload) address_id = result1['data']['address_id'] print("testcase001 兑换商品:") payload = {'goods_id': goods_id, 'address_id': address_id} result = self.requests.interface_requests_payload( self.member_id, sheet_index, row, payload)
class Brands(unittest.TestCase): def setUp(self): self.r = FuncRequests() self.member_id = '10394' #-----------------钱包 - 删除可提现账户---------------------------------- def testcase_001(self): sheet_index = 13 row = 9 print("testcase_001钱包 - 删除可提现账户:") # 调用提现账户添加接口获取account_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) urlpart1 = '/wallet/account/add' date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"account": date, "first_name": "yu", "last_name": "qin"} result1 = self.r.interface_requests_data(self.member_id, urlpart1, payload1) urlpart2 = '/wallet/account/lists' payload2 = {} result2 = self.r.interface_requests_data(self.member_id, urlpart2, payload2) list = result2["data"]["list"] account_id = list[0]["id"] print("account_id=", account_id) payload = {"account_id": account_id} result = self.r.interface_requests_payload(self.member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class PostsDetail(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------评论详情---------------------------------- def testcase_001(self): sheet_index = 1 row = 55 print("testcase_001评论详情:") # 1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"content": "接口在" + date + "测试发布纯文字"} member_id1 = "748" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) post_id = result1["data"]["post_id"] # 2.调用评论接口 date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload2 = { "post_id": post_id, "content": "接口在" + date + "测试发布评论", "is_post": "N" } urlpart2 = '/comments/publish' result2 = self.r.interface_requests_data(member_id1, urlpart2, payload2) global comment_id comment_id = result2["data"]["comment_id"] # 3.调用评论详情接口 payload = {'page': 1, 'comment_id': comment_id, 'direct_id': 0} # 获取token值 member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") # -----------------评论跳转---------------------------------- def testcase_002(self): sheet_index = 1 row = 56 print("testcase_002评论跳转:") payload = { 'page': 1, 'comment_id': comment_id, 'direct_id': comment_id } # 获取token值 member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class PostsDetail(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------删除自己的动态---------------------------------- def testcase_001(self): sheet_index = 1 row = 21 print("testcase_001动态删除:") #调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"uid": "744", "content": "接口在" + date + "测试发布纯文字"} # 获取发布接口token值 member_id = "744" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) post_id = result1["data"]["post_id"] payload = {"post_id": post_id} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------删除别人的动态---------------------------------- def testcase_002(self): sheet_index = 1 row = 22 print("testcase_002删除别人的动态:") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"uid": "744", "content": "接口在" + date + "测试发布纯文字"} member_id = "744" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) post_id = result1["data"]["post_id"] payload = {"post_id": post_id} # 获取token值 member_id = "748" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10003, result["code"]) print("code返回值:10003") #-----------------删除不存在的动态---------------------------------- def testcase_003(self): sheet_index = 1 row = 23 print("testcase_003删除不存在的动态:") member_id = "744" result = self.r.interface_requests(member_id, sheet_index, row) self.assertEqual(9999, result["code"]) print("code返回值:9999")
class CommentsDel(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------删除自己的评论---------------------------------- def testcase_001(self): sheet_index = 1 row = 24 print("testcase_001删除评论:") #1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"uid": "744", "content": "接口在" + date + "测试发布纯文字"} member_id = "744" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) post_id=result1["data"]["post_id"] # 2.调用评论接口,获得comment_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload2 = {"post_id": post_id, "content": "接口在" + date + "测试发布评论", "is_post": "N"} urlpart2 = '/comments/publish' result2 = self.r.interface_requests_data(member_id, urlpart2, payload2) comment_id = result2["data"]["comment_id"] print(comment_id) # 获取删除评论接口的token值 payload = {"comment_id": comment_id} result=self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------删除别人的评论---------------------------------- def testcase_002(self): sheet_index = 1 row = 25 print("testcase_002删除别人的评论:") member_id = "744" result=self.r.interface_requests(member_id,sheet_index,row) self.assertEqual(10003, result["code"]) print("code返回值:10003") #-----------------删除不存在的评论---------------------------------- def testcase_003(self): sheet_index=1 row=26 print("testcase_003删除不存在的评论:") member_id = "744" result=self.r.interface_requests(member_id,sheet_index,row) self.assertEqual(10003, result["code"]) print("code返回值:10003")
class CommentsPublish(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------回答的编辑---------------------------------- def testcase_001(self): sheet_index = 1 row = 76 print("testcase_001 回答的编辑:") # 调用发布接口发送一条动态,获取question_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # payload1 = { "content": "接口在" + date + "测试发布Q/A","category":"qa"} # member_id1 = "748" # urlpart1 = '/posts/publish' # result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) # global question_id # question_id = result1["data"]["question_id"] # print(question_id) # 调用QA回答接口发送一条回答,获取answer_id payload2 = { "question_id": "19183", "content": "接口在" + date + "测试回答Q/A" } member_id2 = "744" urlpart2 = '/answer/publish' result2 = self.r.interface_requests_data(member_id2, urlpart2, payload2) global answer_id answer_id = result2["data"]["answer_id"] print(answer_id) payload = { "answer_id": answer_id, "content": "接口在" + date + "测试编辑回答Q/A", "aztec_images": '[{"androidid":"1532313356301","imageUrl":"https://s3-us-west-2.amazonaws.com/images-omv/posts/1532313355871_767_android.jpg","radio":"1.0000","tag":1}]' } member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") # 回答成功后,删除回答,不然后面的接口不能再回答这个问题 payload1 = {"answer_id": answer_id} member_id1 = "744" urlpart = '/answer/delete' result1 = self.r.interface_requests_data(member_id1, urlpart, payload1)
class Brands(unittest.TestCase): def setUp(self): self.r=FuncRequests() #-----------------想法认可、想法取消---------------------------------- def testcase_001(self): sheet_index = 11 row = 7 print ("testcase_001想法认可:") # 调用想法管理列表,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"page": 1, "normal_member_id": 745} member_id1 = "34791" urlpart1 = '/opinion/manage' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) print(result1) list = result1["data"]["list"] post_id=list[0]["post_id"] print("post_id=",post_id) member_id = '34791' payload = {"post_id": post_id, "state": 1,"normal_member_id":745} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000") #-----------------想法取消认可---------------------------------- def testcase_002(self): sheet_index = 11 row = 8 print ("testcase_002想法取消认可:") # 调用想法管理列表,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"page": 1, "normal_member_id": 745} member_id1 = "34791" urlpart1 = '/opinion/manage' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) print(result1) list = result1["data"]["list"] post_id=list[0]["post_id"] print("post_id=",post_id) member_id = '34791' payload = {"post_id": post_id, "state": 0 ,"normal_member_id":745} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class VideoList(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------播放视频列表post---------------------------------- def testcase_001(self): sheet_index = 1 row = 17 print("testcase_001播放视频列表post:") # 1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "content": "接口在" + date + "测试发布视频", "video": "posts/149673555108234_748_ios.mp4", "video_cover": "posts/149673555108234_748_ios.jpg" } member_id = "744" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) post_id = result1["data"]["post_id"] print("post_id=", post_id) payload = {"post_id": post_id, "page": "1", "type": "post"} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------播放视频列表reveal---------------------------------- def testcase_002(self): sheet_index = 1 row = 18 print("testcase_002播放视频列表reveal:") # 1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "content": "接口在" + date + "测试发布视频", "video": "posts/149673555108234_748_ios.mp4", "video_cover": "posts/149673555108234_748_ios.jpg" } member_id = "744" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) post_id = result1["data"]["post_id"] payload = {"post_id": post_id, "page": "1", "type": "reveal"} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class Shop(unittest.TestCase): def setUp(self): self.r=FuncRequests() #-----------------管理我的店铺 - 设置店铺主图---------------------------------- def testcase_001(self): sheet_index = 12 row = 26 member_id='10394' print ("testcase_001管理我的店铺 - 设置店铺主图:") #调用图片/视频上传接口获得id obj1 = ({"path": "posts/1512710644871_767_android.jpg", "ratio": 1.23, "tag": 1},) images1 = json.dumps(obj1) payload1 = {"shop_id": "29388", "images":images1,"normal_member_id":745} urlpart1 = '/shop/picture/save' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) id=result1["data"]["id"] print(result1) print("id=",id) obj = ({"path": "posts/1512710644871_767_android.jpg", "ratio": 1, "tag": 1}) image = json.dumps(obj) payload = {"shop_id": "29388", "pid": id,"image":image,"normal_member_id":745} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000") #-----------------管理我的店铺 - 其他用户设置店铺主图---------------------------------- def testcase_002(self): sheet_index = 12 row = 47 member_id='34791' print ("testcase_002管理我的店铺 - 其他用户设置店铺主图:") #调用图片/视频上传接口获得id obj1 = ({"path": "posts/1512710644871_767_android.jpg", "ratio": 1.23, "tag": 1},) images1 = json.dumps(obj1) payload1 = {"shop_id": "29388", "images":images1,"normal_member_id":745} urlpart1 = '/shop/picture/save' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) id=result1["data"]["id"] print(result1) print("id=",id) obj = ({"path": "posts/1512710644871_767_android.jpg", "ratio": 1, "tag": 1}) image = json.dumps(obj) payload = {"shop_id": "29388", "pid": id,"image":image,"normal_member_id":745} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class CommentsLists(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------评论列表---------------------------------- def testcase_001(self): sheet_index = 1 row = 12 print("testcase_001评论列表:") # 1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"content": "接口在" + date + "测试发布纯文字"} member_id1 = "748" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) post_id = result1["data"]["post_id"] #2.调用评论接口进行评论 date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload2 = { "post_id": post_id, "content": "接口在" + date + "测试发布评论", "is_post": "N" } member_id2 = "423" urlpart2 = '/comments/publish' result2 = self.r.interface_requests_data(member_id2, urlpart2, payload2) print('评论的comment_id:', result2['data']['comment_id']) payload = {'post_id': post_id, 'page': 1} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------不存在的post---------------------------------- def testcase_002(self): sheet_index = 1 row = 13 print("testcase_002不存在的post:") member_id = "744" result = self.r.interface_requests(member_id, sheet_index, row) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class Brands(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------话题详情---------------------------------- def testcase_001(self): sheet_index = 11 row = 14 print("testcase_001话题详情:") # 调用话题发布,获取topic_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "brand_id": 1, "title": "接口发布的话题" + date, "topic_content": "用来被删除" } member_id1 = "744" urlpart1 = '/brandtopic/public' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) print(result1) topic_id = result1["data"]["brand_topic_id"] print("topic_id=", topic_id) member_id = '777' payload = {"topic_id": topic_id} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class PostsDetail(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------动态详情---------------------------------- def testcase_001(self): sheet_index = 1 row = 20 print("testcase_001动态详情:") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"uid": "744", "content": "接口在" + date + "测试发布纯文字"} member_id1 = "748" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) post_id = result1["data"]["post_id"] payload = {'post_id': post_id} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class Brands(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------设置默认地址---------------------------------- def testcase_001(self): sheet_index = 0 row = 104 print("testcase_001设置默认地址:") # 先调用添加收获地址借口哦添加一个地址,然后进行设置 date = int(time.time()) payload = { 'firstname': 'Yu', 'lastname': date, 'phone': '15800110123', 'country': 'China', 'state': 'shanghai', 'city': 'shanghai', 'street': 'No.1611,zhennan road', 'zip_code': '210110' } member_id = "744" urlpart = '/member/address/add' result1 = self.r.interface_requests_data(member_id, urlpart, payload) address_id = result1['data']['address_id'] payload = {'address_id': address_id} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class Praise(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------评论点赞---------------------------------- def testcase_001(self): sheet_index = 1 row = 53 print("testcase_001评论点赞:") # 1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "content": "接口在" + date + "测试发布纯文字"} member_id1 = "748" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) post_id = result1["data"]["post_id"] # 2.调用评论接口,获得comment_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload2 = {"post_id": post_id, "content": "接口在" + date + "测试发布评论", "is_post": "N"} urlpart2 = '/comments/publish' result2 = self.r.interface_requests_data(member_id1, urlpart2, payload2) global comment_id comment_id = result2["data"]["comment_id"] print(comment_id) #3.调用评论点赞接口 payload ={"comment_id": comment_id,'praise_state':1} member_id = "744" result=self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------取消点赞---------------------------------- def testcase_002(self): sheet_index = 1 row = 54 print("testcase_002取消点赞:") # 调用评论点赞接口 payload = {"comment_id": comment_id,'praise_state':0} member_id = "744" result=self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class List(unittest.TestCase): def setUp(self): self.member_id = '744' self.requests = FuncRequests() #-----------------用户个人post列表 all---------------------------------- def testcase_001(self): sheet_index = 0 row = 71 print("testcase001 用户个人post列表 all:") result = self.requests.interface_requests(self.member_id, sheet_index, row) self.assertEqual(10000, result['code']) print("code返回值:10000") self.assertEqual('', result['msg']) print("msg返回值:ok") #-----------------用户个人post列表第2页数据---------------------------------- def testcase_002(self): urlpart = "/member/posts" payload = {"page": "1", "type": "all", "member_id": "744"} result = self.requests.interface_requests_data(self.member_id, urlpart, payload) #先获取第一页最后一条post的post_id date = result['data']['list'] post_id = date[9]['post_id'] #原地址+当前接口地址拼接 payload = { "page": "2", "type": "all", "member_id": "744", "last_id": post_id } sheet_index = 0 row = 72 print("testcase002 用户个人post列表第2页数据:") result = self.requests.interface_requests_payload( self.member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000") self.assertEqual('', result['msg']) print("msg返回值:ok") # -----------------type不存在---------------------------------- def testcase_003(self): sheet_index = 0 row = 74 print("testcase003 type不存在:") result = self.requests.interface_requests(self.member_id, sheet_index, row) self.assertEqual(9999, result['code']) print("code返回值:9999") self.assertEqual('Time out.', result['msg']) print("msg返回值:Time out.")
class CommentsPublish(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------回答的删除---------------------------------- def testcase_001(self): sheet_index = 1 row = 77 print("testcase_001 回答的删除:") # 调用发布接口发送一条动态,获取question_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # payload1 = { "content": "接口在" + date + "测试发布Q/A","category":"qa"} # member_id1 = "748" # urlpart1 = '/posts/publish' # result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) # global question_id # question_id = result1["data"]["question_id"] # print(question_id) # 调用QA回答接口发送一条回答,获取answer_id payload2 = {"question_id": 19183, "content": "接口在" + date + "测试回答Q/A"} member_id2 = "744" urlpart2 = '/answer/publish' result2 = self.r.interface_requests_data(member_id2, urlpart2, payload2) global answer_id answer_id = result2["data"]["answer_id"] print(answer_id) payload = {"answer_id": answer_id} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") # 回答成功后,删除回答,不然后面的接口不能再回答这个问题 payload1 = {"answer_id": answer_id} member_id1 = "744" urlpart = '/answer/delete' result1 = self.r.interface_requests_data(member_id1, urlpart, payload1)
class Shop(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------设置置顶---------------------------------- def testcase_001(self): sheet_index = 12 row = 37 member_id = '10394' print("testcase_001设置置顶:") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "content": "接口在" + date + "测试发布纯文字", "normal_member_id": 745 } # 获取发布接口token值 urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) print(result1) global post_id post_id = result1["data"]["post_id"] print("post_id=", post_id) payload = { "shop_id": 29388, "post_id": post_id, "state": 1, "normal_member_id": 745 } result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000") #-----------------取消置顶---------------------------------- def testcase_002(self): sheet_index = 12 row = 38 member_id = '10394' print("testcase_001取消置顶:") payload = { "shop_id": 29388, "post_id": post_id, "state": 0, "normal_member_id": 745 } result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class Shop(unittest.TestCase): def setUp(self): self.requests = FuncRequests() self.member_id = 'none' #-----------------店铺纠错信息提交成功---------------------------------- def testcase_001(self): sheet_index = 12 row = 7 # 先注册新用户 # 先调用注册接口重新注册一个用户 nowTime = time.strftime("%Y%m%d_%H_%M_%S") nickname = 'test' + nowTime email = 'test' + nowTime + '@qq.com' print(email) member_id1 = 'none' payload1 = { 'email': email, 'password': '******', 'displayname': 'test', 'nickname': nickname, 'equipment_number': 'PE-TL10', } urlpart1 = '/sign/up' result1 = self.requests.interface_requests_data( member_id1, urlpart1, payload1) member_id = str(result1["data"]["member_id"]) print("member_id=", member_id) print("testcase_001提交店铺纠错信息:") obj = ({ "week": [1, 2], "start": "01:00", "close": "03:00" }, { "week": [4, 5], "start": "05:00", "close": "06:00" }) business_hours = json.dumps(obj) payload = { "shop_id": "1315", "tel": "18888066666", "address": "address111", "shop_name": "shop_name111", "business_hours": business_hours, "other": " 111" } result = self.requests.interface_requests_payload( member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class Post_share(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------第三方分享回调---------------------------------- #-----------------facebook:411568645883504 twitter:861855853032357889 vk:427871220-------------------------- def testcase_001(self): sheet_index = 6 row = 7 print("testcase_001第三方分享回调") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"content": "接口在" + date + "测试发布纯文字"} member_id = "744" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) post_id = result1["data"]["post_id"] print(post_id) #调用第三方分享回调接口 payload = {'platform': 'facebook', 'post_id': post_id} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------不支持的第三方---------------------------------- #-----------------facebook:411568645883504 twitter:861855853032357889 vk:427871220-------------------------- def testcase_002(self): sheet_index = 6 row = 8 print("testcase_002不支持的第三方") member_id = "744" result = self.r.interface_requests(member_id, sheet_index, row) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------分享app---------------------------------- #-----------------facebook:411568645883504 twitter:861855853032357889 vk:427871220-------------------------- def testcase_003(self): sheet_index = 6 row = 9 print("testcase_003分享app:") member_id = "744" result = self.r.interface_requests(member_id, sheet_index, row) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class Codecheck(unittest.TestCase): def setUp(self): self.member_id = '452' self.email = '*****@*****.**' self.requests = FuncRequests() #-----------------邮箱验证码校验正确forgot---------------------------------- def testcase_001(self): # -----------------先获取验证码--------------------------------- # 获取路径 urlpart = "/member/reset_send_mail" payload = {"email": self.email} sheet_index = 0 row = 79 result = self.requests.interface_requests_data(self.member_id, urlpart, payload) identifycode = result['data']['code'] print("testcase001 邮箱验证码校验正确forgot:") payload = {'email': self.email, 'code': identifycode, 'type': 'forgot'} sheet_index = 0 row = 90 result = self.requests.interface_requests_payload( self.member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000") self.assertEqual('', result['msg']) print("msg返回值:ok") #-----------------邮箱验证码校验失败---------------------------------- def testcase_002(self): print("testcase002 邮箱验证码校验失败:") payload = { "email": "*****@*****.**", "code": "111111", "type": "forgot" } sheet_index = 0 row = 92 result = self.requests.interface_requests_payload( self.member_id, sheet_index, row, payload) self.assertEqual(10009, result['code']) print("code返回值:10009") self.assertEqual('Verification Code Error', result['msg']) print("msg返回值:Verification Code Error")
class PostsReport(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------举报动态---------------------------------- def testcase_001(self): sheet_index = 1 row = 14 print("testcase_001举报动态:") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"uid": "744", "content": "接口在" + date + "测试发布纯文字"} # 获取发布接口token值 member_id1 = "748" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) global post_id post_id = result1["data"]["post_id"] payload = {"post_id": post_id, "reason_id": "1"} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------二次举报动态---------------------------------- def testcase_002(self): print(post_id) sheet_index = 1 row = 15 print("testcase_002二次举报动态:") payload = {"post_id": post_id, "reason_id": "1"} # 获取token值 member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10014, result["code"]) print("code返回值:10014")
class CommentsPublish(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------Q/A的关注---------------------------------- def testcase_001(self): sheet_index = 1 row = 69 print("testcase_001 Q/A的关注:") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"content": "接口在" + date + "测试发布Q/A", "category": "qa"} member_id1 = "748" urlpart = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart, payload1) print(result1) global question_id question_id = result1["data"]["question_id"] print(question_id) payload = {"question_id": question_id, "follow_state": 1} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") # -----------------Q/A的取消关注---------------------------------- def testcase_002(self): sheet_index = 1 row = 70 print("testcase_002 Q/A的取消关注:") payload = {"question_id": question_id, "follow_state": 0} # 获取token值 member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class Praise(unittest.TestCase): def setUp(self): self.r = FuncRequests() # 获取版本 self.version = Version().test_version() self.url = Url().test_url() #-----------------动态点赞/取消点赞---------------------------------- def testcase_001(self): sheet_index = 1 row = 8 print("testcase_001动态点赞/取消点赞:") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = {"uid": "744", "content": "接口在" + date + "测试发布纯文字"} member_id1 = "748" urlpart = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart, payload1) post_id = result1["data"]["post_id"] payload = {"post_id": post_id, "praise_state": 1} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------点赞/取消点赞不存在的post id---------------------------------- def testcase_002(self): sheet_index = 1 row = 10 print("testcase_002点赞/取消点赞不存在的post id:") member_id = "744" result = self.r.interface_requests(member_id, sheet_index, row) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class RewardsDescription(unittest.TestCase): def setUp(self): self.member_id = '744' self.requests = FuncRequests() #-----------------兑换商品详情---------------------------- def testcase_001(self): sheet_index = 8 row = 10 # 先调用积分接口获取goods_id,然后根据goods_id得到商品详情 urlpart = '/membership' payload = {} result1 = self.requests.interface_requests_data( self.member_id, urlpart, payload) goods_id = result1['data']['gifts'][0]['goods_id'] print("testcase001 兑换商品详情:") payload = {'goods_id': goods_id} result = self.requests.interface_requests_payload( self.member_id, sheet_index, row, payload) self.assertEqual(10000, result['code']) print("code返回值:10000")
class CommentsLists(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------动态收藏---------------------------------- def testcase_001(self): sheet_index = 1 row = 60 print("testcase_001评论列表:") # 1.调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "content": "接口在" + date + "测试发布纯文字"} member_id1 = "748" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) global post_id post_id = result1["data"]["post_id"] print(post_id) #2.调用动态收藏/取消收藏接口 payload = {'post_id': post_id, 'state': 1} member_id = "744" result=self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") #-----------------取消收藏---------------------------------- def testcase_002(self): sheet_index = 1 row = 61 payload = {'post_id': post_id, 'state': 0} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
def product(): # 调用新增产品接口发送一条动态,获取product_ids r = FuncRequests() for index in range(0, 2): member_id = '10394' obj = ({ "path": "posts/1512710644871_767_android.jpg", "ratio": 1.23, "tag": 1 }, ) images = json.dumps(obj) date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "name": "autotest" + date, "description": "description" + date, "images": images, "shop_id": 29388, "normal_member_id": 745 } # 获取发布接口token值 urlpart1 = '/product/add' result1 = r.interface_requests_data(member_id, urlpart1, payload1) product_id = result1["data"]["product_id"] return product_id
class CommentsPublish(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------news详情(review类型)---------------------------------- def testcase_001(self): sheet_index = 1 row = 96 print("testcase_001 news详情(review类型):") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "content": "接口在" + date + "测试发布review", "category": "review", "review_title": "review_title", "review_product": "review_product", "review_type": "review_type" } member_id1 = "744" urlpart1 = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) print(result1) global post_id post_id = result1["data"]["post_id"] print(post_id) payload = {"category": "review", "post_id": post_id} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") # -----------------news详情(news类型)---------------------------------- def testcase_002(self): sheet_index = 1 row = 97 print("testcase_002 news详情(news类型):") payload = {"category": "news", "post_id": "41931"} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") # -----------------hotnews详情(news类型)---------------------------------- def testcase_003(self): sheet_index = 1 row = 110 print("testcase_003news详情(hotnews类型):") payload = {"category": "news", "post_id": "41931"} member_id = "744" result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class CommentsPublish(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------用户对于Q/A的回答列表第一页数据---------------------------------- def testcase_001(self): sheet_index = 1 row = 82 print("testcase_001 用户对于Q/A的回答列表第一页数据:") # 调用发布接口发送一条动态,获取post_id date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload1 = { "content": "接口在" + date + "测试发布Q/A","category":"qa"} member_id1 = "748" urlpart = '/posts/publish' result1 = self.r.interface_requests_data(member_id1, urlpart, payload1) print(result1) global question_id question_id = result1["data"]["question_id"] print(question_id) # 调用QA回答接口发送一条回答 payload2 = {"question_id": question_id, "content": "接口在" + date + "测试回答Q/A"} member_id2 = "744" urlpart2 = '/answer/publish' result2 = self.r.interface_requests_data(member_id2, urlpart2, payload2) result2 = self.r.interface_requests_data('745', urlpart2, payload2) result2 = self.r.interface_requests_data('746', urlpart2, payload2) result2 = self.r.interface_requests_data('747', urlpart2, payload2) result2 = self.r.interface_requests_data('748', urlpart2, payload2) result2 = self.r.interface_requests_data('749', urlpart2, payload2) result2 = self.r.interface_requests_data('750', urlpart2, payload2) result2 = self.r.interface_requests_data('751', urlpart2, payload2) result2 = self.r.interface_requests_data('752', urlpart2, payload2) result2 = self.r.interface_requests_data('753', urlpart2, payload2) result2 = self.r.interface_requests_data('754', urlpart2, payload2) payload = {"question_id": question_id,"page": 1} member_id="744" result=self.r.interface_requests_payload(member_id, sheet_index, row, payload) global last_answer_id last_answer_id=result["data"]["last_answer_id"] print(last_answer_id) self.assertEqual(10000, result["code"]) print("code返回值:10000") # -----------------用户对于Q/A的回答列表第二页数据----------------------------------- def testcase_002(self): sheet_index = 1 row = 83 print("testcase_002 用户对于Q/A的回答列表二页数据:") member_id = "744" payload={"question_id":question_id,"page":2,"last_answer_id":last_answer_id} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000") # -----------------用户744的Q/A回答列表---------------------------------- def testcase_003(self): sheet_index = 1 row = 84 print("testcase_002 用户744的Q/A回答列表:") member_id = "744" payload={"question_id":question_id,"page":1,"member_id":member_id} result = self.r.interface_requests_payload(member_id, sheet_index, row, payload) self.assertEqual(10000, result["code"]) print("code返回值:10000")
class System_nation(unittest.TestCase): def setUp(self): self.r = FuncRequests() #-----------------抽奖活动 - 新用户参与抽奖--------------------------------- def testcase_001(self): sheet_index = 3 row = 8 #先调用注册接口重新注册一个用户 nowTime = time.strftime("%Y%m%d_%H_%M_%S") nickname = 'test' + nowTime email = 'test' + nowTime + '@qq.com' print(email) member_id1 = 'none' payload1 = { 'email': email, 'password': '******', 'displayname': 'test', 'nickname': nickname, 'equipment_number': 'PE-TL10', } urlpart1 = '/sign/up' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) print(result1) global member_id member_id = str(result1["data"]["member_id"]) print("member_id=", member_id) print("testcase_001抽奖活动 - 新用户参与抽奖:") # 获取EXcel路径 self.path = Url().test_path() # 路径 url = Url().test_url() self.obi = Read_ExcelData() self.base_url = self.obi.read_excel_data(sheet_index, row, 4) self.base_url1 = url + self.base_url # 获取版本 self.version = Version().test_version() payload = self.obi.read_excel_data_dict(sheet_index, row, 5) # 获取token值 base_url0 = Url().test_url() + '/token' serial_number = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) headers = { 'device': 'android ', 'version': self.version, 'lang': 'en', 'timestamp': '1493780505', 'login': member_id, "serial-number": serial_number, "company": "HUAWEI", "phone-model": "P10", "system-version": "system_version" } r = requests.post(base_url0, params=payload, headers=headers) content = r.json() print(content) token = content['token'] # 记录接口的请求时间 start = time.time() headers = { "device": "android ", "version": self.version, "lang": "en", "timestamp": "1493780505", "token": token, "login": member_id, "serial-number": serial_number, "company": "HUAWEI", "phone-model": "P10", "system-version": "system_version" } r = requests.post(self.base_url1, params=payload, headers=headers) result = r.json() format_result = json.dumps(result, indent=1) print(format_result) end = time.time() # 写入excel中 str_result = str(result) self.obj = Write_ExcelData() self.obj.write_excel_data(sheet_index, row, 6, result["code"], self.path) self.obj.write_excel_data(sheet_index, row, 7, result["msg"], self.path) if len(str_result) > 32767: self.obj.write_excel_data(sheet_index, row, 8, str_result[0:32767], self.path) self.obj.write_excel_data(sheet_index, row, 9, str_result[32767:], self.path) else: self.obj.write_excel_data(sheet_index, row, 8, str_result, self.path) self.obj.write_excel_data(sheet_index, row, 10, end - start, self.path) self.assertEqual(10000, result["code"]) print("code返回值:10000") # -----------------抽奖活动 - 老用户不能参与抽奖---------------------------------- def testcase_002(self): sheet_index = 3 row = 9 print("testcase_002抽奖活动 - 老用户不能参与抽奖:") member_id = "744" result = self.r.interface_requests(member_id, sheet_index, row) self.assertEqual(10100, result["code"]) print("code返回值:10100") #-----------------抽奖活动 - 已抽奖用户不能参与抽奖---------------------------------- def testcase_003(self): sheet_index = 3 row = 10 print("testcase_003抽奖活动 - 已抽奖用户不能参与抽奖:") # 获取EXcel路径 self.path = Url().test_path() # 路径 url = Url().test_url() self.obi = Read_ExcelData() self.base_url = self.obi.read_excel_data(sheet_index, row, 4) self.base_url1 = url + self.base_url # 获取版本 self.version = Version().test_version() payload = self.obi.read_excel_data_dict(sheet_index, row, 5) # 获取token值 base_url0 = Url().test_url() + '/token' serial_number = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) headers = { 'device': 'android ', 'version': self.version, 'lang': 'en', 'timestamp': '1493780505', 'login': member_id, "serial-number": serial_number, "company": "HUAWEI", "phone-model": "P10", "system-version": "system_version" } r = requests.post(base_url0, params=payload, headers=headers) content = r.json() print(content) token = content['token'] # 记录接口的请求时间 start = time.time() headers = { "device": "android ", "version": self.version, "lang": "en", "timestamp": "1493780505", "token": token, "login": member_id, "serial-number": serial_number, "company": "HUAWEI", "phone-model": "P10", "system-version": "system_version" } r = requests.post(self.base_url1, params=payload, headers=headers) result = r.json() format_result = json.dumps(result, indent=1) print(format_result) end = time.time() # 写入excel中 str_result = str(result) self.obj = Write_ExcelData() self.obj.write_excel_data(sheet_index, row, 6, result["code"], self.path) self.obj.write_excel_data(sheet_index, row, 7, result["msg"], self.path) if len(str_result) > 32767: self.obj.write_excel_data(sheet_index, row, 8, str_result[0:32767], self.path) self.obj.write_excel_data(sheet_index, row, 9, str_result[32767:], self.path) else: self.obj.write_excel_data(sheet_index, row, 8, str_result, self.path) self.obj.write_excel_data(sheet_index, row, 10, end - start, self.path) self.assertEqual(10099, result["code"]) print("code返回值:10099") #-----------------抽奖活动 - 用户自己不能使用自己的邀请码进行抽奖---------------------------------- def testcase_004(self): sheet_index = 3 row = 11 # 先调用注册接口重新注册一个用户 nowTime = time.strftime("%Y%m%d_%H_%M_%S") nickname = 'test' + nowTime email = 'test' + nowTime + '@qq.com' print(email) member_id1 = 'none' payload1 = { 'email': email, 'password': '******', 'displayname': 'test', 'nickname': nickname, 'equipment_number': 'PE-TL10', } urlpart1 = '/sign/up' result1 = self.r.interface_requests_data(member_id1, urlpart1, payload1) print(result1) member_id = str(result1["data"]["member_id"]) print("member_id=", member_id) # 先调用个人中心接口获得新注册用户的邀请码 payload1 = {'member_id': member_id} urlpart1 = '/member/center' result1 = self.r.interface_requests_data(member_id, urlpart1, payload1) print(result1) invite_code = str(result1["data"]["invite_code"]) print("invite_code=", invite_code) print("testcase_004抽奖活动 - 用户自己不能使用自己的邀请码进行抽奖:") # 获取EXcel路径 self.path = Url().test_path() # 路径 url = Url().test_url() self.obi = Read_ExcelData() self.base_url = self.obi.read_excel_data(sheet_index, row, 4) self.base_url1 = url + self.base_url # 获取版本 self.version = Version().test_version() payload = {'invitation_code': invite_code} # 获取token值 base_url0 = Url().test_url() + '/token' serial_number = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) headers = { 'device': 'android ', 'version': self.version, 'lang': 'en', 'timestamp': '1493780505', 'login': member_id, "serial-number": serial_number, "company": "HUAWEI", "phone-model": "P10", "system-version": "system_version" } r = requests.post(base_url0, params=payload, headers=headers) content = r.json() print(content) token = content['token'] # 记录接口的请求时间 start = time.time() headers = { "device": "android ", "version": self.version, "lang": "en", "timestamp": "1493780505", "token": token, "login": member_id, "serial-number": serial_number, "company": "HUAWEI", "phone-model": "P10", "system-version": "system_version" } r = requests.post(self.base_url1, params=payload, headers=headers) result = r.json() format_result = json.dumps(result, indent=1) print(format_result) end = time.time() # 写入excel中 str_result = str(result) self.obj = Write_ExcelData() self.obj.write_excel_data(sheet_index, row, 6, result["code"], self.path) self.obj.write_excel_data(sheet_index, row, 7, result["msg"], self.path) if len(str_result) > 32767: self.obj.write_excel_data(sheet_index, row, 8, str_result[0:32767], self.path) self.obj.write_excel_data(sheet_index, row, 9, str_result[32767:], self.path) else: self.obj.write_excel_data(sheet_index, row, 8, str_result, self.path) self.obj.write_excel_data(sheet_index, row, 10, end - start, self.path) self.assertEqual(10102, result["code"]) print("code返回值:10102")