def test_02_get_question(): # 获取问题详情 questionid = read_file('./tmp/questionid.txt') u = datas[1][2] h = eval(datas[1][3]) p = eval(datas[1][4]) res = requests.get(url=u, headers=h, params=p) assert res.status_code == datas[1][5] assert res.json()['status'] == datas[1][6]
def test_03_deletequestion(): r = read_excel('data\\测谈网接口测试用例.xlsx','Sheet1') u = r[18][2] d = eval(r[18][3]) #字符串转换成字典 h = eval(r[18][4]) res = requests.post(url=u, json=d, headers=h) assert res.status_code == r[18][6] assert res.json()['status'] == r[18][7] sql = 'select * from t_article where id="{}"'.format(read_file('./conf/user_qid.txt')) assert len(query(sql)) == 0
def test_04_yhdelquestion(): data = read_excel("data\测谈网测试用例.xlsx", "问题") u = data[3][2] h = eval(data[3][5]) h["token"] = read_file() d = eval(data[3][4]) d["qid"] = questionId res = requests.post(url=u, json=d, headers=h) assert res.status_code == 200 assert res.json()["status"] == data[3][6] sql = "select status from t_questions where id = '{}' ".format(questionId) assert query(sql)[0][0] == 1
def test_05_comment_update(): # 修改评论 u = datas[4][2] h = eval(datas[4][3]) d = eval(datas[4][4]) res = requests.post(url=u,headers=h,json=d) assert res.status_code == datas[4][5] assert res.json()['status'] == datas[4][6] sql = "select * from t_user_comments where id={} and comment='{}'".format(read_file('./tmp/inspirer_comment_id.txt'),d['comment']) assert len(query(sql)) != 0
def test_06_comment_delete(): # 删除评论 u = datas[5][2] h = eval(datas[5][3]) d = eval(datas[5][4]) res = requests.post(url=u,headers=h,json=d) assert res.status_code == datas[5][5] assert res.json()['status'] == datas[5][6] sql = "select * from t_user_comments where id={} and status='1'".format(read_file('./tmp/question_comment_id.txt')) assert len(query(sql)) != 0
def test_04_deletearticle(): data = read_excel("data\测谈网测试用例.xlsx", "文章") u = data[4][2] h = eval(data[4][5]) h["token"] = read_file() d = eval(data[4][4]) d["aid"] = articleId res = requests.post(url=u, json=d, headers=h) assert res.status_code == 200 assert res.json()["status"] == data[4][6] sql = "select status from t_article where id = '{}' ".format(articleId) assert int(query(sql)[0][0]) == 1
def test_03_deletearticle(): r = read_excel('data\\测谈网接口测试用例.xlsx', 'Sheet1') u = r[6][2] d = eval(r[6][3]) h = eval(r[6][4]) res = requests.post(url=u, json=d, headers=h) assert res.status_code == r[6][6] assert res.json()['status'] == r[6][7] sql = 'select status from t_article where id="{}"'.format( read_file('./conf/user_articleid.txt')) assert query(sql)[0] == ('1', )
def test_02_updatearticle(): r = read_excel('data\\测谈网接口测试用例.xlsx', 'Sheet1') u = r[5][2] d = eval(r[5][3]) h = eval(r[5][4]) res = requests.post(url=u, json=d, headers=h) assert res.status_code == r[5][6] assert res.json()['status'] == r[5][7] sql = 'select * from t_article where id="{}" and title="{}"'.format( read_file('./conf/user_articleid.txt'), d['title']) assert len(query(sql)) != 0
def test_03_updateyhlg(): data = read_excel("data\测谈网测试用例.xlsx", "灵感") u = data[3][2] h = eval(data[3][5]) h["token"] = read_file() d = eval(data[3][4]) d["iid"] = inspirerId res = requests.post(url=u, json=d, headers=h) print(res.json()) assert res.status_code == 200 assert res.json()["status"] == data[3][6] sql = "select * from t_inspirer where content = '{}' ".format(d["content"]) assert query(sql) != 0
def test_01_fblg(): url = "http://118.24.105.78:2333/inspirer/new" data = {"content": "内容", "ximg": "dsfsdf.jpg"} header = {"Content-Type": "application/json", "token": read_file()} res = requests.post(url=url, json=data, headers=header) print(res.text) assert res.status_code == 200 assert res.json()["status"] == 200 # 数据库查询 id = res.json()["data"]["inspirerid"] sql = "select * from t_inspirer where id={}".format(id) assert len(query(sql)) == 1
def test_06_qxyhfollows(): data = read_excel("data\测谈网测试用例.xlsx", "关注") u = data[3][2] h = eval(data[3][5]) h["token"] = read_file() d = eval(data[3][4]) res = requests.post(url=u, json=d, headers=h) print(res.json()) assert res.status_code == 200 assert res.json()["status"] == data[3][6] sql = "select fstatus from t_coures_user_status where uid = '{}' and cid = '{}' ".format( 1333385544, d["fid"]) assert int(query(sql)[0][0]) == 1
def test_01_newquestion(): r = read_excel('data\\测谈网接口测试用例.xlsx','Sheet1') u = r[16][2] d = eval(r[16][3]) #字符串转换成字典 h = eval(r[16][4]) res = requests.post(url=u, json=d, headers=h) assert res.status_code == r[16][6] assert res.json()['status'] == r[16][7] qid = res.json()['data']['questionid'] write_file('./conf/user_qid.txt', str(qid)) sql = "select * from t_questions where id = '{}'".format(read_file('./conf/user_qid.txt')) assert len(query(sql)) != 0
def test_04_yhtquestion(): data = read_excel("data\测谈网测试用例.xlsx", "问题") u = data[1][2] h = eval(data[1][5]) h["token"] = read_file() d = eval(data[1][4]) res = requests.post(url=u, json=d, headers=h) print(res.json()) global questionId questionId = res.json()["data"]["questionid"] assert res.status_code == 200 assert res.json()["status"] == data[1][6] sql = "select * from t_questions where id = '{}' ".format(questionId) assert query(sql) != 0
def test_01_fblg(): # 构造请求 url = 'http://118.24.105.78:2333/inspirer/new' data = {"content": "内ssss容", "ximg": "dsfsdf.jpg"} h1 = {"Content-Type": "application/json", "token": read_file()} res = requests.post(url=url, json=data, headers=h1) print(res.text) # 断言 assert res.status_code == 200 assert res.json()['status'] == 200 # 数据库查询 inspirerid = res.json()['data']['inspirerid'] sql = "select * from t_inspirer where id={}".format(inspirerid) assert len(query(sql)) == 1
def test_01_newarticle(): r = read_excel('data\\测谈网接口测试用例.xlsx', 'Sheet1') u = r[4][2] d = eval(r[4][3]) h = eval(r[4][4]) res = requests.post(url=u, json=d, headers=h) assert res.status_code == r[4][6] assert res.json()['status'] == r[4][7] articleid = res.json()['data']['articleid'] write_file('./conf/user_articleid.txt', str(articleid)) sql = 'select * from t_article where id="{}"'.format( read_file('./conf/user_articleid.txt')) assert len(query(sql)) != 0
def test_01_new_aritcle(): """ 新建文章case """ u = "http://118.24.105.78:2333/article/new" h = {"Content-Type":"application/json","token":read_file()} d = {"title":"为什么要学习测试","content":"内容","tags":"测试123","brief":"介绍","ximg":"dsfsdf.jpg"} res = requests.post(url=u, headers=h, json=d) assert res.status_code == 200 assert res.json()["status"] == 200 print(res.text) # 数据库查询 aid = res.json()["data"]["articleid"] sql = "select * from t_article where id = {}".format(aid) assert len(query(sql)) != 0
def test_01_new_question(): # 新建问题 u = datas[0][2] h = eval(datas[0][3]) d = eval(datas[0][4]) res = requests.post(url=u, headers=h, json=d) assert res.status_code == datas[0][5] assert res.json()['status'] == datas[0][6] write_file('./tmp/questionid.txt', res.json()['data']['questionid']) questionid = read_file('./tmp/questionid.txt') sql = "select * from t_questions where id={} and title='{}' and content='{}' and tags='{}' and brief='{}' and ximg='{}'".format( questionid, d['title'], d['content'], d['tags'], d['brief'], d['ximg']) assert len(query(sql)) != 0
def test_01_xwz(): u = "http://192.144.148.91:2333/article/new" h = { "Content-Type": "application/json", "token": read_file("user_token.txt") } d = { "title": "为什么要学习测试", "content": "内容", "tags": "测试1234", "brief": "介绍", "ximg": "dsfsdf.jpg" } res = requests.post(url=u, json=d, headers=h) print(res) #断言 assert res.status_code == 200 assert res.json()["status"] == 200 sql = "select * from t_article where id='{}'".format( res.json()["data"]["articleid"]) assert len(query(sql)) != 0