Example #1
0
def compile_result(testobj):
    log.info("start compile_result")
    try:
        filename_leftpart1 = "output"+"\\"+"leftpart"+"\\"+testobj+"error1.txt"
        filename_leftpart2 = "output"+"\\"+"leftpart"+"\\"+testobj+"error2.txt"

        filename_filterpart1 = "output"+"\\"+"filterpart"+"\\"+testobj+"error1.txt"
        filename_filterpart2 = "output"+"\\"+"filterpart"+"\\"+testobj+"error2.txt"

        f1 = open(filename_leftpart1, 'w')
        f2 = open(filename_leftpart2, 'w')

        f3 = open(filename_filterpart1, 'w')
        f4 = open(filename_filterpart2, 'w')

        log.info("start get keyword")
        for keyword in loadkeyword.load_keyword_from_AppTestCase():
            reload(sys)
            sys.setdefaultencoding('utf-8')
            keyword = str(keyword)
            keyword_quote = urllib.quote(keyword)
            url1 = urlget.urlall(urlget.urlget(testobj)["url1"],keyword_quote)
            url2 = urlget.urlall(urlget.urlget(testobj)["url2"],keyword_quote)
            log.info("start http getresponse_url")
            result1 = http.getresponse_url(url1)
            result2 = http.getresponse_url(url2)
            result3 = result1
            result4 = result2
            result5 = result1
            result6 = result2


            for m in loadreg.loadreg():
                result5 = filter.leftpart(result5, m)
                result6 = filter.leftpart(result6, m)
                result3 = filter.ignorepart(result5, m)
                result4 = filter.ignorepart(result5, m)



            if result5 == result6:
                log.info(keyword)
                log.info(testobj)
                log.info("完全一致")
            else:
                log.info(keyword)
                log.info(testobj)
                log.info("存在不同")

            #time.sleep(1)
            filewrite_filterpart.filewrite_filterpart(f3,result3,keyword)
            filewrite_filterpart.filewrite_filterpart(f4,result4,keyword)
            filewrite_leftpart.filewrite_leftpart(f1,result5,keyword)
            filewrite_leftpart.filewrite_leftpart(f2,result6,keyword)



    except Exception,e:
        log.error(e)
Example #2
0
def checkout_base(data):
    #print data
    # try:
        db_cityname = array('u', data[7]).tostring()[::2].decode('gbk')
        db_cityid = data[6]
        db_keyword = data[2]
        url = geturl.geturl(db_cityid,db_keyword)  #此处需要替换
        #log.info(url)

        content = http.getresponse_url(url)
        content = json.loads(content)

        adddd = findaddddd(db_keyword)
        if len(getfoodvlue(content)) == 0:
            if len(adddd) != 0:
                print "关键字为",db_keyword,"联想结果中的food个数为",len(getfoodvlue(content)),"数据库中包含存在个数为",len(findaddddd(db_keyword))
            else:
                print "正确","关键字为",db_keyword,"food个数为",len(getfoodvlue(content))
        else:
            for n in getfoodvlue(content):
                if str(n["districtname"]).find(db_cityname) == -1:
                    print "关键字为",db_keyword,"联想结果所在城市为",n["districtname"],"实际搜索城市为",db_cityname
                if adddd.find(str(n["word"])) == -1:
                    print "关键字为",db_keyword,"结果为",n["word"],"不在数据库中"
                else:
                    print "正确","关键字为",db_keyword,"food个数为",len(getfoodvlue(content))
Example #3
0
def checkout_city(data):
    try:
        db_cityname = array("u", data[7]).tostring()[::2].decode("gbk")
        db_keyword = data[2]
        db_province = data[13]

        urlbase = geturl.geturl(db_cityname, db_keyword)  # 此处需要替换
        contentbase = http.getresponse_url(urlbase)
        url = geturl.geturl_city(db_cityname, db_keyword, db_province)  # 此处需要替换
        # log.info(url)
        content = http.getresponse_url(url[0])

        if total(contentbase) != "0":
            if total(content) == "0":  # 测试total的个数
                print "关键字+城市测试", "测试total结果错误", "测试的keyword为:", db_keyword, "城市为", db_cityname
        else:
            pass
    except:
        pass
