Ejemplo n.º 1
0
 def test_updatePost(self, login, getUserInfo):
     logging.info("update interface 开始测试....")
     with allure.step("获取从上一个接口获取到的数据"):
         # 获取从上一个接口获取到的数据 xx
         createPositionList = Glob.get_value('createPosition')
         createPositionId = Glob.get_value('createPositionId')
         createPostDictlist = Glob.get_value("createPostDictlist")
         dataList = [{**{'postLevelId': 'aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18'}, **createPosition, **createPostDict} \
                     for createPosition, createPostDict in zip(createPositionList, createPostDictlist)]
         reqList = Common.cre_data('updatePost.yaml',
                                   'Post',
                                   dataList,
                                   SpecialtyInput='input')
         Auth = login
     with allure.step("开始进行接口请求,并取到返回值"):
         # 开始进行接口请求,并取到返回值
         for reqlist in reqList:
             logging.info("这里对接口返回的值进行json取值")
             result = Common.getResult(Common.requestManual(reqlist, Auth))
             logging.info("返回结果为:%s" % result)
             # 以下根据返回值取key,替换X
             pytest.assume(result['updatePost'], "INSTANCE")
     with allure.step("与数据库数据进行对比..."):
         updateCheckPoint = Glob.get_value("createPostIdList")
         # 以下传入查询的node,key
         querySqlResult = Common.getSqlResult('post', 'updateCheckSql', "fetchall", \
                                              dataposition_id=createPositionId, \
                                              datapost_level_id='aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18', \
                                              datatenant_id=getUserInfo)
         logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
         pytest.assume(
             sorted(querySqlResult).__eq__(sorted(updateCheckPoint)))
     logging.info("update interface 结束测试....")
Ejemplo n.º 2
0
    def __init__(self, **kwargs):
        self.common = Common()
        self.path = kwargs.get('path') if kwargs.get(
            'path') else self.save_path()

        from win32com.client import Dispatch
        self.thunder = Dispatch('ThunderAgent.Agent64.1')
