Esempio n. 1
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 结束测试....")
Esempio n. 2
0
 def run_selectDisplayMode_case(self, casename, data):
     with allure.step("点击设置按钮"):
         self.click_ele(self.supplierBoxPage_supplierBoxSettingBtn_loc)
     with allure.step("{}".format(casename)):
         if data["select_supplierName"]:
             self.supplierBoxPageCommon.select_displayMode(is_select=1)
         else:
             self.supplierBoxPageCommon.select_displayMode(is_select=0)
         if data["select_supplierShortName"]:
             self.supplierBoxPageCommon.select_displayMode(is_select=1,
                                                           type="供应商简称")
         else:
             self.supplierBoxPageCommon.select_displayMode(is_select=0,
                                                           type="供应商简称")
         if data["select_supplierCode"]:
             self.supplierBoxPageCommon.select_displayMode(is_select=1,
                                                           type="供应商代码")
         else:
             self.supplierBoxPageCommon.select_displayMode(is_select=0,
                                                           type="供应商代码")
     with allure.step("点击确定按钮"):
         self.click_ele(self.supplierBoxPage_sureBtn_loc)
     with allure.step("获取toast提示"):
         toast_text = self.get_elementText(self.toast_loc)
         pytest.assume(
             data["toast"] == toast_text,
             'data["toast"]:{},toast_text:{}'.format(
                 data["toast"], toast_text))
     with allure.step("获取最近联系的供应商箱名"):
         supplierBoxNames = self.supplierBoxPageCommon.get_allSupplierBoxName(
             level=2)
         pytest.assume(
             data["expect"] in supplierBoxNames,
             'data["expect"]:{},supplierBoxNames:{}'.format(
                 data["expect"], supplierBoxNames))
Esempio n. 3
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 结束测试....")
Esempio n. 4
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 结束测试....")
Esempio n. 5
0
 def test011_merge_result(self):
     func_name = sys._getframe().f_code.co_name
     csurl, method, headers, yamlvalue, yaml_path, mainkey = get_common_params('merge.yaml', func_name)
     a = RestClient(rooturl)
     res = a.request(url=csurl, method=method, json=yamlvalue['data'], headers=headers)
     check_codes_msg(res, yamlvalue, mainkey)
     pytest.assume('"yihuikuanjine":"77"' in res.text)
def test_uuconvert_template_to_string_format_undocumented1(request, mocker):
    logger.info(f'{request._pyfuncitem.name}()')
    exp_value = 'ping {{app.inner_host_name}}'
    value = uuconvert_template_to_string_format(exp_value,
                                                default_start=None,
                                                default_end=None)
    pytest.assume(exp_value == value)
 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 结束测试....")
Esempio n. 8
0
 def test_01(self):
     """用例1"""
     print('执行test_01断言1')
     pytest.assume(0 == 1)
     pytest
     print('执行test_01断言2')
     pytest.assume(1 == 2)
Esempio n. 9
0
 def test2(self):
     print("test2...")
     # assert 1 == 2  # python3的断言只会断言一次
     # self.assertEqual(2, 3)  # unittest的断言也只会断言一次
     # self.assertEqual(3, 4)
     pytest.assume(1 == 2)  # pytest的断言可以进行多次
     pytest.assume(2 == 3)