Example #4
0
def checkout_base(data):
    try:
        db_cityname = array("u", data[7]).tostring()[::2].decode("gbk")
        db_keyword = data[2]
        url = geturl.geturl(db_cityname, db_keyword)  # 此处需要替换
        # log.info(url)
        content = http.getresponse_url(url)

        if total(content) == "0":  # 测试total的个数
            print "关键字测试", "测试total结果错误", "测试的keyword为:", db_keyword, "城市为", db_cityname
        else:
            pass
    except:
        pass
Example #5
0
def compile_result(testobj):
    try:
        filename1 = "output"+"\\"+testobj+"error1.txt"
        filename2 = "output"+"\\"+testobj+"error2.txt"
        f1 = open(filename1, 'w')
        f2 = open(filename2, 'w')
        for keyword in loadkeyword.load_keyword_from_AppTestCase():
            reload(sys)
            sys.setdefaultencoding('utf-8')
            keyword = str(keyword)
            keyword_quote = urllib.quote(keyword)

            url1 = urlget.urlall(urlget.urlget(testobj)["url1"],keyword_quote)
            url2 = urlget.urlall(urlget.urlget(testobj)["url2"],keyword_quote)

            result1 = http.getresponse_url(url1)
            result2 = http.getresponse_url(url2)

            for m in loadreg.loadreg():
                result1 = filter.leftpart(result1, m)
                result2 = filter.leftpart(result2, m)

            if result1 == result2:
                log.info(keyword)
                log.info(testobj)
                log.info("完全一致")
            else:
                log.info(keyword)
                log.info(testobj)
                log.info("存在不同")

            #time.sleep(1)
            filewrite.filewrite(f1,result1,keyword)
            filewrite.filewrite(f2,result2,keyword)
    except Exception,e:
        log.error(e)
Example #6
0
def checkout_downtown(data):
    try:
        # print "开始base url的测试"  #此处需要替换
        db_cityname = array("u", data[7]).tostring()[::2].decode("gbk")
        db_keyword = data[2]
        db_province = data[13]
        db_cityid = data[6]
        db_downtown = getdata.get_db_downtown(db_cityid)

        url = geturl.geturl_downtown(db_cityname, db_keyword, db_downtown, db_province)  # 此处需要替换
        # log.info(url)
        content = http.getresponse_url(url[0])

        if total(content) == "0":  # 测试total的个数
            print "关键字+商业区测试", "测试total结果错误", "测试的keyword为:", db_keyword, "城市为", db_cityname, "商业区为:", db_downtown
    except:
        pass
Example #7
0
def checkout_district(data):
    try:
        db_cityname = array("u", data[7]).tostring()[::2].decode("gbk")
        db_keyword = data[2]
        db_cityid = data[6]
        db_province = data[13]
        db_district = getdata.get_db_district(db_cityid)

        url = geturl.geturl_district(db_cityname, db_keyword, db_district, db_province)  # 此处需要替换
        # log.info(url)
        content = http.getresponse_url(url[0])
        # print total(content)

        if total(content) == "0":  # 测试total的个数
            print "关键字+行政区测试", "测试total结果错误", "测试的keyword为:", db_keyword, "城市为", db_cityname, "行政区为:", db_district
        else:
            pass
    except:
        pass
Example #8
0
from common.ctrip import loadkeyword
from common.trd.httpbase import http
from common.trd.httpbase import http


all = []
m = []
for keyword in loadkeyword.load_keyword_from_AppTestCase():

    reload(sys)
    sys.setdefaultencoding('utf-8')
    keyword = str(keyword)
    keyword_quote = urllib.quote(keyword)
    url = "http://10.2.25.24:8180/appautocomplete/search?keyword=keywordvalue&action=autocomplete&source=globalonline&districtid=4"
    url1 = url.replace("keywordvalue",keyword_quote)
    result1 = http.getresponse_url(url1)
    try:
        result1 = http.json_to_py(result1)
        for n in result1["data"]:
            if n["type"] not in m:
                m.append(n["type"])
                print keyword,n["word"],n["type"],n["url"]
                if n["type"] not in all:
                    all.append(n["type"])

    except Exception:
        pass
for a in all:
    print a