Ejemplo n.º 3
0
    def getDepartmentList(Auth: str, OrgNameOne: str, OrgNameTwo: str) -> list:
        '''

        :param Auth:
        :param OrgNameOne: 组织名1 如 autoTestOrganization
        :param OrgNameTwo: 组织名2 如 autoTestOrg
        :return: 部门列表
        '''

        logging.info("开始准备请求,获取待创建的机构列表..")
        with allure.step("准备访问组织的数据"):
            reqList = Common.cre_data('allOrganization.yaml', 'LaborDemand',
                                      None)
        with allure.step(
                "开始进行allOrg接口请求,并取到组织名为 入参 'OrgNameOne' 和 'OrgNameTwo' 返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                ids = Common.getResult(Common.requestManual(reqlist, Auth))
            logging.info("返回值为:%s" % ids)
            # 获取name为 'autoTestOrganization'和 'autoTestOrg'的组织,返回下面的AutoPublic 和 AutoTestOrg
            resultList = ids['organizations'][0]['subOrganizations']
            responseDepartmentList = [(checkData['subOrganizations'][0]["id"], \
                                       checkData['subOrganizations'][0]["name"]) \
                                      for checkData in resultList\
                                      if checkData['name'] == OrgNameOne or checkData['name'] == OrgNameTwo]
        logging.info("返回的待请求的部门列表为:%s" % responseDepartmentList)
        return responseDepartmentList
 def test_createEducationTypes(self, login, getUserInfo):
     logging.info("create interface 开始测试....")
     with allure.step("准备数据"):
         reqList = Common.cre_data('createEducationS.yaml',
                                   'EducationSetting')
         Auth = login
         logging.info("getuserinfo:%s" % getUserInfo)
     with allure.step("开始进行接口请求,并取到返回值"):
         for reqlist in reqList:
             logging.info("这里对接口返回的值进行json取值")
             ids = Common.getResult(Common.requestManual(reqlist, Auth))
             # 以下填入取值x
             checkData = ids['mergeEducation']
             checkDatalist.append(checkData)
             checkDictlist.append({'id': checkData})
     with allure.step("与数据库数据进行对比..."):
         # 以下填入数据库的node 以及 key
         querySqlResult = Common.getSqlResult('educationSetting',
                                              'queryCheckSqlS',
                                              "fetchall",
                                              tenant_id=getUserInfo)
         logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
         logging.info("接口返回并sort排序的数据为:%s" % sorted(checkDatalist))
         pytest.assume(sorted(querySqlResult).__eq__(sorted(checkDatalist)))
     with allure.step("传递数据到下个接口..."):
         # 设置需要传递下去的值 X,Y
         Glob.set_value("QueryCheck", checkDatalist)
         Glob.set_value("createEducationTypes", checkDictlist)
         logging.info(checkDictlist)
     logging.info("create interface 结束测试....")
Ejemplo n.º 5
0
    def item_completed(self, results, item, info):

        commonLib = Common()
        
        item_data = {}
        for key,value in item.items():
            item_data[key] = value

        itemType = item_data.pop("itemType")
        if itemType == spiders.common.TYPE_STOCK:
            url = '/api/stock/addStock'
            # stock = {
            #     "code" : item['code'],
            #     "day" : item['day'],
            #     item['query'] : item['value'],
            # }
            post_data = {
                "stock" : item_data,
                'col' : 'qq',
            }
            commonLib.http_post(url,post_data)
            print "this is a stock"
        else:
            print "unknow item type"
        return item
 def test_updateEducationType(self, login, getUserInfo):
     logging.info("update interface 开始测试....")
     with allure.step("获取从上一个接口获取到的数据"):
         # 获取从上一个接口获取到的数据 xx
         data = Glob.get_value('createEducationTypes')
         logging.info(data)
         reqList = Common.cre_data('updateEducationS.yaml',
                                   'EducationSetting',
                                   data,
                                   SpecialtyInput='input')
         Auth = login
     with allure.step("开始进行接口请求,并取到返回值"):
         # 开始进行接口请求,并取到返回值
         for reqlist in reqList:
             logging.info("这里对接口返回的值进行json取值")
             result = Common.getResult(Common.requestManual(reqlist, Auth))
             # 以下根据返回值取key,替换X
             pytest.assume(result['mergeEducation'],
                           Glob.get_value("QueryCheck"))
     with allure.step("与数据库数据进行对比..."):
         updateCheckPoint = Glob.get_value("QueryCheck")
         querySqlResult = Common.getSqlResult("educationSetting",
                                              "updateCheckSqlS",
                                              "fetchall",
                                              tenant_id=getUserInfo)
         logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
         logging.info("接口返回并sort排序的数据为:%s" % sorted(updateCheckPoint))
         pytest.assume(
             sorted(querySqlResult).__eq__(sorted(updateCheckPoint)))
     logging.info("update interface 结束测试....")
Ejemplo n.º 7
0
    def test_employmentTypeQuery(self, login, getUserInfo):
        with allure.step("准备数据"):
            reqList = Common.cre_data('EmploymentQuery.yaml',
                                      'NatureEmployment')
            Auth = login
        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                ids = Common.getResult(Common.requestManual(reqlist, Auth))
            logging.info("返回值为:%s" % ids)
            # 以下是取数,根据返回key取值,替换其中X,Y部分为后续命名
            resultList = ids['employmentTypes']
            checkDataList = [checkData["id"] for checkData in resultList]

        with allure.step("与数据库数据进行对比..."):
            # 查询sql的node,key值
            querySqlResult = Common.getSqlResult('employTypeSetting',
                                                 'queryAllIds',
                                                 "fetchall",
                                                 tenant_id=getUserInfo)
            logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
            logging.info("接口返回并sort排序的数据为:%s" % sorted(checkDataList))
            pytest.assume(sorted(querySqlResult).__eq__(sorted(checkDataList)))
        with allure.step("传递数据到下个接口..."):
            Glob.set_value("employmentTypesData", resultList)
            Glob.set_value("allIds", checkDataList)
            logging.info(resultList)
        logging.info("query interface 结束测试....")
Ejemplo n.º 8
0
 def spider_init(self):
     self.commonLib = Common()
     self.env_type = self.commonLib.get_env()
     if self.env_type == "online":
         self.debug = ""
     logging.info("task id is [%s] get debug is  [%s] , env_type is [%s]",
                  self.taskId, self.debug, self.env_type)
Ejemplo n.º 9
0
 def test_positionStructQuery(self, login, getUserInfo):
     positionCategoryDict = Glob.get_value('positionCategoryDict')
     with allure.step("准备数据"):
         reqList = Common.cre_data('positionStructQuery.yaml',
                                   'PositionCategory', None)
         Auth = login
     with allure.step("开始进行接口请求,并取到返回值"):
         for reqlist in reqList:
             logging.info("这里对接口返回的值进行json取值")
             ids = Common.getResult(Common.requestManual(reqlist, Auth))
         logging.info("返回值为:%s" % ids)
         # 以下是取数,根据返回key取值,替换其中X
         resultList = ids['struct']
         checkPositionList = [
             checkData["positions"] for checkData in resultList if
             checkData["id"] == positionCategoryDict['positionCategoryId']
         ][0]
         checkDataList = [checkid['id'] for checkid in checkPositionList]
     with allure.step("与数据库数据进行对比..."):
         # 查询sql的node,key值
         querySqlResult = Common.getSqlResult('position', 'queryAllIds', "fetchall", datapositionCategoryDict = positionCategoryDict['positionCategoryId'], \
                          datatenant_id=getUserInfo)
         logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
         logging.info("接口返回并sort排序的数据为:%s" % sorted(checkDataList))
         pytest.assume(sorted(querySqlResult).__eq__(sorted(checkDataList)))
     with allure.step("传递数据到下个接口..."):
         # 替换下方的x
         Glob.set_value('QueryResult', checkPositionList)
         Glob.set_value("allIds", checkDataList)
         logging.info(resultList)
     logging.info("query interface 结束测试....")
Ejemplo n.º 10
0
    def test_createPosition(self, login, getUserInfo):
        logging.info("create interface 开始测试....")
        positionCategoryDict = Glob.get_value('positionCategoryDict')
        with allure.step("准备数据"):
            reqList = Common.cre_data('createPosition.yaml',
                                      'Position',
                                      positionCategoryDict,
                                      mode='create')
            Auth = login
        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                ids = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info("返回值为:%s" % ids)
                # 以下填入取值x
                checkData = ids['createPosition']
                assert checkData == "INSTANCE"

        with allure.step("与数据库数据进行对比..."):
            # 以下填入数据库的node 以及 key
            querySqlResult = Common.getSqlResult('position', 'queryCheckSql', "fetchall", \
                             datapositionCategoryDict = positionCategoryDict['positionCategoryId'], \
                             datatenant_id=getUserInfo)
            logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
            pytest.assume(sorted(querySqlResult).__ne__([]))

        with allure.step("传递数据到下个接口..."):
            # 设置需要传递下去的值 X
            checkDictlist = [{'id': SqlResult} for SqlResult in querySqlResult]
            checkDatalist = [SqlResult for SqlResult in querySqlResult]
            Glob.set_value("createPosition", checkDictlist)
            Glob.set_value("updateCheckPoint", checkDatalist)
            logging.info(checkDictlist)
        logging.info("create interface 结束测试....")
Ejemplo n.º 11
0
 def test_updatePosition(self, login, getUserInfo):
     logging.info("update interface 开始测试....")
     positionCategoryDict = Glob.get_value('positionCategoryDict')
     checkDatalist = Glob.get_value('updateCheckPoint')
     with allure.step("获取从上一个接口获取到的数据"):
         # 获取从上一个接口获取到的数据 xx
         data = Glob.get_value('createPosition')
         newlist = [{
             **dataDict,
             **positionCategoryDict
         } for dataDict in data]
         reqList = Common.cre_data('updatePosition.yaml',
                                   'Position',
                                   newlist,
                                   SpecialtyInput='input')
         Auth = login
     with allure.step("开始进行接口请求,并取到返回值"):
         # 开始进行接口请求,并取到返回值
         for reqlist in reqList:
             logging.info("这里对接口返回的值进行json取值")
             result = Common.getResult(Common.requestManual(reqlist, Auth))
             # 以下根据返回值取key,替换X
             pytest.assume(result['updatePosition'], "INSTANCE")
     with allure.step("与数据库数据进行对比..."):
         updateCheckPoint = Glob.get_value("QueryCheck")
         # 以下传入查询的node,key
         querySqlResult = Common.getSqlResult('position', 'updateCheckSql', "fetchall", \
                          datapositionCategoryDict = positionCategoryDict['positionCategoryId'], \
                          datatenant_id=getUserInfo)
         logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
         pytest.assume(sorted(querySqlResult).__eq__(sorted(checkDatalist)))
     logging.info("update interface 结束测试....")
Ejemplo n.º 12
0
 def test_postQuery(self, login, getUserInfo):
     createPositionId = Glob.get_value('createPositionId')
     data = {'id': createPositionId}
     with allure.step("准备数据"):
         reqList = Common.cre_data('postByPositionId.yaml', 'Post', data)
         Auth = login
     with allure.step("开始进行接口请求,并取到返回值"):
         for reqlist in reqList:
             logging.info("这里对接口返回的值进行json取值")
             ids = Common.getResult(Common.requestManual(reqlist, Auth))
         logging.info("返回值为:%s" % ids)
         # 以下是取数,根据返回key取值,替换其中X
         resultList = ids['posts']
         checkDataList = [checkid['id'] for checkid in resultList]
     with allure.step("与数据库数据进行对比..."):
         # 查询sql的node,key值
         querySqlResult = Common.getSqlResult('post', 'queryAllIds', "fetchall",\
                           dataposition_id = createPositionId, \
                           datapost_level_id = 'aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18', \
                           datatenant_id = getUserInfo, \
                 )
         logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
         logging.info("接口返回并sort排序的数据为:%s" % sorted(checkDataList))
         pytest.assume(sorted(querySqlResult).__eq__(sorted(checkDataList)))
     with allure.step("传递数据到下个接口..."):
         # 替换下方的x
         Glob.set_value('QueryResult', resultList)
         Glob.set_value("allIds", checkDataList)
         logging.info(resultList)
     logging.info("query interface 结束测试....")
Ejemplo n.º 13
0
class iwencaiSpider(scrapy.Spider):
    name = "wencai"
    allowed_domains = ["iwencai.com"]
    start_urls = [
        "http://www.iwencai.com/stockpick",
    ]
    source_currency = "RMB"
    picType = "jpg"
    debug = ""
    taskId = -1
    commonLib = False
    env_type = "offline"

    def __init__(self, *args, **kwargs):

        self.commonLib = Common()
        self.env_type = self.commonLib.get_env()
        if self.env_type == "online":
            self.debug = ""
        self.commonLib.set_header("env_type",self.env_type)
        self.commonLib.set_header("debug",self.debug)
        self.commonLib.write_log("get task id is [%s]" % (self.taskId))

    def parse(self, response):
        try:        

            # request = scrapy.Request(response.url, callback=self.query_indicator_list)
            # request.meta['method'] = "query_indicator_list"
            # yield request
            ## 获取技术指标列表
            # for option in response.xpath("//div[@class='area_item']/a[@name='lm_c_jszb']/../div//a[@class='other_link']/@href"):
            #     href = option.extract().strip()

            #     self.commonLib.write_log("get indicator list url is [%s]" % (href))
            #     request = scrapy.Request(href, callback=self.parse_indicator_list)
            #     yield request
                
            #     if self.debug:
            #         self.commonLib.write_log("debug")
            #         return
            # day = "2016年03月23日"
            # indicator = "MACD金叉"
            # yield self.query_indicator_by_day(indicator,day)
            request = scrapy.Request(response.url, callback=self.query_indicator)
            request.meta['method'] = "query_indicator"
            yield request
            
        except Exception, e:
            urlStatus = common.STATUS_FAIL
            exc_type, exc_value, exc_traceback = sys.exc_info()
            msgStr = self.commonLib.write_exception(exc_type, exc_value, exc_traceback)
            self.commonLib.write_log(msgStr)
            print (msgStr)
Ejemplo n.º 14
0
def url(request, project, env):
    from lib.node import Node
    from lib.common import Common

    result = ""

    n = Node(project, env)
    ip = []
    for row in n.get():
        if row['hostname'].startswith("Controltier"):
            continue
        ip.append(row['hostname'])

    for vrow in Validation.objects.filter(project=project).values():
        for server in ip:
            if vrow['url'].startswith("ip"):
                url = re.sub("ip", server, vrow['url'])
                return_code = Common().get_return_code(url, vrow['port'])
                result += """
                <tr>
                    <th>{url}</th>
                    <th>{return_code}</th>
                </tr>
                """.format(
                    url=url,
                    return_code=return_code,
                )

    return HttpResponse(result)
Ejemplo n.º 15
0
    def __init__(self, args, env):
        '''
        runs all other functions
        '''

        self.daemon = getattr(args, 'daemonize', False)
        self.env = env

        if self.daemon:
            self.write_pidfile()

        self.common = Common(daemon=self.daemon)

        self.log = self.common.log
        self.log.debug('--- start ---')

        self.image = Img(self.common)
        self.plugin = Plugin(self.common, self.image, self.env)

        self.interval = float(
            getattr(args, 'interval', False) or
            (settings.change_interval)) * 60
        self.step = float(getattr(args, 'step', 0))
        self.step_increasing = self.step

        self.infinite_loop()
Ejemplo n.º 16
0
    def __init__(self, *args, **kwargs):

        self.commonLib = Common()
        self.env_type = self.commonLib.get_env()
        if self.env_type == "online":
            self.debug = ""
        self.commonLib.set_header("env_type",self.env_type)
        self.commonLib.set_header("debug",self.debug)
        self.commonLib.write_log("get task id is [%s]" % (self.taskId))
Ejemplo n.º 17
0
class YouGet():
    def __init__(self, **kwargs):
        self.path = kwargs.get('path') if kwargs.get(
            'path') else self.save_path()
        self.common = Common()

    def save_path(self):
        parallel = os.path.abspath(os.path.dirname(BASE_DIR))
        flv_path = self.common.mkdir(os.path.join(parallel, 'you_get'))
        return flv_path

    def download(self, url):
        sys.argv = ['you-get', '-o', self.path, url]
        you_get.main()

        # 下载完成,删除xml文件
        for file in os.listdir(self.path):
            if file[-3:] == 'xml':
                self.common.rmfile(os.path.join(self.path, file))
Ejemplo n.º 18
0
 def __init__(self, taskId=None, *args, **kwargs):
     super(zaraSpider, self).__init__(*args, **kwargs)
     #self.start_urls = ['http://www.example.com/categories/%s' % category]
     self.taskId = int(taskId)
     self.commonLib = Common()
     self.env_type = self.commonLib.get_env()
     if self.env_type == "online":
         self.debug = ""
     self.commonLib.set_header("env_type",self.env_type)
     self.commonLib.set_header("debug",self.debug)
     self.commonLib.write_log("get task id is [%s]" % (self.taskId))
Ejemplo n.º 19
0
    def test_deletePosition(self, login, getUserInfo):
        logging.info("delete interface 开始测试....")
        with allure.step("获取从上一个接口获取到的数据,以及登录获取当前version"):
            # 获取从create接口获取到的数据 xx
            data = Glob.get_value('createPosition')
            positionCategoryDict = Glob.get_value('positionCategoryDict')
            Auth = login
            # 再次登录,查询当前的version情况:
            with allure.step("进行query查询"):
                with allure.step("准备数据"):
                    reqList = Common.cre_data('positionStructQuery.yaml',
                                              'Post', None)
                with allure.step("开始进行接口请求,并取到返回值"):
                    for reqlist in reqList:
                        logging.info("这里对接口返回的值进行json取值")
                        ids = Common.getResult(
                            Common.requestManual(reqlist, Auth))
                    # 以下是取数,根据返回key取值,替换x
                    resultList = ids['struct']
                    checkPositionList = [
                        checkData["positions"] for checkData in resultList
                        if checkData["id"] ==
                        positionCategoryDict['positionCategoryId']
                    ][0]

            reqList = Common.cre_data('deletePosition.yaml',
                                      'Position',
                                      data,
                                      checkPositionList,
                                      idAndVersions='idAndVersions')

        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                result = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info(result)
                # 替换下面的key x
                pytest.assume(result['deletePosition'], 'INSTANCE')
        with allure.step("与数据库数据进行对比..."):
            # 替换下面的查询数据库 替换node key
            querySqlResult = Common.getSqlResult('position', 'queryAllIds', "fetchall",
                                                 datapositionCategoryDict=positionCategoryDict['positionCategoryId'], \
                                                 datatenant_id=getUserInfo)
            updateSqlResult = Common.getSqlResult('position', 'queryAllIds', "fetchall",
                                                  datapositionCategoryDict=positionCategoryDict['positionCategoryId'], \
                                                  datatenant_id=getUserInfo)
            logging.info("数据库查询并sort排序的结果为:%s" % querySqlResult)
            pytest.assume(sorted(querySqlResult).__eq__([]))
            pytest.assume(sorted(updateSqlResult).__eq__([]))
        logging.info("delete interface 结束测试....")
Ejemplo n.º 20
0
    def test_createPost(self, login, getUserInfo):
        logging.info("create interface 开始测试....")
        createPositionList = Glob.get_value('createPosition')
        createPositionId = Glob.get_value('createPositionId')
        dataList = [{**{'postLevelId': 'aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18'}, **createPosition} \
                     for createPosition in createPositionList]
        with allure.step("准备数据"):
            reqList = Common.cre_data('createPost.yaml',
                                      'Post',
                                      dataList,
                                      mode='create')
            Auth = login
        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                ids = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info("返回值为:%s" % ids)
                # 以下填入取值x
                checkData = ids['createPost']
                assert checkData == "INSTANCE"

        with allure.step("与数据库数据进行对比..."):
            # 以下填入数据库的node 以及 key
            querySqlResult = Common.getSqlResult('post', 'queryCheckSql', "fetchall", \
                                                 dataposition_id=createPositionId,\
                                                 datapost_level_id='aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18',\
                                                 datatenant_id=getUserInfo,\
                                                 )
            logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
            pytest.assume(sorted(querySqlResult).__ne__([]))

        with allure.step("传递数据到下个接口..."):
            # 设置需要传递下去的值 X
            checkDictlist = [{'id': SqlResult} for SqlResult in querySqlResult]
            checkDatalist = [SqlResult for SqlResult in querySqlResult]
            Glob.set_value("createPostDictlist", checkDictlist)
            Glob.set_value("createPostIdList", checkDatalist)
            logging.info(checkDictlist)
        logging.info("create interface 结束测试....")
Ejemplo n.º 21
0
    def executeTestCase(row):
        lstRowsNo = list()
        try:
            # Initialize variables by current Driver Sheet row
            Function_Name = str(row["Function_Name"])
            SheetName = str(row["TestDataSheetName"])
            RowNo = str(row["TestDataSheetRowNo"])
            RowID = str(row["RowID"])
            TestCaseID = str(row["TestCaseID"])
            TestDataRow = None
            testFunction = None

            lstRowsNo = Common.GetIterations(RowNo, ',')

            if len(lstRowsNo) < 1:
                raise Exception(
                    "Test Data Sheet RowNo is empty for function ({0}) in Driver sheet row ({1})"
                    .format(Function_Name, RowID))
            else:
                Globals.Report.TestCaseIterations = len(lstRowsNo)
                Globals.Report.TestCaseStatus = True
                Reporter.startTest(TestCaseID)
                for rowNum in lstRowsNo:
                    Reporter.startIteration(Function_Name, rowNum)
                    TestDataRow = DataManager.getDictionaryTableFromExcell(
                        "select * from [" + SheetName + "$] where RowID=" +
                        rowNum)[0]
                    if TestDataRow != None:
                        if hasattr(TestScenarios, Function_Name):
                            testFunction = getattr(TestScenarios,
                                                   Function_Name)
                            testFunction(TestDataRow)
                        else:
                            raise Exception(
                                "TestFunction ( {0} ) Not Exist In TestScenarios"
                                .format(Function_Name))
                    else:
                        raise Exception(
                            "Test Data Row ( {0} ) Not Exist In Sheet ( {1} )".
                            format(rowNum, SheetName))

                    Reporter.endIteration()

                Reporter.endTest()

        except:
            print("Failed to execute Test Case for Error {0}".format(
                sys.exc_info()[1]))
        finally:
            pass
Ejemplo n.º 22
0
    def test_deletePost(self, login, getUserInfo):
        logging.info("delete interface 开始测试....")
        with allure.step("获取从上一个接口获取到的数据,以及登录获取当前version"):
            # 获取从create接口获取到的数据 xx
            createPositionId = Glob.get_value('createPositionId')
            Auth = login
            createPostDictlist = Glob.get_value('createPostDictlist')
            data = {'id': createPositionId}
            # 再次登录,查询当前的version情况:
        with allure.step("准备数据"):
            reqList = Common.cre_data('postByPositionId.yaml', 'Post', data)
            Auth = login
        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                ids = Common.getResult(Common.requestManual(reqlist, Auth))
            logging.info("返回值为:%s" % ids)
            # 以下是取数,根据返回key取值,替换其中X
            resultList = ids['posts']

        reqList = Common.cre_data('deletePost.yaml',
                                  'Post',
                                  createPostDictlist,
                                  resultList,
                                  idAndVersions='idAndVersions')

        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                result = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info(result)
                # 替换下面的key x
                pytest.assume(result['deletePost'], 'INSTANCE')
        with allure.step("与数据库数据进行对比..."):
            # 替换下面的查询数据库 替换node key
            querySqlResult = Common.getSqlResult('post', 'queryCheckSql', "fetchall",   dataposition_id=createPositionId, \
                                                     datapost_level_id='aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18', \
                                                     datatenant_id=getUserInfo)
            updateSqlResult = Common.getSqlResult('post', 'updateCheckSql', "fetchall",   dataposition_id=createPositionId, \
                                                     datapost_level_id='aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18', \
                                                     datatenant_id=getUserInfo)
            logging.info("数据库查询并sort排序的结果为:%s" % querySqlResult)
            pytest.assume(sorted(querySqlResult).__eq__([]))
            pytest.assume(sorted(updateSqlResult).__eq__([]))
        logging.info("delete interface 结束测试....")
Ejemplo n.º 23
0
    def get_calendar_year(self, year):
        target_month = 1
        flg_exit = False
        list_month = ['', '', '', '', '', '', '', '', '', '', '', '']

        common = Common()

        for i in range(self.row_num):
            for j in range(self.column_num):
                #print("row_num:", i, "self.column_num:", j)
                if target_month > common.month_num:
                    flg_exit = True
                    break
                else:
                    list_month[target_month - 1] = self.get_calendar_month(
                        year, target_month)
                    target_month += 1
            if flg_exit:
                break
        return list_month
Ejemplo n.º 24
0
    def getOrgPost(Auth: str, positionOne: str, positionTwo: str,
                   OrgPostOne: str, OrgPostTwo: str,
                   OrgPostThree: str) -> list:
        '''

        :param Auth:
        :param positionOne: autoTest
        :param positionTwo: autoTest2
        :param OrgPostOne: AutoTest1
        :param OrgPostTwo: AutoTest2
        :param OrgPostThree: atest
        :return: PostList
        '''
        responseOrgPost = []
        logging.info("获取待请求的职务结构.......")
        with allure.step("准备数据"):
            reqList = Common.cre_data('positionStructQuery.yaml',
                                      'LaborDemand', None)
        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                ids = Common.getResult(Common.requestManual(reqlist, Auth))
            logging.info("返回值为:%s" % ids)
            # 以下是取数,根据返回key取值,替换其中X
            resultList = ids['struct']
            responsePositionStruct = [
                ({"id": checkData["positions"][0]['id']}, {'name': checkData["positions"][0]['name']}) \
                for checkData in resultList \
                if checkData['name'] == positionOne or checkData['name'] == positionTwo]
        logging.info("获取待请求的职务结构的列表为: %s" % responsePositionStruct)

        logging.info("获取待请求的职位列表......")
        with allure.step("准备数据"):
            reqList = Common.cre_data('postByPositionId.yaml', 'LaborDemand',
                                      responsePositionStruct)

        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                ids = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info("返回值为:%s" % ids)
                # 以下是取数,根据返回key取值,替换其中X
                resultList = ids['posts']
                checkDataList = [(checkData["id"], checkData["name"]) for checkData in resultList \
                                 if checkData['name'] == OrgPostOne or checkData['name'] == OrgPostTwo or checkData[
                                     'name'] == OrgPostThree]
                responseOrgPost.append(checkDataList)
        logging.info("获取到的职位列表为:%s" % responseOrgPost)
        return responseOrgPost
Ejemplo n.º 25
0
    def test_deleteEmploymentType(self, login, getUserInfo):
        logging.info("delete interface 开始测试....")
        with allure.step("获取从上一个接口获取到的数据,以及登录获取当前version"):
            # 获取从create接口获取到的数据 xx
            data = Glob.get_value('createEmployType')
            Auth = login
            # 再次登录,查询当前的version情况:
            with allure.step("进行query查询"):
                with allure.step("准备数据"):
                    reqList = Common.cre_data('EmploymentQuery.yaml',
                                              'NatureEmployment')
                with allure.step("开始进行接口请求,并取到返回值"):
                    for reqlist in reqList:
                        logging.info("这里对接口返回的值进行json取值")
                        ids = Common.getResult(
                            Common.requestManual(reqlist, Auth))
                    # 以下是取数,根据返回key取值,替换x
                    resultList = ids['employmentTypes']

            reqList = Common.cre_data('deleteEmploymentTypes.yaml',
                                      'NatureEmployment',
                                      data,
                                      resultList,
                                      IdAndVersionInput='idVersions')

        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                result = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info(result)
                #替换下面的key x
                pytest.assume(result['deleteEmploymentTypes'], 'INSTANCE')
        with allure.step("与数据库数据进行对比..."):
            #替换下面的查询数据库 替换node key
            querySqlResult = Common.getSqlResult('employTypeSetting',
                                                 'queryCheckSql',
                                                 "fetchall",
                                                 tenant_id=getUserInfo)
            logging.info("数据库查询并sort排序的结果为:%s" % querySqlResult)
            pytest.assume(sorted(querySqlResult).__eq__([]))
        logging.info("delete interface 结束测试....")
Ejemplo n.º 26
0
    def get_calendar_month(self, year, month):
        line = ['', '', '', '', '', '', '', '', '']
        cnt = 0

        common = Common()

        header_month = common.month_name[month -
                                         1] + "                          "
        line[cnt] += '\033[38;5;245;1m' + header_month[:21] + '\033[0m'
        cnt += 1

        line[cnt] += ' '.join(map(str, common.weekday_name)) + " "
        cnt += 1

        d = datetime.datetime.today()

        for s1 in self.get_day_list(year, month):
            s5 = ''
            for s2 in s1:
                s3 = '{: >2}'.format(s2)

                if s2 != '':
                    if year == d.year and month == d.month and s2 == d.day:
                        #s4 = '\033[31m' + s3 + '\033[0m'
                        s4 = '\033[38;5;226m' + s3 + '\033[0m'
                    elif self.get_weekday(year, month, s2) == 0:
                        s4 = '\033[31m' + s3 + '\033[0m'
                    elif self.get_weekday(year, month, s2) == 6:
                        s4 = '\033[36m' + s3 + '\033[0m'
                    else:
                        s4 = s3
                else:
                    s4 = s3
                s5 += s4 + " "
            line[cnt] += s5
            #line[cnt] += "  "
            cnt += 1
        return line
Ejemplo n.º 27
0
class Thunder():
    def __init__(self, **kwargs):
        self.common = Common()
        self.path = kwargs.get('path') if kwargs.get(
            'path') else self.save_path()

        from win32com.client import Dispatch
        self.thunder = Dispatch('ThunderAgent.Agent64.1')

    def save_path(self):
        parallel = os.path.abspath(os.path.dirname(BASE_DIR))
        flv_path = self.common.mkdir(os.path.join(parallel, 'you_get'))
        return flv_path

    def download1(self, urls):
        for i, url in enumerate(urls):
            self.thunder.AddTask(url, "第{0}集.rmvb".format(i + 1), self.path)
            self.thunder.CommitTasks()

    def download(self, url, name):
        self.thunder.AddTask(url, "第{0}集.rmvb".format(name))
        self.thunder.CommitTasks()
        time.sleep(60)
    def test_deleteEducationTypes(self, login, getUserInfo):
        logging.info("delete interface 开始测试....")
        with allure.step("获取从上一个接口获取到的数据,以及登录获取当前version"):
            # 获取从上一个接口获取到的数据 xx
            data = Glob.get_value("createEducationTypes")
            Auth = login
            # 再次登录,查询当前的version情况:
            with allure.step("进行query查询"):
                with allure.step("准备数据"):
                    reqList = Common.cre_data('educationQuery.yaml',
                                              'EducationSetting')
                with allure.step("开始进行接口请求,并取到返回值"):
                    for reqlist in reqList:
                        logging.info("这里对接口返回的值进行json取值")
                        ids = Common.getResult(
                            Common.requestManual(reqlist, Auth))
                    # 以下是取数,根据返回key取值,替换其m中X,Y部分为后续命名
                    resultList = ids['educations']
            reqList = Common.cre_data('deleteEducations.yaml',
                                      'EducationSetting',
                                      data,
                                      resultList,
                                      IdAndVersionInput='idVersions')

        with allure.step("开始进行接口请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                result = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info(result)
                pytest.assume(result['deleteEducations'], 'INSTANCE')
        with allure.step("与数据库数据进行对比..."):
            querySqlResult = Common.getSqlResult("educationSetting",
                                                 "queryCheckSql",
                                                 "fetchall",
                                                 tenant_id=getUserInfo)
            logging.info("数据库查询并sort排序的结果为:%s" % (querySqlResult))
            pytest.assume(sorted(querySqlResult).__eq__([]))
        logging.info("delete interface 结束测试....")
Ejemplo n.º 29
0
def send(request, id, project, status):
    print id, project, status

    mail_to, mail_cc = [], []

    mailuser = get_mail_address(project, status)
    #print mailuser
    if mailuser['to']:
        for user in mailuser['to']:
            mail_to.append(user)

    if mailuser['cc']:
        for user in mailuser['cc']:
            mail_cc.append(user)

    if mail_to:
        row = Content.objects.filter(id=id).values()[0]

        #rollback version search
        if status > 103:
            row['version'] = History.objects.filter(project=project, env=row['env']).order_by('-finish_time').values()[1]['version']

        status_name = get_status_name(project, status)
        percent = row['env'],


        contents = u"""
    <html><head>
    <meta charset="utf-8">
<style>body{width:600px;margin:1px auto;font-family:'trebuchet MS','Lucida sans',Arial;font-size:14px;color:#444}table{*border-collapse:collapse;border-spacing:0;width:80%}.bordered{border:solid #ccc 1px;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 1px 1px #ccc;-moz-box-shadow:0 1px 1px #ccc;box-shadow:0 1px 1px #ccc}.bordered tr:hover{background:#fbf8e9;-o-transition:all .1s ease-in-out;-webkit-transition:all .1s ease-in-out;-moz-transition:all .1s ease-in-out;-ms-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.bordered td,.bordered th{border-left:1px solid #ccc;border-top:1px solid #ccc;padding:10px;text-align:left}.bordered th{background-color:#dce9f9;background-image:-webkit-gradient(linear,left top,left bottom,from(#ebf3fc),to(#dce9f9));background-image:-webkit-linear-gradient(top,#ebf3fc,#dce9f9);background-image:-moz-linear-gradient(top,#ebf3fc,#dce9f9);background-image:-ms-linear-gradient(top,#ebf3fc,#dce9f9);background-image:-o-linear-gradient(top,#ebf3fc,#dce9f9);background-image:linear-gradient(top,#ebf3fc,#dce9f9);-webkit-box-shadow:0 1px 0 rgba(255,255,255,.8) inset;-moz-box-shadow:0 1px 0 rgba(255,255,255,.8) inset;box-shadow:0 1px 0 rgba(255,255,255,.8) inset;border-top:0;text-shadow:0 1px 0 rgba(255,255,255,.5)}.bordered td:first-child,.bordered th:first-child{border-left:none}.bordered th:first-child{-moz-border-radius:6px 0 0 0;-webkit-border-radius:6px 0 0 0;border-radius:6px 0 0 0}.bordered th:last-child{-moz-border-radius:0 6px 0 0;-webkit-border-radius:0 6px 0 0;border-radius:0 6px 0 0}.bordered th:only-child{-moz-border-radius:6px 6px 0 0;-webkit-border-radius:6px 6px 0 0;border-radius:6px 6px 0 0}.bordered tr:last-child td:first-child{-moz-border-radius:0 0 0 6px;-webkit-border-radius:0 0 0 6px;border-radius:0 0 0 6px}.bordered tr:last-child td:last-child{-moz-border-radius:0 0 6px 0;-webkit-border-radius:0 0 6px 0;border-radius:0 0 6px 0}.zebra td,.zebra th{padding:10px;border-bottom:1px solid #f2f2f2}.zebra tbody tr:nth-child(even){background:#f5f5f5;-webkit-box-shadow:0 1px 0 rgba(255,255,255,.8) inset;-moz-box-shadow:0 1px 0 rgba(255,255,255,.8) inset;box-shadow:0 1px 0 rgba(255,255,255,.8) inset}.zebra th{text-align:left;text-shadow:0 1px 0 rgba(255,255,255,.5);border-bottom:1px solid #ccc;background-color:#eee;background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#eee));background-image:-webkit-linear-gradient(top,#f5f5f5,#eee);background-image:-moz-linear-gradient(top,#f5f5f5,#eee);background-image:-ms-linear-gradient(top,#f5f5f5,#eee);background-image:-o-linear-gradient(top,#f5f5f5,#eee);background-image:linear-gradient(top,#f5f5f5,#eee)}.zebra th:first-child{-moz-border-radius:6px 0 0 0;-webkit-border-radius:6px 0 0 0;border-radius:6px 0 0 0}.zebra th:last-child{-moz-border-radius:0 6px 0 0;-webkit-border-radius:0 6px 0 0;border-radius:0 6px 0 0}.zebra th:only-child{-moz-border-radius:6px 6px 0 0;-webkit-border-radius:6px 6px 0 0;border-radius:6px 6px 0 0}.zebra tfoot td{border-bottom:0;border-top:1px solid #fff;background-color:#f1f1f1}.zebra tfoot td:first-child{-moz-border-radius:0 0 0 6px;-webkit-border-radius:0 0 0 6px;border-radius:0 0 0 6px}.zebra tfoot td:last-child{-moz-border-radius:0 0 6px 0;-webkit-border-radius:0 0 6px 0;border-radius:0 0 6px 0}.zebra tfoot td:only-child{-moz-border-radius:0 0 6px 6px;-webkit-border-radius:0 0 6px 6px border-radius:0 0 6px 6px}</style>
</head>
<body>
"""

        contents += u"""
    <h2>{project} {percent} {status}</h2>
    <table class="bordered">
        <tr><td>ID</td><td>{id}</td></tr>
        <tr><td>项目名称</td><td>{project_sub}</td></tr>
        <tr><td>版本号</td><td>{version}</td></tr>
        <tr><td>当前状态</td><td>{status_sub}</td></tr>
        <tr><td>创建时间</td><td>{create_time}</td></tr>
        <tr><td>开始发布时间</td><td>{release_starttime}</td></tr>
        <tr><td>查看上线单</td><td>{link}</td></tr>
        <tr><td>上线目的</td><td>{comment}</td></tr>
    </table>
    """.format(
            project=project,
            percent=percent_string(percent[0]),
            status=status_name,
            id=row['id'],
            project_sub=project,
            version=row['version'],
            status_sub=status_name,
            create_time=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(row['create_time']))),
            release_starttime=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(row['deploy_time']))),
            link="http://release.vipshop.com/task/view/%s/" % row['id'],
            comment=re.sub("\n", "<br>", row['comment']),
        )



        #=============================================================
        #validation
        if status == 102:
            time.sleep(30)
            from lib.common import Common
            from lib.node import Node as Tnode
            try:
                result_row = Validation.objects.filter(project=project).values()[0]
            except IndexError:
                result_row = {
                    "port":""
                }

            url_result = Common().validation_url(project, percent[0])

            if url_result:
                contents += u"""
             <h2>验证部分</h2>
             <h5>Url<h5>
             <table class="bordered" style="width:800px">
             <tr>
             	  <th>url</th>
             	  <th>return code</th>
             </tr>
             """

                for row in sorted(url_result.iteritems(), key=lambda d:d[0], reverse = False ):
                    url, return_code = row[0], row[1]
                    if return_code != 200 and return_code != 302:
                        url_style = 'style="background:#FF5151;"'
                    else:
                        url_style=""

                    contents += u"""
                    <tr>
                        <td {url_style}>{url}</td>
                        <td {code_style}>{return_code}</td>
                    </tr>
                    """.format(
                        url_style = url_style,
                        url = url,
                        code_style = url_style,
                        return_code = return_code,
                    )
                contents += u"</table>"


            if not url_result and result_row['port']:
                contents += u"""
             <h2>验证部分</h2>
             """

            if result_row['port']:
                contents += u"""
            <h5>Port<h5>
                <table class="bordered" style="width:800px">
                <tr>
                    <th>IP</th>
                    <th>PORT</th>
                    <th>STATUS</th>
                </tr>
                """

                port_status = ""
                port_style = ""
                for n in Tnode(project).get():
                    port_status = Common().validation_port(n['hostname'], result_row['port'])

                    if port_status:
                        port_style = 'style="background:#FF5151;"'
                        port_status = "ERROR"
                    else:
                        port_style = ""
                        port_status = "OK"

                    contents += u"""
                    <tr>
                        <td {port_style_h}>{host}</td>
                        <td {port_style_p}>{port}</td>
                        <td {port_style_s}>{status}</td>
                    </tr>
                    """.format(
                            port_style_h = port_style,
                            host = n['hostname'],
                            port_style_p = port_style,
                            port = result_row['port'],
                            port_style_s = port_style,
                            status = port_status,
                        )


                contents += u"</table>"








        #===============================================================
        #server
        contents += u"""
    <h2>影响服务器</h2>
    <table class="bordered" style="width:300px">
        """
        for row in Node.objects.filter(project=project).values():
            if row['name'].startswith("Controltier"):
                continue
            contents += """
            <tr><td>%s</td></tr>
            """ % row['hostname']

        contents += """
    </table>
</body>
</html>
        """
        print contents

        m = Sendmail()

        m.send_mail(
            mail_to=mail_to,
            mail_cc=mail_cc,
            subject=u"自动发布系统 {project} {percent} {status}".format(
                project=project,
                percent=percent_string(percent[0]),
                status=status_name,
            ).encode("utf-8"),
            msg=contents,
        )

    return HttpResponse("")