Esempio n. 10
0
def test_4ocr_valu44():  # ok
    log = logging.getLogger(__name__)
    mongo = MongoManager()
    table_dict = mongo.get_table('GG_6TABLE')
    table_scraper = TableScraper(table_dict)
    file_name = get_dir(os.path.join('log', 'pics', 'table_b_16.png'))

    table_scraper.screenshot = Image.open(file_name)
    # table_scraper.crop_from_top_left_corner2(select_table=0)
    if is_debug:
        # table_scraper.screenshot.save('log/pics/table1.png')
        file_name = get_dir(os.path.join('log', 'pics', 'table_label.png'))
        save_table_rectangle_cv2(table_scraper.screenshot, table_dict,
                                 file_name)
    table_scraper.get_pots()
    table_scraper.get_players_funds()
    table_scraper.get_player_pots()
    log.info(f"{table_scraper.total_pot}")
    log.info(f"{table_scraper.current_round_pot}")
    log.info(f"{table_scraper.player_funds}")
    log.info(f"{table_scraper.player_pots}")
    # pytest.assume(table_scraper.total_pot == 4.0)
    # assert table_scraper.total_pot == 4.0
    # pytest.assume(table_scraper.player_pots == [-1.0, -1.0, -1.0, 0.5, -1.0, 1.0])
    pytest.assume(table_scraper.current_round_pot == 2.0)
Esempio n. 11
0
 def test_search_by_keywords(self, name):
     self.dpjhPage.search_by_keywords(name)
     if name == "抗菌药物点评":  # 存在的计划
         pytest.assume(self.dpjhPage.is_exist_plan(name), "按关键字搜索计划有问题")
     if name == "天上人间":  # 不存在的计划
         pytest.assume(
             self.dpjhPage.is_exist_plan(name) == False, "按关键字搜索计划有问题")
Esempio n. 12
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 结束测试....")
 def check_emailNumOfLeftSide(self, homepage_totalEmailNum=0):
     with allure.step("获取搜索之后的邮件总数"):
         totalEmailNum_v2 = self.get_elementText(self.emailNumTotal_loc)
         totalEmailNum_v2 = int(totalEmailNum_v2[2:-2])
         if homepage_totalEmailNum:
             pytest.assume(
                 homepage_totalEmailNum != totalEmailNum_v2,
                 "homepage_totalEmailNum:{},totalEmailNum_v2:{}".format(
                     homepage_totalEmailNum, totalEmailNum_v2))
     with allure.step("获取客户/供应商的邮件总数"):
         totalEmailNum_customer = self.get_searchEmailNum()
         pytest.assume(
             totalEmailNum_customer > 0,
             "totalEmailNum_customer:{}".format(totalEmailNum_customer))
     with allure.step("获取全部位置的邮件总数"):
         totalEmailNum_allPosition = self.get_searchEmailNum(type=1)
         pytest.assume(
             totalEmailNum_allPosition == totalEmailNum_v2,
             "totalEmailNum_allPosition:{},totalEmailNum_v2:{}".format(
                 totalEmailNum_allPosition, totalEmailNum_v2))
     with allure.step("获取回复状态的邮件总数"):
         totalEmailNum_reply = self.get_searchEmailNum(type=2)
         pytest.assume(
             totalEmailNum_reply == totalEmailNum_v2,
             "totalEmailNum_reply:{},totalEmailNum_v2:{}".format(
                 totalEmailNum_reply, totalEmailNum_v2))
     with allure.step("获取阅读状态的邮件总数"):
         totalEmailNum_read = self.get_searchEmailNum(type=3)
         pytest.assume(
             totalEmailNum_read == totalEmailNum_v2,
             "totalEmailNum_read:{},totalEmailNum_v2:{}".format(
                 totalEmailNum_read, totalEmailNum_v2))
Esempio n. 14
0
 def test_viplist(self):
     expect, actual = meizhu_api.meizhu('post', 'dict', '会员列表',
                                        '/Home/Customer/vip')
     actual = json.loads(actual[0])
     pytest.assume(expect[0] == actual['status'])
     global vipUserId
     vipUserId = actual['data']['item'][0]['id']
Esempio n. 15
0
    def test_add(self, calculation, get_add_data):

        result = self.calc.add(get_add_data[0], get_add_data[1])
        # 由于python底层的计算处理逻辑  0.30000000000000004 != 0.3, 需要将是浮点数的result 利用round函数保留2位小数
        if isinstance(result, float):
            result = round(result, 2)
        pytest.assume(result == get_add_data[2])
