示例#1
0
文件: all.py 项目: milian0711/OMS_
def get_location(post_url):
    """
    获取302跳转的url
    """
    ID_card = identify_code(Conf.IC_url)
    lt = get_lt(post_url)
    print lt
    postdata = {
        'username': Conf.username,
        'password': Conf.password,
        '_eventId': "submit",
        'lt': lt,
        'j_captcha_response': ID_card
    }
    resp = session.post(post_url,
                        data=postdata,
                        headers=Conf.headers,
                        allow_redirects=False,
                        verify=False)
    # print requests.head(post_url).headers
    time.sleep(2)
    mylocation = resp.headers['location']

    logging.info("mylocation is %s" % mylocation)
    return mylocation
示例#2
0
文件: all.py 项目: milian0711/OMS_
def login_page(location_url):
    """
    获取最新生成jessonid的url
    """
    resp = session.get(location_url,
                       headers=Conf.headers,
                       allow_redirects=False,
                       verify=False)
    oms_url = resp.headers['location']
    logging.info("oms_url is %s " % oms_url)
    oms_page = session.get(oms_url, headers=Conf.headers)
示例#3
0
def test_addComment():
    """
    添加评论功能
    method:添加评论
    objId:被评论的新闻ID
    userNickName: 用户昵称名字
    content:评论内容
    objectName: 新闻标题
    """
    postdata = {
        "method": "comment",
        "objId": "18590933",
        "userNickName": "杭州游客",
        "content": "py添加评论",
        "objectName": "绝美星空!看到纪念碑谷的银河拱桥,我内心被点亮了..."
    }
    resp = session.post(Conf.addComment_url,
                        data=postdata,
                        headers=Conf.headers)
    logging.info("postdata is %s" % postdata)
    logging.info("response is %s" % resp)
    logging.info("response is %s" % resp.json())
    result = str(resp.json()['result'])
    if str(result) == '0000':
        logging.info("linkSearch result success")
示例#4
0
文件: all.py 项目: milian0711/OMS_
def test_addComment():
    """
    添加评论功能
    method:添加评论
    objId:被评论的新闻ID
    userNickName: 用户昵称名字
    content:评论内容
    objectName: 新闻标题
    """

    postdata = {
        "method": "comment",
        "objId": str(Conf.newsID),
        "userNickName": test_getNickname(),
        "content": "oms add comments",
        "objectName": "这一“充电焦虑”怎么破解?国家放出大招"
    }
    resp = session.post(Conf.addComment_url,
                        data=json.dumps(postdata),
                        headers=Conf.headers)
    logging.info("postdata is %s" % postdata)
    logging.info("response is %s" % resp)
    logging.info("response is %s" % resp.json())
    result = str(resp.json()['result'])
    if str(result) == '0000':
        logging.info("linkSearch result success")
示例#5
0
def test_change(change_url, id):
    """
    长链转短链接口,有以下几种情形:
    1、ID为普通新闻类型
    2、ID为节目推荐类型
    3、ID带有空格
    4、ID带有符号
    5、ID不存在
    """
    # qs = [17884373, 17754437, '185374 25', '185374#25', 185374]
    param_list = [('17884373', 'True'), ('17754437', 'False'),
                  ('185374 25', 'False'), ('185374#25', 'False'),
                  (185374, 'False')]
    for q in param_list:
        # data = {"keyWord": id}
        data = dict(keyWord=q[0])
        resp = session.post(change_url, data=data, headers=Conf.headers)
        logging.info("input id is: %s", q[0])
        logging.info("result is:%s", resp.json())
        # 由于q[1]类型为str, 而result类型为bool, 因而需要转换
        result = str(resp.json()['success'])
        # eq_(q[1], result, '{0}!={1}'.format(expect, result))
        if q[1] == result:
            logging.info('change_test success')
        else:
            logging.info('change_test fail')
示例#6
0
文件: all.py 项目: milian0711/OMS_
def test_transExternalImg():
    """
    外部图片地址转换为服务器图片地址
    contID:新闻ID
    columname:IMAGES
    contText:图片标签
    :return:
    验证返回值是否为true
    """ ""
    contID = Conf.newsID
    columnName = "IMAGES"
    # 由于浏览器对传入的contText进入了渲染,传的时候需要传入源标签的内容
    # contText = '<img+src="http://www.cs.com.cn/ssgs/fcgs/201712/W020171201369316897595.jpg"+alt=""+/>'
    contText = '<img src="http://www.cs.com.cn/ssgs/fcgs/201712/W020171201369316897595.jpg" alt="" />'
    # 包含4种类型(bmp,png,jpg,gif)的图片转换
    contText = '<img src="http://www.cs.com.cn/ssgs/fcgs/201712/W020171201369316897595.jpg" alt="" /><img src="http://www.cr173.com/up/2014-9/14109191026919813.gif" alt="" /><img src="http://www.sucaitianxia.com/sheji/pic/200706/20070620224220832.bmp" alt="" /><img alt="" src="https://upload.wikimedia.org/wikipedia/commons/9/98/SAKURA.png" />'

    postdata = {
        "contId": contID,
        "columnName": columnName,
        "contText": contText
    }
    resp = session.post(Conf.transfer_url, data=postdata, headers=Conf.headers)
    logging.info("postdata is %s" % postdata)
    logging.info("response is %s" % resp.json())
    result = str(resp.json()['success'])
    logging.info("transExternalImg result is %s" % result)
