Exemplo n.º 1
0
 def setUpClass(cls):
     proDir = os.path.join(os.getcwd(),
                           Constant.PATH_FOR_CONF)  # 动态获取配置文件目录相对路径
     headerPath = os.path.join(
         proDir, Constant.HEADER_FILE_NAME)  # 动态获取配置文件ini的相对路径
     cls.headers = OperJson.read_json(headerPath)
     cls._MockDate = OperJson.read_json(
         os.path.join(proDir, Constant.MOCK_FILE_NAME))
     config = ConfigUtil()
     cls.host = config.getRun("host")
 def get_HitLevel(self,keyword):
     """从wwsy中获取目录id和权重值"""
     Config = ConfigUtil()
     wwsy = Config.getRun("wwsy_prd") + urllib.parse.quote(keyword)
     # wwsy = "http://10.104.242.58/qa?&gender=1&rewrite=1&gender=1&import=1&rett=1&shop=1&source=search&semantic=1&gbk=0&q="+urllib.parse.quote(keyword)
     request = RequestUtil()
     reponse = request.get(wwsy, {})
     HitLevel = {}
     if reponse["sort_res"] != None:
         entitys = reponse["sort_res"][0]["entitys"]
         if entitys !=None:
             for entity in entitys[:3]:#只取前三个
                 HitLevel.update({entity["entity_id"]:entity["entity_s"]})
     return HitLevel
Exemplo n.º 3
0
 def compare_brand(self, kewords_random):
     flag = True
     # kewords_random = ["http://t.cn/rs719hp"]
     for keyword in kewords_random:
         logger.info("测试keyword为:%s" % (keyword))
         brands = self.get_brand(keyword)
         logger.info("页面取得品牌:%s" % brands)
         Config = ConfigUtil()
         wwsy = Config.getRun("wwsy_prd") + urllib.parse.quote(keyword)
         logger.info(wwsy)
         request = RequestUtil()
         reponse = request.get(wwsy, {})
         # 空列表循环是否报错
         brand_wwsy = "未命中"
         # logger.info("问题%s"%tmp)
         if reponse["sort_res"] != None:
             for member in reponse["sort_res"]:
                 tmp1 = member["entitys"]
                 if member["entitys"] != None:
                     for entitys in member["entitys"]:
                         if entitys["entity_n"] == "brand_Name":
                             brand_wwsy = entitys[
                                 "entity_v"]  # 同时命中两个品牌的情况??
                             break
             logger.info("wwsy取的品牌:%s" % brand_wwsy)
         if brand_wwsy in brands:
             wordMatch = "pass"
         else:
             if brand_wwsy == "未命中":
                 wordMatch = "pass"
             else:
                 wordMatch = "fail"
         if wordMatch == "fail":
             flag = False
         result = SearchResult()
         result.setBrand(brands)
         result.setBrand_wwsy(brand_wwsy)
         result.setKeyword(keyword)
         result.setMatchStatus(wordMatch)
         self.searchresults.append(result)
     return flag
Exemplo n.º 4
0
 def __init__(self):
     self.headers = {"content-type": "application/json;charset=UTF-8"}
     config = ConfigUtil()
     self.segURL = config.getRun(Constant.CONFIG_PARAM_RUN_SEGMENTATION)
Exemplo n.º 5
0
# -*- coding: utf8 -*-
import logging
import os
import time
import unittest
# from utils import HTMLSearchReport
from utils import HTMLTestRunner as HTMLSearchReport
from utils.CaseUtil import CaseUtil
from utils.ConfigUtil import ConfigUtil
from utils.Constant import Constant
from utils.LogSingleton import LogSingleton

if __name__ == '__main__':
    config = ConfigUtil()
    # 选择去运行case目录下的哪些自动化脚本
    casePattern = config.getRun(Constant.CONFIG_PARAM_RUN_PATTERN)

    logger = LogSingleton()
    logger = logging.getLogger(Constant.LOGGER_NAME)

    # 报告存放路径
    report_path = os.path.join(os.getcwd(), Constant.PATH_FOR_REPORTS)

    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    report_abspath = os.path.join(report_path, "report_" + now + ".html")
    fp = open(report_abspath, 'wb')
    logger.info("Created a report file(%s)" % report_abspath)
    runner = HTMLSearchReport.HTMLTestRunner(
        stream=fp,
        verbosity=2,
        title=Constant.REPORT_TITLE,