Esempio n. 16
0
def test_no_command_passed(capsys):
    ret = main([])
    assume(ret != 0)
    out, err = capsys.readouterr()
    assume(out == "")
    # skip the first lines because they differ between macos and linux
    assert err.splitlines()[2:] == HELP_MESSAGE.splitlines()[2:]
def test_uconvert_template_to_string_explicit_param1b_jinja2Lock(
    request,
    mocker,
    ymlparsersExtraFixture,
):
    logger.info(f'{request._pyfuncitem.name}{ymlparsersExtraFixture}')

    ymlparsers.initConfig(jinja2ctx={
        'variable_start_string': '22_',
        'variable_end_string': '_22'
    })

    init_jinja2ctx = HiYaPyCo.jinja2ctx
    mock_lock = create_mock_lock(mocker)
    mocker.patch.object(HiYaPyCo, 'jinja2Lock', new=mock_lock, spec_set=True)
    jinja2ctx_mock = mocker.patch.object(HiYaPyCo, 'jinja2ctx', spec_set=True)
    mock_variable_start_string = mocker.PropertyMock(
        return_value=init_jinja2ctx.variable_start_string)
    type(jinja2ctx_mock).variable_start_string = mock_variable_start_string
    mock_variable_end_string = mocker.PropertyMock(
        return_value=init_jinja2ctx.variable_end_string)
    type(jinja2ctx_mock).variable_end_string = mock_variable_end_string

    #exp_value = '{name}'
    template = '22_name_22'  #HiYaPyCo.jinja2ctx is non default one and external lock

    jinja2Lock_param_lock = create_mock_lock(mocker)
    with pytest.raises(ValueError):
        _convert_template_to_string_format(template,
                                           jinja2Lock=jinja2Lock_param_lock)
    #pytest.assume(exp_value == value)
    pytest.assume(mock_lock.acquire.call_count == 0)
Esempio n. 18
0
 def run_setSenderCondition_case(self, data):
     if data["is_equal"]:
         with allure.step("点击等于按钮"):
             equalSenderBtn_loc = self.queryBoxPageCommon.generateEqualXpathBySubject(
                 "发件人")
             self.click_ele(equalSenderBtn_loc)
     with allure.step("输入发件人"):
         senderInput_loc = self.queryBoxPageCommon.generateXpathBySubject(
             "发件人")
         self.sendKeys(senderInput_loc, key=data["sender"])
     with allure.step("点击确定按钮"):
         self.click_ele(self.queryBoxPage_sureBtn_loc)
     with allure.step("获取toast提示"):
         toast_text = self.get_elementText(self.toast_loc)
         pytest.assume(toast_text == "新建成功!",
                       "toast_text:{}".format(toast_text))
     with allure.step("点击第一个查询箱"):
         self.click_ele(self.queryBoxPage_queryBoxList_loc)
     with allure.step("获取所有的发件人"):
         emailSenders = self.recipientBoxPageCommon.get_allEmailSender()
     for sender in emailSenders:
         pytest.assume(
             data["sender"] in sender or sender == "管理员",
             "设置的条件,发件人-data['sender']:{},查询箱的查询结果,发件人-sender:{}".format(
                 data["sender"], sender))
 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 结束测试....")