Ejemplo n.º 30
0
 def __init__(self, **kwargs):
     self.path = kwargs.get('path') if kwargs.get(
         'path') else self.save_path()
     self.common = Common()
Ejemplo n.º 31
0
 def __init__(self, **kwargs):
     LoggingPython.__init__(self, log_name="mongo")
     Client.__init__(self,
                     db=kwargs.get("db", "test"),
                     host=kwargs.get('host', '192.168.0.253'))
     self.common = Common()
Ejemplo n.º 32
0
class zaraSpider(scrapy.Spider):
    name = "zara"
    allowed_domains = ["zara.cn"]
    start_urls = [
        #"http://www.zara.cn/cn/zh/%E5%84%BF%E7%AB%A5-c277007.html",
        "http://www.zara.cn/cn/zh/%E5%84%BF%E7%AB%A5-c359013.html",
    ]
    source_currency = "RMB"
    picType = "jpg"
    debug = "true"
    taskId = -1
    commonLib = False
    env_type = "offline"

    def __init__(self, taskId=None, *args, **kwargs):
        super(zaraSpider, self).__init__(*args, **kwargs)
        #self.start_urls = ['http://www.example.com/categories/%s' % category]
        self.taskId = int(taskId)
        self.commonLib = Common()
        self.env_type = self.commonLib.get_env()
        if self.env_type == "online":
            self.debug = ""
        self.commonLib.set_header("env_type",self.env_type)
        self.commonLib.set_header("debug",self.debug)
        self.commonLib.write_log("get task id is [%s]" % (self.taskId))

    def parse(self, response):
        # ## 打折

        try:        
            expectCnt = 1
            actualCnt = 0

            top_bar_list = ["男婴","女婴","男童","女童"]
            urlStatus = common.STATUS_DONE
            assert self.taskId > 0, "taskId [%s] should not be null" % (self.taskId)
            ## //li[@rootid]/ul/li/ul/li

            barList = response.xpath("//li[@class='current selected']/ul/li/a")

            expectCnt = len(barList)
            for category in barList:
                category_url = category.xpath("@href")[0].extract().strip() + "#" + common.LEVEL_HOME
                top_bar_name = category.xpath("text()")[0].extract().strip()
                top_bar = top_bar_name.split(" ")[0].strip()

                actualCnt = actualCnt + 1
                # if top_bar not in top_bar_list:
                #     self.commonLib.write_log("top_bar [%s] is not child category" % (top_bar))
                #     continue
                
                self.commonLib.write_log("top_bar_name is [%s], top_bar is [%s],parse zara url is [%s],actualCnt is [%s] " % (top_bar_name,top_bar,category_url,actualCnt))

                product_info = {}
                product_info['top_bar'] = top_bar
                request = scrapy.Request(category_url, callback=self.parse_category_list)
                request.meta['product_info'] = copy.deepcopy(product_info)
                yield request

            assert actualCnt == expectCnt and expectCnt>0, "parse ActualCnt [%s] is not [equal] expectCnt [%s]" % (actualCnt,expectCnt)

        except Exception, e:
            urlStatus = common.STATUS_FAIL
            exc_type, exc_value, exc_traceback = sys.exc_info()
            msgStr = self.commonLib.write_exception(exc_type, exc_value, exc_traceback)
            self.commonLib.write_log(msgStr)
            yield common.addLog(msgStr,self.taskId,common.LOG_FATAL,response.url,self.name)
        finally:
Ejemplo n.º 33
0
    def test_disablePost(self, login, getUserInfo):
        logging.info("disable interface 开始测试....")
        with allure.step("获取从上一个接口获取到的数据"):
            # 获取从上一个接口获取到的数据 xx,yy
            data = Glob.get_value('QueryResult')
            allIds = Glob.get_value('allIds')
            createPositionId = Glob.get_value('createPositionId')
            reqList = Common.cre_data('disablePost.yaml',
                                      'Post',
                                      data,
                                      idAndVersions='idAndVersions')
            Auth = login
        with allure.step("开始第一次进行disable请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                with allure.step("执行第一次disable请求,校验置为disable"):
                    result = Common.getResult(
                        Common.requestManual(reqlist, Auth))
                    logging.info("返回值为:%s" % result)
                    # 输入返回值的key x
                    pytest.assume(result['changePost'], "INSTANCE")
            with allure.step("第一次执行完整后与数据库数据进行对比..."):
                # 查询输入node 以及 key
                querySqlResult = Common.getSqlResult('post', 'disableCheck', "fetchall", \
                                                     dataposition_id=createPositionId, \
                                                     datapost_level_id='aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18', \
                                                     datatenant_id=getUserInfo,\
                                                     )
                logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
                logging.info("接口返回并sort排序的数据为:%s" % sorted(allIds))
                pytest.assume(sorted(querySqlResult).__eq__(sorted(allIds)))

        with allure.step("进行query查询"):
            data = {'id': createPositionId}
            with allure.step("准备数据"):
                reqList = Common.cre_data('postByPositionId.yaml', 'Post',
                                          data)
                Auth = login
            with allure.step("开始进行接口请求,并取到返回值"):
                for reqlist in reqList:
                    logging.info("这里对接口返回的值进行json取值")
                    ids = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info("返回值为:%s" % ids)
                # 以下是取数,根据返回key取值,替换其中X
                resultList = ids['posts']
                checkDataList = [checkid['id'] for checkid in resultList]

        with allure.step("开始第二次进行disable接口请求,并取到返回值"):
            reqList = Common.cre_data('disablePost.yaml',
                                      'Post',
                                      resultList,
                                      idAndVersions='idAndVersions')
            for reqlist in reqList:
                result = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info("返回值为:%s" % result)
                # 返回KEY X替换
                pytest.assume(result['changePost'], "INSTANCE")
            with allure.step("与数据库数据进行对比..."):
                # 查询输入node 以及 key
                querySqlResult = Common.getSqlResult('post', 'ableCheck', "fetchall", \
                                                     dataposition_id=createPositionId, \
                                                     datapost_level_id='aa3c3d8d-cdf9-42e2-8e71-233f7b87bb18', \
                                                     datatenant_id=getUserInfo)
                logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
                logging.info("接口返回并sort排序的数据为:%s" % sorted(allIds))
                pytest.assume(sorted(querySqlResult).__eq__(sorted(allIds)))
            logging.info("disable interface 结束测试....")
Ejemplo n.º 34
0
    def test_disablePosition(self, login, getUserInfo):
        logging.info("disable interface 开始测试....")
        with allure.step("获取从上一个接口获取到的数据"):
            # 获取从上一个接口获取到的数据 xx,yy
            data = Glob.get_value('QueryResult')
            allIds = Glob.get_value('allIds')
            positionCategoryDict = Glob.get_value('positionCategoryDict')
            reqList = Common.cre_data('disablePosition.yaml',
                                      'Position',
                                      data,
                                      idAndVersions='idAndVersions')
            Auth = login
        with allure.step("开始第一次进行disable请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                with allure.step("执行第一次disable请求,校验置为disable"):
                    result = Common.getResult(
                        Common.requestManual(reqlist, Auth))
                    logging.info("返回值为:%s" % result)
                    # 输入返回值的key x
                    pytest.assume(result['changePosition'], "INSTANCE")
            with allure.step("第一次执行完整后与数据库数据进行对比..."):
                # 查询输入node 以及 key
                querySqlResult = Common.getSqlResult('position', 'disableCheck', "fetchall", \
                                                     datapositionCategoryDict=positionCategoryDict['positionCategoryId'], \
                                                     datatenant_id=getUserInfo)
                logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
                logging.info("接口返回并sort排序的数据为:%s" % sorted(allIds))
                pytest.assume(sorted(querySqlResult).__eq__(sorted(allIds)))

        with allure.step("进行query查询"):
            with allure.step("准备数据"):
                reqList = Common.cre_data('positionStructQuery.yaml',
                                          'Position', None)
            with allure.step("开始进行接口请求,并取到返回值"):
                for reqlist in reqList:
                    logging.info("这里对接口返回的值进行json取值")
                    ids = Common.getResult(Common.requestManual(reqlist, Auth))
                    logging.info("返回值为:%s" % ids)
                    # 以下是取数,根据返回key取值,替换其中X部分为后续命名
                    resultList = ids['struct']
                    checkPositionList = [
                        checkData["positions"] for checkData in resultList
                        if checkData["id"] ==
                        positionCategoryDict['positionCategoryId']
                    ][0]

            with allure.step("开始第二次进行disable接口请求,并取到返回值"):
                reqList = Common.cre_data('disablePosition.yaml',
                                          'Position',
                                          checkPositionList,
                                          idAndVersions='idAndVersions')
            for reqlist in reqList:
                result = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info("返回值为:%s" % result)
                # 返回KEY X替换
                pytest.assume(result['changePosition'], "INSTANCE")
            with allure.step("与数据库数据进行对比..."):
                # 查询输入node 以及 key
                querySqlResult = Common.getSqlResult('position', 'ableCheck', "fetchall", \
                                                     datapositionCategoryDict=positionCategoryDict['positionCategoryId'], \
                                                     datatenant_id=getUserInfo)
                logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
                logging.info("接口返回并sort排序的数据为:%s" % sorted(allIds))
                pytest.assume(sorted(querySqlResult).__eq__(sorted(allIds)))
            logging.info("disable interface 结束测试....")
Ejemplo n.º 35
0
    def test_disableEmploymentType(self, login, getUserInfo):
        logging.info("disable interface 开始测试....")
        with allure.step("获取从上一个接口获取到的数据"):
            # 获取从上一个接口获取到的数据 xx,yy
            data = Glob.get_value("employmentTypesData")
            allIds = Glob.get_value("allIds")
            logging.info("data is: %s" % data)
            reqList = Common.cre_data('disableEmploymentType.yaml',
                                      'NatureEmployment',
                                      data,
                                      SpecialtyInput='input')
            Auth = login

        with allure.step("开始第一次进行disable请求,并取到返回值"):
            for reqlist in reqList:
                logging.info("这里对接口返回的值进行json取值")
                with allure.step("执行第一次disable请求,校验置为disable"):
                    result = Common.getResult(
                        Common.requestManual(reqlist, Auth))
                    logging.info("第一次返回值:%s" % result)
                    #输入返回值的key x
                    pytest.assume(result['mergeEmploymentType'],
                                  reqlist[1]['input']['id'])
            with allure.step("第一次执行完整后与数据库数据进行对比..."):
                #查询输入node 以及 key
                querySqlResult = Common.getSqlResult('employTypeSetting',
                                                     'disableCheck',
                                                     "fetchall",
                                                     tenant_id=getUserInfo)
                logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
                logging.info("接口返回并sort排序的数据为:%s" % sorted(allIds))
                pytest.assume(sorted(querySqlResult).__eq__(sorted(allIds)))

        with allure.step("进行query查询"):
            with allure.step("准备数据"):
                reqList = Common.cre_data('EmploymentQuery.yaml',
                                          'NatureEmployment')
            with allure.step("开始进行接口请求,并取到返回值"):
                for reqlist in reqList:
                    logging.info("这里对接口返回的值进行json取值")
                    ids = Common.getResult(Common.requestManual(reqlist, Auth))
                # 以下是取数,根据返回key取值,替换其中X部分为后续命名
                resultList = ids['employmentTypes']

        with allure.step("开始第二次进行disable接口请求,并取到返回值"):
            reqList = Common.cre_data('disableEmploymentType.yaml',
                                      'NatureEmployment',
                                      resultList,
                                      SpecialtyInput='input')

            for reqlist in reqList:
                result = Common.getResult(Common.requestManual(reqlist, Auth))
                logging.info("第二次返回值:%s" % result)
                #返回KEY X替换
                pytest.assume(result['mergeEmploymentType'],
                              reqlist[1]['input']['id'])
            with allure.step("与数据库数据进行对比..."):
                #查询输入node 以及 key
                querySqlResult = Common.getSqlResult('employTypeSetting',
                                                     'ableCheck',
                                                     "fetchall",
                                                     tenant_id=getUserInfo)
                logging.info("数据库查询并sort排序的结果为:%s" % sorted(querySqlResult))
                logging.info("接口返回并sort排序的数据为:%s" % sorted(allIds))
                pytest.assume(sorted(querySqlResult).__eq__(sorted(allIds)))
        logging.info("disable interface 结束测试....")
Ejemplo n.º 36
0
            client.download(url)


if __name__ == "__main__":
    # common = Common()
    # client = NewSpider3()
    # info = common.order_dict(client.spider(), index=0, reverse=False)
    # client.browser.close()
    #
    #
    # client = Thunder()
    # for item in info.items():
    #     client.download(item[1], item[0])

    path = r'E:\共享文件夹\后端之路\框架学习\Django\繁华嗅'
    # path = r'C:\Users\yeyuc\Desktop\帽子哥'
    # path = r'C:\Users\yeyuc\Desktop\助眠'
    #
    # client = NewSpider1()
    # client = NewSpider2()
    client = NewSpider4()
    urls = client.spider()
    client.browser.close()

    urls = ["https://www.bilibili.com/video/av" + item for item in urls]

    client = Work(path=path)
    data = Common().split_list(urls, 8)
    client.process(data)
    pass