示例#7
0
def test_importance():
    """
    设置权重功能
    nodeId:栏目ID
    check:状态是否是已审核
    contIds: 新闻ID
    importanceValue:权重值
    cleanImportanceTime: 权重失效时间
    """
    setting_time = generateTime(20)

    postdata = {
        "nodeId": "2012678",
        "check": "1",
        "contIds": "18537425",
        "importanceValue": "5",
        "cleanImportanceTime": setting_time
    }
    resp = session.post(Conf.updateImportance_url,
                        data=postdata,
                        headers=Conf.headers)
    logging.info("postdata is %s" % postdata)
    logging.info("response is %s" % resp.json())
    result = str(resp.json()['message'])
    logging.info("updateImportance result is %s" % result)
示例#8
0
文件: all.py 项目: milian0711/OMS_
def test_addFavoriteNews():
    """
    添加新闻到收藏夹
    newsId: 待收藏的新闻ID
    """
    postdata = {"newsId": str(Conf.newsID)}
    resp = session.post(Conf.addFavoriteNews_url,
                        data=json.dumps(postdata),
                        headers=Conf.headers)
    result = str(resp.json()['success'])
    logging.info("response is %s" % result)
    if bool(result) == True:
        logging.info("addFavoriteNews success")
    else:
        logging.info("addFavoriteNews failure")
示例#9
0
def test_linkSearch():
    """
    链接到功能测试
    rowsContData:待链接的新闻ID
    rowsNodeData:链接到的栏目ID
    isCopy: 是否链接
    """
    postdata = {
        "rowsContData": '["18458908"]',
        "rowsNodeData": '["2008364"]',
        "isCopy": "true"
    }
    resp = session.post(Conf.link_url, data=postdata, headers=Conf.headers)
    logging.info("postdata is %s" % postdata)
    logging.info("response is %s" % resp.json())
    result = str(resp.json()['success'])
    logging.info("linkSearch result is %s" % result)
示例#10
0
文件: all.py 项目: milian0711/OMS_
def test_cancelFavoriteNews():
    """
    从我的收藏夹中取消收藏
    newsId: 待取消的新闻ID
    """
    postdata = {"newsId": str(Conf.newsID)}
    resp = session.post(Conf.cancelFavoriteNews_url,
                        data=json.dumps(postdata),
                        headers=Conf.headers)
    result = str(resp.json()['success'])
    logging.info("response is %s" % result)
    # 由于result为str类型,在判断时需要进行转换
    # logging.info("type response is %s" % type(result))

    if bool(result) == True:
        logging.info("cancelFavoriteNews success")
    else:
        logging.info("cancelFavoriteNews failure")
示例#11
0
def test_copySearch():
    """
    复制到功能测试
    rowsContData:待复制的新闻ID
    rowsNodeData:复制到的栏目ID
    isCopy: 是否复制
    """
    postdata = {
        "rowsContData": '["18751122"]',
        "rowsNodeData": '["2008364"]',
        "isCopy": "true"
    }
    resp = session.post(Conf.copySearch_url,
                        data=postdata,
                        headers=Conf.headers)
    logging.info("postdata is %s" % postdata)
    logging.info("response is %s" % resp.json())
    result = str(resp.json()['success'])
    logging.info("linkSearch result is %s" % result)
示例#12
0
文件: all.py 项目: milian0711/OMS_
def test_linkSearch():
    """
    链接到功能测试
    rowsContData:待链接的新闻ID
    rowsNodeData:链接到的栏目ID
    isCopy: 是否链接
    """
    rowsContData = "'" + '["' + str(Conf.newsID) + '"]' + "'"
    rowsNodeData = "'" + '["' + str(Conf.nodeID) + '"]' + "'"

    postdata = {
        "rowsContData": rowsContData,
        "rowsNodeData": rowsNodeData,
        "isCopy": "true"
    }
    resp = session.post(Conf.link_url, data=postdata, headers=Conf.headers)
    logging.info("postdata is %s" % postdata)
    logging.info("response is %s" % resp.json())
    result = str(resp.json()['success'])
    logging.info("linkSearch result is %s" % result)
示例#13
0
文件: all.py 项目: milian0711/OMS_
def test_getNickname():
    resp = session.post(Conf.getNickname_url, headers=Conf.headers)
    nickname = resp.json()["data"]
    logging.info("randomNickname is %s" % nickname)
    return nickname