Esempio n. 20
0
 def run_setServalDaysCondition_case(self, data):
     if data["is_send"]:
         with allure.step("点击发件按钮"):
             self.click_ele(self.queryBoxPage_servalDaysSendBtn_loc)
     with allure.step("输入日期"):
         servalDaysInput_loc = self.queryBoxPageCommon.generateXpathBySubject(
             "几天内")
         self.sendKeys(servalDaysInput_loc, key=data["day_num"])
     with allure.step("点击确定按钮"):
         self.click_ele(self.queryBoxPage_sureBtn_loc)
     with allure.step("获取toast提示"):
         toast_text = self.get_elementText(self.toast_loc)
         pytest.assume(toast_text == "新建成功!",
                       "toast_text:{}".format(toast_text))
     with allure.step("点击第一个查询箱"):
         self.click_ele(self.queryBoxPage_queryBoxList_loc)
     with allure.step("点击最后一页"):
         self.recipientBoxPageCommon.turnEmailPage()
     with allure.step("获取邮件详情里面的日期"):
         dates = self.recipientBoxPageCommon.get_allEmailDate()
     if "前" not in dates[-1]:
         print(dates[-1].replace("/", ""))
         actual_time = dates[-1].replace("/", "")
         with allure.step("判断时间是否正确"):
             current_time = time.time()
             print(current_time)
             purpose_time = time.strftime(
                 "%m%d",
                 time.localtime(current_time -
                                24 * 60 * 60 * data["day_num"]))
             print(purpose_time)
             pytest.assume(
                 int(purpose_time) <= int(actual_time),
                 "设置的条件,天数:{},查询箱的最后一个结果实际时间:{},当前的时间:{}".format(
                     data["day_num"], actual_time, current_time))
Esempio n. 21
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 结束测试....")
Esempio n. 22
0
 def run_delQueryBox_case(self):
     with allure.step("悬浮一个可删除的查询箱"):
         firstCanDelQueryBoxName = self.get_elementText(
             self.queryBoxPage_canDelQueryBoxList_loc)
         self.mouseHover_visibleEle(
             self.queryBoxPage_canDelQueryBoxList_loc)
     time.sleep(0.5)
     with allure.step("悬浮更多操作按钮"):
         self.mouseHover_visibleEle(
             self.queryBoxPage_queryBoxMoreOperateBtn_loc)
     time.sleep(1)
     with allure.step("点击删除按钮"):
         self.click_ele(self.queryBoxPage_delQueryBoxBtn_loc)
     with allure.step("点击确认删除按钮"):
         self.click_ele(self.queryBoxPage_sureDelQueryBoxBtn_loc)
     with allure.step("获取toast提示,并判断"):
         toast_text = self.get_elementText(self.toast_loc)
         pytest.assume(toast_text == "删除成功",
                       "toast_text:{}".format(toast_text))
     with allure.step("获取所有的查询箱名"):
         queryBoxNames = self.queryBoxPageCommon.get_queryBoxNames()
         pytest.assume(
             firstCanDelQueryBoxName not in queryBoxNames,
             "删除的查询箱:{},删除后的查询箱列表:{}".format(firstCanDelQueryBoxName,
                                             queryBoxNames))
Esempio n. 23
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 结束测试....")
def test_uconvert_template_to_string_HiYaPyCoDefaultChanged(
        request, mocker, ymlparsersExtraFixture):
    logger.info(f'{request._pyfuncitem.name}{ymlparsersExtraFixture}')

    ymlparsers.initConfig(jinja2ctx={
        'variable_start_string': '2_',
        'variable_end_string': '_2'
    })
    init_jinja2ctx = HiYaPyCo.jinja2ctx

    mock_lock = create_mock_lock(mocker)
    mocker.patch.object(HiYaPyCo, 'jinja2Lock', new=mock_lock, spec_set=True)
    jinja2ctx_mock = mocker.patch.object(HiYaPyCo, 'jinja2ctx', spec_set=True)
    mock_variable_start_string = mocker.PropertyMock(
        return_value=init_jinja2ctx.variable_start_string)
    type(jinja2ctx_mock).variable_start_string = mock_variable_start_string
    mock_variable_end_string = mocker.PropertyMock(
        return_value=init_jinja2ctx.variable_end_string)
    type(jinja2ctx_mock).variable_end_string = mock_variable_end_string

    exp_value = '{name}'
    template = '2_name_2'
    value = _convert_template_to_string_format(template)
    pytest.assume(exp_value == value)

    pytest.assume(mock_lock.acquire.call_count > 0)
    pytest.assume(mock_lock.release.call_count == mock_lock.acquire.call_count)

    pytest.assume(mock_variable_start_string.call_count > 0)
    pytest.assume(mock_variable_end_string.call_count > 0)
