Esempio n. 1
0
def is_correct_brand_case(bug_file_add, log_add, brand):
    if equal_brand(log_add, brand) == False:
        #write brand error
        bug_str = brand + '::error::请求brand与返回广告brand 不一致'
        addfile_changeline(bug_file_add, bug_str)
    else:
        #write brand pass
        bug_str = brand + '::pass::请求brand与返回广告brand一致'
        addfile_changeline(bug_file_add, bug_str)
def is_correct_brand_case(bug_file_add, log_add, brand):
    if equal_brand(log_add, brand) == False:
        # write brand error
        bug_str = brand + "::error::请求brand与返回广告brand 不一致"
        addfile_changeline(bug_file_add, bug_str)
    else:
        # write brand pass
        bug_str = brand + "::pass::请求brand与返回广告brand一致"
        addfile_changeline(bug_file_add, bug_str)
def personal_api_exact_cat_id(fname):
    log_address='E:\\svn\\ad_team\\test_result\\exact_cat_id_log.txt'
    #获取得category_list
    category_list=read_file(fname)
    #循环取category_list
    for i in category_list:
        #print category_list[i]
        catid = str(int(i))
        #写请求log
        str1 = 'request category_id:'+ catid
        addfile_changeline(log_address,str1)
        #判断case是否通过
        is_correct_usecase(catid,exact_extend_list(catid))
Esempio n. 4
0
def personal_api_exact_cat_id(fname):
    log_address = 'E:\\svn\\ad_team\\test_result\\exact_cat_id_log.txt'
    #获取得category_list
    category_list = read_file(fname)
    #循环取category_list
    for i in category_list:
        #print category_list[i]
        catid = str(int(i))
        #写请求log
        str1 = 'request category_id:' + catid
        addfile_changeline(log_address, str1)
        #判断case是否通过
        is_correct_usecase(catid, exact_extend_list(catid))
def pc_personal_api_brand(log_add, brand):
    #url
    url = "http://10.255.254.62:9090/getadspersonal/9/0/10/0/0/0/3/1407986641294815803640/0/" + brand + "/0/1"
    response = urllib2.Request(url)
    res_data = urllib2.urlopen(response)
    res = res_data.read()
    #解析str变成字典
    res_dict = json.loads(res)
    #print res_dict
    if res_dict == None:
        str = brand + '该品牌词请求下无广告'
        addfile_changeline(log_add, str)
    else:
        str = brand + '::发送回头客品牌词请求成功'
        addfile_changeline(log_add, str)
        return res_dict
def pc_personal_api_brand(log_add,brand):
    #url
    url = "http://10.255.254.62:9090/getadspersonal/9/0/10/0/0/0/3/1407986641294815803640/0/" + brand + "/0/1"
    response = urllib2.Request(url)
    res_data = urllib2.urlopen(response)
    res = res_data.read()
    #解析str变成字典
    res_dict = json.loads(res)
    #print res_dict
    if res_dict==None:
        str=brand+'该品牌词请求下无广告'
        addfile_changeline(log_add,str)
    else:
        str=brand+'::发送回头客品牌词请求成功'
        addfile_changeline(log_add,str)
        return res_dict
Esempio n. 7
0
def equal_brand(log_add, brand):
    #print('start')
    product_id_li = personal_api_brand(log_add, brand)
    #print('end')
    for i in product_id_li:
        #print i
        #print type(i)
        try:
            personal_get_brand(str(i))
            if brand == personal_get_brand(str(i)):
                continue
            else:
                return False
                break
        except Exception:
            #write_log:print('data error:: this brand name is None')
            #print('该product_id在product_Core中的brand为空值')
            brand_none_log_str = str(i) + '  :this brand name is None'
            addfile_changeline(log_add, brand_none_log_str)
            return False
            break
def equal_brand(log_add, brand):
    # print('start')
    product_id_li = personal_api_brand(log_add, brand)
    # print('end')
    for i in product_id_li:
        # print i
        # print type(i)
        try:
            personal_get_brand(str(i))
            if brand == personal_get_brand(str(i)):
                continue
            else:
                return False
                break
        except Exception:
            # write_log:print('data error:: this brand name is None')
            # print('该product_id在product_Core中的brand为空值')
            brand_none_log_str = str(i) + "  :this brand name is None"
            addfile_changeline(log_add, brand_none_log_str)
            return False
            break
Esempio n. 9
0
def is_correct_usecase(catid,exact_extend_list):
    catid_compare_list=[]
    #print exact_extend_list
    bug_address='E:\\svn\\ad_team\\test_result\\exact_cat_id_bug.txt'
    log_address='E:\\svn\\ad_team\\test_result\\exact_cat_id_log.txt'
    for i in range(0,exact_extend_list.__len__()):
        #打印每一条记录
        #print exact_extend_list[i]
        dic_compare=[]
        #print exact_extend_list[i]['cat_id']
        #print type(exact_extend_list[i]['cat_id'])
        #print "*******************"

        if catid== str(int(exact_extend_list[i]['extra'])):
            #print('pass:写log,cat_id,product_id,')
            #log_str='ad_id='+str(int(exact_extend_list[i]['ad_id']))+',product_id='+str(int(exact_extend_list[i]['product_id']))+',cat_id:'+str(int(exact_extend_list[i]['cat_id']))+'cat_id='+str(int(exact_extend_list[i]['cat_id']))+',cat_extend:'+str(int(exact_extend_list[i]['cat_extend']))
            #addfile_changeline(log_address,log_str)
            dic_compare.append(1)
        else:
            #print('error:写log')
            log_str='error::ad_id='+str(int(exact_extend_list[i]['ad_id']))+',extra='+str(int(exact_extend_list[i]['extra']))+',product_id='+str(int(exact_extend_list[i]['product_id']))+',cat_id:'+str(int(exact_extend_list[i]['cat_id']))+',cat_extend:'+str(int(exact_extend_list[i]['cat_extend']))
            addfile_changeline(log_address,log_str)
            dic_compare.append(0)
    if 0 in dic_compare:
        #print(写错误报告)
        bug_str=catid+':该分类请求返回错误'
        addfile_changeline(bug_address,bug_str)
    else:
        #print(write error report)
        bug_str=catid+':该分类请求返回数据正确'
        addfile_changeline(bug_address,bug_str)
