Exemplo n.º 1
0
def test_03_deleteyhlg():
    data = read_excel("data\测谈网测试用例.xlsx", "灵感")
    u = data[4][2]
    h = eval(data[4][5])
    h["token"] = read_file()
    d = eval(data[4][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[4][6]
    sql = "select status from t_inspirer where id = '{}' ".format(d["iid"])
    print(query(sql))
    assert int(query(sql)[0][0]) == 1
Exemplo n.º 2
0
def get_areas(mysql_conf, article_guid):
    sql = '''SELECT `base_area`.`name` FROM `base_area` WHERE `base_area`.`id` IN ( 
                    SELECT `base_articlearea`.`area_id` FROM `base_articlearea` WHERE `base_articlearea`.`article_id` = %s 
                ) '''
    areas = query(sql=sql, db_config=mysql_conf, list1=(article_guid, ))

    return list(map(lambda x: {'name': x[0]}, areas))
Exemplo n.º 3
0
def get_categories(mysql_conf, article_guid):
    sql = '''SELECT `base_category`.`name` FROM `base_category` WHERE `base_category`.`id` IN ( 
                    SELECT `base_articlecategory`.`category_id` FROM `base_articlecategory` WHERE `base_articlecategory`.`article_id` = %s 
                ) '''
    categories = query(sql=sql, db_config=mysql_conf, list1=(article_guid, ))

    return list(map(lambda x: {'name': x[0]}, categories))
Exemplo n.º 4
0
def get_articles(mysql_conf, start, length):
    sql = 'SELECT `guid`, `title`, `url`, `pubtime`, `source`, `score`, `risk_keyword`, `invalid_keyword` FROM `base_article` WHERE `status` <> -1 ORDER BY `pubtime` DESC LIMIT %s, %s'
    articles = query(sql=sql, db_config=mysql_conf, list1=(
        start,
        length,
    ))

    return articles
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
0
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
Exemplo n.º 8
0
def test_02_login_success():
    data = read_excel("data\测谈网测试用例.xlsx", "登录")
    u = data[0][2]
    d = eval(data[0][4])
    h = eval(data[0][5])
    res = requests.post(url=u, json=d, headers=h)
    print(res.json())
    assert res.status_code == 200
    assert res.json()["status"] == int(data[0][6])
    #数据库检验
    sql = "select * from t_user where username = '******'".format(d["username"])
    assert query(sql) != 0
    save_file(token=res.json()["data"]["token"])
Exemplo n.º 9
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
Exemplo n.º 10
0
def test_03_yhfblg():
    data = read_excel("data\测谈网测试用例.xlsx", "灵感")
    u = data[2][2]
    h = eval(data[2][5])
    h["token"] = read_file()
    d = eval(data[2][4])
    res = requests.post(url=u, json=d, headers=h)
    print(res.json())
    global inspirerId
    inspirerId = res.json()["data"]["inspirerid"]
    assert res.status_code == 200
    assert res.json()["status"] == data[2][6]
    sql = "select * from t_inspirer where content = '{}' ".format(d["content"])
    assert query(sql) != 0