Esempio n. 25
0
 def write_allure(self, testCase):
     allure.dynamic.feature(testCase['模块名称'])
     allure.dynamic.title(testCase['测试用例名称'])
     result = self.batch_execution_cases(testCase)
     for r in result:
         with allure.step(r['接口名称']):
             with allure.step(f'''发送请求-->'''):
                 with allure.step(f'请求方式: {r["请求方式"]}'):
                     pass
                 with allure.step(f'请求地址: {r["请求地址"]}'):
                     pass
                 with allure.step(f'请求头: {r["请求头"]}'):
                     pass
                 with allure.step(f'请求参数: {r["请求参数"]}'):
                     pass
                 with allure.step(f'响应结果: {r["实际结果"]}'):
                     pass
             with allure.step('进行预期结果与实际结果的断言'):
                 for key, value in r['预期结果'].items():
                     with allure.step(
                             f'{key}断言:预期结果:{value[0]},实际结果:{jmespath.search(value[1], r["实际结果"])}'
                     ):
                         # assert value[0] == jmespath.search(value[1], r['实际结果'])
                         pytest.assume(value[0] == jmespath.search(
                             value[1], r['实际结果']))
Esempio n. 26
0
def test__typed_property():
    from syncsweptsine import _typed_property

    class T(object):
        prop_str = _typed_property(name='prop_str',
                                   expected_type=str,
                                   desc='This is a string property.')
        prop_scalar = _typed_property(
            name='prop_scalar',
            expected_type=(int, float),
            desc='This is a scalar type, accepting int and float.')

    tinst = T()
    TESTSTR = 'test123'
    tinst.prop_str = TESTSTR
    assume(tinst.prop_str == TESTSTR)
    assume(tinst._prop_str == TESTSTR)
    with pytest.raises(TypeError):
        tinst.prop_str = 1
    with pytest.raises(TypeError):
        tinst.prop_str = 0.1
    with pytest.raises(TypeError):
        tinst.prop_str = False
    TESTSCALAR = 19878215
    tinst.prop_scalar = TESTSCALAR
    assume(tinst.prop_scalar == TESTSCALAR)
    assume(tinst._prop_scalar == TESTSCALAR)
    tinst.prop_scalar = TESTSCALAR * 3.1415
    with pytest.raises(TypeError):
        tinst.prop_scalar = '0.45234'

    assume(hasattr(tinst, '_typed_property_was_changed'))
Esempio n. 27
0
async def test_pool_by_params(driver, event_loop):
    db = AsyncDB(driver, params=params, loop=event_loop)
    assert db.is_connected() is False
    await db.connection()
    pytest.assume(db.is_connected() is True)
    await db.close()
    assert db.is_closed() is True
Esempio n. 28
0
def test_ymlparsers_load_single_no_substition(request, mocker, ymlparsersSetup,
                                              ymlparsersCleanup, exp_config_d):
    logger.info(f'{request._pyfuncitem.name}()')

    pck = '.'.join(['tests_data', __package__, 'ymlparsers'])

    mock_lock = create_mock_lock(mocker)
    mocker.patch.object(HiYaPyCo, 'jinja2Lock', new=mock_lock, spec_set=True)

    with path(pck, 'config.yml') as full_path:
        with ymlparsers.DisableVarSubst():
            default_d = ymlparsers.load([str(full_path)])

    # ymlparsers.load() when uses HiYaPyCo.jinja2ctx uses HiYaPyCo.jinja2Lock
    # note, that ymlparsers.DisableVarSubst also use 1 time HiYaPyCo.jinja2Lock
    pytest.assume(mock_lock.acquire.call_count > 1)
    pytest.assume(mock_lock.release.call_count == mock_lock.acquire.call_count)

    app_d = default_d.get('app', None)
    exp_d = copy.deepcopy(exp_config_d)
    exp_app_d = exp_d.get('app', None)

    inner_host_name = app_d.get('inner_host_name', None)
    exp_host_name = exp_app_d.get('inner_host_name', None)
    pytest.assume(exp_host_name == inner_host_name)
    cli_template = app_d.get('cli_template')
    pytest.assume('inner_host_name' in cli_template)
    pytest.assume(exp_config_d == default_d)