Esempio n. 10
0
def personal_api_brand(log_add, brand):
    #发送api品牌词请求
    ad_brand = pc_personal_api_brand(log_add, brand)
    #获取cat_extend=6的product_list
    product_id_li = []
    for i in range(0, ad_brand.__len__()):
        #获取product_id=int(ad_brand[i]['product_id']
        #print type(brand_cat_extend)
        #print type(ad_brand[i]['cat_extend'].encode('utf-8'))
        #print ad_brand[i]['cat_extend']
        if ad_brand[i]['cat_extend'].encode('utf-8') == '6':
            product_id = int(ad_brand[i]['product_id'])
            #write log:print product_id
            product_str = str(product_id)
            #print ad_brand[i]['cat_extend']
            addfile_changeline(log_add, product_str)
            log_str = str(ad_brand[i]['ad_id']) + '是百货历史广告'
            addfile_changeline(log_add, log_str)
            product_id_li.append(product_id)
        else:
            #write log 不是百货历史广告。
            log_str = str(ad_brand[i]['ad_id']) + '不是百货历史广告'
            addfile_changeline(log_add, log_str)
            #break
    return product_id_li
Esempio n. 11
0
def personal_api_brand(log_add, brand):
    # 发送api品牌词请求
    ad_brand = pc_personal_api_brand(log_add, brand)
    # 获取cat_extend=6的product_list
    product_id_li = []
    for i in range(0, ad_brand.__len__()):
        # 获取product_id=int(ad_brand[i]['product_id']
        # print type(brand_cat_extend)
        # print type(ad_brand[i]['cat_extend'].encode('utf-8'))
        # print ad_brand[i]['cat_extend']
        if ad_brand[i]["cat_extend"].encode("utf-8") == "6":
            product_id = int(ad_brand[i]["product_id"])
            # write log:print product_id
            product_str = str(product_id)
            # print ad_brand[i]['cat_extend']
            addfile_changeline(log_add, product_str)
            log_str = str(ad_brand[i]["ad_id"]) + "是百货历史广告"
            addfile_changeline(log_add, log_str)
            product_id_li.append(product_id)
        else:
            # write log 不是百货历史广告。
            log_str = str(ad_brand[i]["ad_id"]) + "不是百货历史广告"
            addfile_changeline(log_add, log_str)
            # break
    return product_id_li
Esempio n. 12
0
def is_correct_usecase(catid, exact_extend_list):
    catid_compare_list = []
    #print exact_extend_list
    bug_address = 'E:\\svn\\ad_team\\test_result\\exact_cat_id_bug.txt'
    log_address = 'E:\\svn\\ad_team\\test_result\\exact_cat_id_log.txt'
    for i in range(0, exact_extend_list.__len__()):
        #打印每一条记录
        #print exact_extend_list[i]
        dic_compare = []
        #print exact_extend_list[i]['cat_id']
        #print type(exact_extend_list[i]['cat_id'])
        #print "*******************"

        if catid == str(int(exact_extend_list[i]['extra'])):
            #print('pass:写log,cat_id,product_id,')
            #log_str='ad_id='+str(int(exact_extend_list[i]['ad_id']))+',product_id='+str(int(exact_extend_list[i]['product_id']))+',cat_id:'+str(int(exact_extend_list[i]['cat_id']))+'cat_id='+str(int(exact_extend_list[i]['cat_id']))+',cat_extend:'+str(int(exact_extend_list[i]['cat_extend']))
            #addfile_changeline(log_address,log_str)
            dic_compare.append(1)
        else:
            #print('error:写log')
            log_str = 'error::ad_id=' + str(int(
                exact_extend_list[i]['ad_id'])) + ',extra=' + str(
                    int(exact_extend_list[i]['extra'])) + ',product_id=' + str(
                        int(exact_extend_list[i]
                            ['product_id'])) + ',cat_id:' + str(
                                int(exact_extend_list[i]['cat_id'])
                            ) + ',cat_extend:' + str(
                                int(exact_extend_list[i]['cat_extend']))
            addfile_changeline(log_address, log_str)
            dic_compare.append(0)
    if 0 in dic_compare:
        #print(写错误报告)
        bug_str = catid + ':该分类请求返回错误'
        addfile_changeline(bug_address, bug_str)
    else:
        #print(write error report)
        bug_str = catid + ':该分类请求返回数据正确'
        addfile_changeline(bug_address, bug_str)