def test_get_message_all_topics(get_accesstoken): all_url = '/messages' topics = Topics(all_url) r = topics.get_message_all_topics(accesstoken=get_accesstoken) print(r.url) res = r.json() assert res['success'] == True
def test_post_fabulous_topics(get_accesstoken, get_reply_id): fabulous_url = '/reply/' + get_reply_id + '/ups' topics = Topics(fabulous_url) r = topics.post_fabulous_topics(accesstoken=get_accesstoken) res = r.json() assert res['success'] == True assert res['action'] == "up"
def test_get_topic_detail(get_topic_id): print("get_topic_id===", get_topic_id) url = '/topic/' + get_topic_id t = Topics(url) r = t.get_topic_detail() print(r.json())
def test_post_message_mark_all_topics(get_accesstoken): mark_url = '/message/mark_all' topics = Topics(mark_url) r = topics.post_message_mark_all_topics(accesstoken=get_accesstoken) print(r.url) res = r.json() assert res['success'] == True
def test_post_create_topic(tab, title, content, token=default_token): url = '/topics' topic = Topics(url) res = topic.post_create_topic(token, title, tab, content) assert res.status_code == 200 r = res.json() assert r['success'] == True
def test_post_verify_topics(get_accesstoken): verify_url = '/accesstoken' topics = Topics(verify_url) r = topics.post_verify_topics(accesstoken=get_accesstoken) print(r.url) res = r.json() assert res['success'] == True assert res['loginname'] == 'user1'
def test_get_details_topics(get_accesstoken, get_topic_id): #print(get_topic_id) details_url = '/topic/' + str(get_topic_id) #print('details_url========',details_url) topics = Topics(details_url) r = topics.get_details_topics(accesstoken=get_accesstoken) res = r.json() assert r.status_code == 200
def test_index_page(): url = "/topics" topics = Topics(url) print("----url----",topics.url) res = topics.get_index_topics() r = res.json() assert len(r['data']) == 20 assert res.status_code == 200
def test_get_message_n_topics(get_accesstoken): n_url = '/message/count' topics = Topics(n_url) r = topics.get_message_n_topics(accesstoken=get_accesstoken) print(r.url) res = r.json() assert res['success'] == True #这个3是通过postman发送借口获取的,是否能通过代码的方式来获取? assert res['data'] == 3
def test_post_topic(token, title, tab, content): url = "/topics" t = Topics(url) r = t.post_create_topic(token, title, tab, content) print(r.json()) res = r.json() topic_id = res['topic_id'] print("topic_id====", topic_id) assert r.status_code == 200 assert res['success'] == True
def get_reply_id(get_accesstoken, get_topic_id): print('test_first_comment_csv============', test_first_comment_csv) first_url = '/topic/' + get_topic_id + '/replies' topics = Topics(first_url) r = topics.post_first_comment_topics(accesstoken=get_accesstoken, content='pppppppppppppppppppppp') res = r.json() reply_id = res['reply_id'] print('get_reply_id==========', reply_id) return (reply_id)
def test_post_cancel_topics(get_accesstoken, get_topic_id): cancel_url = '/topic_collect/de_collect' topics = Topics(cancel_url) r = topics.post_cancel_topics(accesstoken=get_accesstoken, topic_id=get_topic_id) print(r.url) print(r) res = r.json assert r.status_code == 200 assert res['success'] == True
def test_post_first_comment_topics(get_accesstoken, get_topic_id, content): print('test_first_comment_csv============', test_first_comment_csv) first_url = '/topic/' + get_topic_id + '/replies' topics = Topics(first_url) reply_id = [] for c in test_first_comment_csv: print('c===========', c) r = topics.post_first_comment_topics(accesstoken=get_accesstoken, content=c) assert r.status_code == 200
def test_post_create_topics(get_accesstoken, title, tab, content): create_url = '/topics' topics = Topics(create_url) r = topics.post_create_topics(title=title, tab=tab, content=content, accesstoken=get_accesstoken) res = r.json() print('test_post_create_topics=============', res['topic_id']) assert r.status_code == 200 assert res['success'] == True
def test_post_message_mark_one_topics(get_topic_id, get_accesstoken): print("msg_id===============", get_topic_id) mark_one_url = '/message/mark_one/' + get_topic_id topics = Topics(mark_one_url) r = topics.post_message_mark_one_topics(accesstoken=get_accesstoken) print(r.url) res = r.json() assert res['success'] == True #[['comment1111111111111111111111111111111111111111'], ['comment2222222222222222222222222222222222222222'], ['comment3333333333333333333333333333333333333333']]
def test_get_collect_topics(loginname): print('test_loginname_csv', test_loginname_csv) for name in loginname: print('name', name) collect_url = '/topic_collect/' + name topics = Topics(collect_url) r = topics.get_collect_topics() print(r.url) res = r.json() assert r.status_code == 200 all_data = res['data']
def get_topic_id(): """ fixture pytest的测试套件,可以作为基础操作方法被调用 """ url = "/topics" t = Topics(url) r = t.post_create_topic("3333a0fb-6dd8-439e-813b-2c3a5213a154", "11111111111", "ask", "xxxxxxxxxxxxx") print(r.json()) res = r.json() topic_id = res['topic_id'] return topic_id
def test_post_collection_topics(get_accesstoken, get_topic_id): print(get_accesstoken, get_topic_id) collection_url = '/topic_collect/collect' topics = Topics(collection_url) r = topics.post_collection_topics(accesstoken=get_accesstoken, topic_id=get_topic_id) print(r.url) # r_text = r.text # print(r_text) r_json = r.json() assert r.status_code == 200 assert r_json['success'] == True
def test_get_data_topics(limit, tab): url = '/topics' topics = Topics(url) r = topics.get_data_topics(limit, tab) res = r.json() #print(res) assert r.status_code == 200 assert res['success'] == True assert len(res['data']) == int(limit) all_data = res['data'] for data in all_data: assert data['tab'] == tab
def test_index_page(limit, tab): url = "/topics" topics = Topics(url) print("-----------", topics.url) res = topics.get_index_topics(limit, tab) r = res.json() assert len(r['data']) == limit assert r['success'] == True assert res.status_code == 200 all_data = r["data"] for data in all_data: assert data["tab"] == tab
def test_index_page(limit, tab): url = "/topics" topics = Topics(url) # assert_limit=1 # tab = 'ask' res = topics.get_index_topics(limit, tab) r = res.json() assert len(r['data']) == int(limit) # r['data'][0]['tab'] == 'ask' assert res.status_code == 200 all_data = r['data'] for data in all_data: assert data['tab'] == tab
def test_post_second_comment_topics(get_accesstoken, get_topic_id, get_reply_id): second_url = '/topic/' + get_topic_id + '/replies' topics = Topics(second_url) print('reply_id1===========', get_reply_id) r = topics.post_second_comment_topics( accesstoken=get_accesstoken, content='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', reply_id=get_reply_id) res = r.json() print('reply_id2===========', res['reply_id']) assert r.status_code == 200 assert res['reply_id'] != get_reply_id
def test_post_update_topics(get_accesstoken, title, tab, content, get_topic_id): update_url = '/topics/update' topics = Topics(update_url) r = topics.post_update_topics(accesstoken=get_accesstoken, title=title, tab=tab, content=content, topic_id=get_topic_id) res = r.json() #print(res) assert r.status_code == 200 assert res['success'] == True
def get_topic_id(get_accesstoken): create_url = '/topics' topics = Topics(create_url) r = topics.post_create_topics( title='11111111111111111111111111111', tab='ask', content='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', accesstoken=get_accesstoken) print(r) res = r.json() print(res) topic_id = res['topic_id'] print('get_topic_id=============', topic_id) return topic_id
def test_get_user_topics(loginname): print('test_loginname_csv', test_loginname_csv) for name in loginname: print('name', name) collect_url = '/user/' + name topics = Topics(collect_url) r = topics.get_collect_topics() print(r.url) res = r.json() assert r.status_code == 200 assert res['success'] == True recent_topics = res['data']['recent_topics'] for user in recent_topics: assert user['author']['loginname'] == name recent_replies = res['data']['recent_topics'] for user in recent_replies: assert user['author']['loginname'] == name
def test_update_topic(tab, title, content, token=default_token): # create a content t1 = Topics('/topics') r = t1.post_create_topic(token=default_token, tab="ask", title="titlewithCreated", content="helloworld.........") res = r.json() print(res) topic_id = res['topic_id'] # update t2 = Topics('/topics/update') r2 = t2.post_update_topic(token, topic_id, tab, title, content) print(r2.json())
def test_update_topic(token, title, tab, content, get_topic_id): url = "/topics/update" t = Topics(url) r = t.post_update_topic(token, get_topic_id, title + "00", tab, content + "11") print(r.json())