Esempio n. 29
0
async def test_connect(driver, event_loop):
    db = AsyncDB(driver, params=params, loop=event_loop)
    await db.connection()
    pytest.assume(db.is_connected() is True)
    result, error = await db.test_connection()
    pytest.assume(type(result) == list)
    await db.close()
    def test_add_member(self):
        userid = '17712345686'

        # 添加联系人
        res = self.memeber.add_member(userid,
                                      name='李子789',
                                      mobile="17111111186",
                                      department=[1])
        pytest.assume(res.get('errcode') == 0)
        # print(f'res打印结果:{res}')

        # 查找联系人
        res = self.memeber.find_member(userid)
        pytest.assume(res.get('errcode') == 0)
        # print(f'res打印结果:{res}')

        ## 更新联系人
        self.memeber.update_member(
            userid,
            name='张三zi',
        )
        pytest.assume(res.get('errcode') == 0)
        # print(f'res打印结果:{res}')

        # 删除联系人
        res = self.memeber.delete_member(userid)
        pytest.assume(res.get('errcode') == 0)
        # print(f'res打印结果:{res}')

        #
        # 查找联系人
        res = self.memeber.find_member(userid)
        pytest.assume(res.get('errcode') == 60111)
Esempio n. 31
0
def render_doctree(doctree, out_filename, reference_path,
                   template_configuration=None):
    if template_configuration:
        document = template_configuration.document(doctree)
    else:
        document = MinimalTemplate(doctree)
    output_dir = OUTPUT_DIR / out_filename
    output_dir.mkdir(parents=True, exist_ok=True)
    document.render(output_dir / out_filename)
    pdf_filename = '{}.pdf'.format(out_filename)
    _, _, _, _, _, _, ref_outlines = \
        check_pdf_links(reference_path / pdf_filename)
    with in_directory(output_dir):
        _, _, _, badlinks, _, _, outlines = check_pdf_links(pdf_filename)
        pytest.assume(badlinks == [])
        pytest.assume(ref_outlines == outlines)
        if not diff_pdf(reference_path / pdf_filename, pdf_filename):
            pytest.fail('The generated PDF is different from the reference '
                        'PDF.\nGenerated files can be found in {}'
                        .format(output_dir))
Esempio n. 32
0
def test_rstdemo():
    config = TemplateConfigurationFile(TEST_DIR / 'rstdemo.rtt')

    parser = ReStructuredTextReader()
    flowables = parser.parse(TEST_DIR / 'demo.txt')
    document = config.document(flowables)
    out_dir = OUTPUT_DIR / 'rstdemo'
    out_dir.mkdir(parents=True, exist_ok=True)
    pdf_filename = 'demo.pdf'
    _, _, _, _, _, _, ref_outlines = check_pdf_links(TEST_DIR / 'reference'
                                                     / pdf_filename)
    with in_directory(out_dir):
        document.render('demo')
        _, _, _, badlinks, _, _, outlines = check_pdf_links(pdf_filename)
        pytest.assume(badlinks == ['table-of-contents'])
        pytest.assume(ref_outlines == outlines)
        if not diff_pdf(TEST_DIR / 'reference' / 'demo.pdf', 'demo.pdf'):
            pytest.fail('The generated PDF is different from the reference '
                        'PDF.\nGenerated files can be found in {}'
                        .format(out_dir))