Ejemplo n.º 1
0
def format_url_with_para(url):

    #todo
    #it is just a test now
    if url.find("@id:\d+") != -1:
        type = helper.get_id_type(url, '@id')

        # print url
        # print type
        if type in ('flight', 'hotel', "topic", "membership"):
            url = url.replace("@id:\d+", random.choice(str(para_input[type]["valid"])))

        if type in ('feed', 'weibo'):
            if url.find("delete") != -1:
                url = url.replace("@id:\d+", random.choice(para_input["feed_id"]["to_delete"]))
            else:
                url = url.replace("@id:\d+", random.choice(para_input["wid"]["valid"]))

        if type in ('comment'):
            if url.find("delete") != -1:
                url = url.replace("@id:\d+", random.choice(para_input["comment_id"]["to_delete"]))
    #properties
    if url.find("@wid:\d+") != -1 :
        url = url.replace("@wid:\d+", random.choice(para_input["wid"]["valid"]))
    #
    if url.find("@type:\d+") != -1:
        url = url.replace("@type:\d+", "1")
    #
    if url.find("@uid:\d+") != -1 :
         url = url.replace("@uid:\d+", const.test_user["wuid"])

    return url
Ejemplo n.º 2
0
def generate_key_pair(url, key):
    key_pair = {}

    if key == "id":

        # id category
        type = helper.get_id_type(url, "")
        new_key = type + "_id"
        key_pair[key] = new_key
    else:
        key_pair[key] = key

    return key_pair