Пример #1
0
def positive_check_snapLogicmatch(api_admin, areaCode, expect_snapType,
                                  expect_userType):
    with allure.step("校验:校验第二次上报图片的校验结果"):
        with allure.step("取出第二次上报图片的抓拍时间"):
            res_json1 = api_admin.scn_snap_list(areaCodesList=[areaCode],
                                                expected_value=2)
            snapTime_list = JsonHelper.parseJson_by_objectpath(
                res_json1, "$..*[@.snapTime]", res_allowNone=True)
            snapTime = snapTime_list[
                0] if snapTime_list[0] > snapTime_list[1] else snapTime_list[1]
            res_json = api_admin.scn_snap_list(startDateTime=snapTime,
                                               areaCodesList=[areaCode])

        with allure.step("校验:上报数据抓拍类型及访客类型处理结果"):
            actual_snapType = JsonHelper.parseJson_by_objectpath(
                res_json,
                "$..*[@.snapType]",
                res_allowNone=True,
                res_firstOne=True)
            expect_snapType = expect_snapType
            AllureHelper.assert_equal("抓拍类型校验", expect_snapType,
                                      actual_snapType)

            actual_userType = JsonHelper.parseJson_by_objectpath(
                res_json,
                "$..*[@.userType]",
                res_allowNone=True,
                res_firstOne=True)
            expect_userType = expect_userType
            AllureHelper.assert_equal("访客的类型校验", expect_userType,
                                      actual_userType)
Пример #2
0
    def assert_actualTime_in_timeErrorRange(self,
                                            actual_time,
                                            offset_sec=None):
        '''
        功能:实际时间是否在当前时间允许的误差范围内
        :param actual_time: 待校验的时间,其时间格式为:%Y-%m-%d %H:%M:%S
        :param offset_sec: 时间误差偏移量
        :return:
        '''

        # 默认参数定义
        if not offset_sec:
            offset_sec = 5
        # time_format = "%Y-%m-%d %H:%M:%S"

        # 获取到实际的时间戳
        actual_timestamp = TimeHelper.get_timestamp_from_time(actual_time)

        # 获取期望的时间戳范围
        floor_expect_timestamp = actual_timestamp - offset_sec
        ceil_expect_timestamp = actual_timestamp + offset_sec

        with allure.step('[断言校验]实际时间在期望时间区间范围内,误差偏移量是 {}秒'.format(offset_sec)):
            AllureHelper.attachText("", "实际时间:{}".format(actual_time))
            AllureHelper.attachText(
                "", "期望时间区间:{}--{}".format(
                    TimeHelper.get_time_from_timestamp(floor_expect_timestamp),
                    TimeHelper.get_time_from_timestamp(ceil_expect_timestamp)))

            assert actual_timestamp >= floor_expect_timestamp and actual_timestamp <= ceil_expect_timestamp
Пример #3
0
 def checkLoginInfo(self):
     start_time = time.time()
     while True:
         try:
             info_dict = dict()
             end_time = time.time()
             # 等待接收到11个字节
             res = self.conn.recv(11)
             # 获取信息:数据长度、功能号
             data_len = int.from_bytes(res[1:5], byteorder='big')
             func_num = int.from_bytes(res[5:7], byteorder='big')
             self.conn.recv(data_len)
             tmp_res = 'NETTY服务器回复功能号:%s' % func_num_map.functionNo_dict.get(func_num)
             AllureHelper.attachText(tmp_res,"NETTY服务器回复功能号")
             if func_num == 2:
                 info_dict.setdefault('设备登录', func_num_map.functionNo_dict.get(func_num))
                 self.log.log_info("收到设备登录信息回包:{}".format(info_dict))
                 break
             if func_num == 4:
                 info_dict.setdefault('设备心跳', func_num_map.functionNo_dict.get(func_num))
                 self.log.log_info("收到设备心跳信息回包:{}".format(info_dict))
             if end_time - start_time >= 120:
                 raise Exception("NETTY服务器2min超时未回复ReplyLogin")
         except Exception:
             raise Exception("NETTY服务器失败回复ReplyLogin")
Пример #4
0
def snap_node_identification(response,
                             expect_snapRecordStatus,
                             expect_collectRecordStatus=None):
    with allure.step('校验:接口响应信息'):
        with allure.step('校验:查询数据为两条'):
            expect_value = 2
            actual_value = JsonHelper.parseJson_by_objectpath(
                response, "$..*[@.total]")[0]
            AllureHelper.assert_equal("接口查询返回条数", actual_value, expect_value)

        with allure.step('校验:查询结果中两条数据faceid相同'):
            expected_value = JsonHelper.parseJson_by_objectpath(
                response, "$..*[@.faceId]")[0]
            actual_value = JsonHelper.parseJson_by_objectpath(
                response, "$..*[@.faceId]")[1]
            AllureHelper.assert_equal("faceID查询的两条数据", actual_value,
                                      expected_value)

        with allure.step('校验:snapRecordStatus值'):

            actual_snapRecordStatus = \
                JsonHelper.parseJson_by_objectpath(response, "$.*.data.list.snapRecordStatus")[0]
            AllureHelper.assert_equal("抓拍节点下图片去重状态对应字段",
                                      expect_snapRecordStatus,
                                      actual_snapRecordStatus)
        if expect_collectRecordStatus is not None:
            with allure.step('校验:collectRecordStatus值'):

                actual_collectRecordStatus = \
                    JsonHelper.parseJson_by_objectpath(response, "$.*.data.list.collectRecordStatus")[0]
                AllureHelper.assert_equal("汇总节点下图片去重状态对应字段",
                                          expect_collectRecordStatus,
                                          actual_collectRecordStatus)
Пример #5
0
def positive_check_snapLogic(api_admin, areaCode, expect_snapType,
                             expect_userType, expect_snapRecordStatus,
                             expect_collectRecordStatus, expect_faceId):

    with allure.step('测试步骤:抓拍列表查询'):
        res_json = api_admin.scn_snap_list(areaCodesList=areaCode,
                                           res_accurate=False,
                                           expected_value=1)

        actual_snapType = JsonHelper.parseJson_by_objectpath(
            res_json,
            "$..*[@.snapType]",
            res_allowNone=True,
            res_firstOne=True)
        expect_snapType = expect_snapType
        AllureHelper.assert_equal("抓拍类型校验", expect_snapType, actual_snapType)

        actual_userType = JsonHelper.parseJson_by_objectpath(
            res_json,
            "$..*[@.userType]",
            res_allowNone=True,
            res_firstOne=True)
        expect_userType = expect_userType
        AllureHelper.assert_equal("访客的类型校验", expect_userType, actual_userType)

        actual_snapRecordStatus = JsonHelper.parseJson_by_objectpath(
            res_json,
            "$..*[@.snapRecordStatus]",
            res_allowNone=True,
            res_firstOne=True)
        expect_snapRecordStatus = expect_snapRecordStatus
        AllureHelper.assert_equal("抓拍节点-客流处理状态校验", expect_snapRecordStatus,
                                  actual_snapRecordStatus)

        actual_collectRecordStatus = JsonHelper.parseJson_by_objectpath(
            res_json,
            "$..*[@.collectRecordStatus]",
            res_allowNone=True,
            res_firstOne=True)
        expect_collectRecordStatus = expect_collectRecordStatus
        AllureHelper.assert_equal("汇总节点-客流处理状态", expect_collectRecordStatus,
                                  actual_collectRecordStatus)

        faceId = JsonHelper.parseJson_by_objectpath(res_json,
                                                    "$..*[@.faceId]",
                                                    res_allowNone=True,
                                                    res_firstOne=True)
        actual_faceId = False if faceId == "0" else True
        expect_faceId = expect_faceId
        AllureHelper.assert_equal("人脸库faceId值校验", expect_faceId, actual_faceId)
Пример #6
0
    def assert_actual_lt_expect(self, desc_msg, actual_value, expect_value):
        """
        断言方法:actual_value < expect_value
        :param desc_msg: 需要校验的值
        :param actual_var: 实际值
        :param expect_var: 期望值
        """

        validator.check_paramType_str(desc_msg)
        validator.check_paramType_int(actual_value, expect_value)

        with allure.step('[断言校验]实际值小于期望值:{}'.format(desc_msg)):
            AllureHelper.attachText("", "实际值:{}".format(actual_value))
            AllureHelper.attachText("", "期望值:{}".format(expect_value))
            assert expect_value < actual_value
Пример #7
0
    def assert_actual_equal_expect(self, desc_msg, actual_value, expect_value):
        """
        断言方法:expect_value等于actual_value
        :param desc_msg: 需要校验的值
        :param actual_var: 实际值
        :param expect_var: 期望值
        """

        validator.check_paramType_str(desc_msg)

        if type(actual_value) != type(expect_value):
            actual_value = str(actual_value)
            expect_value = str(expect_value)

        with allure.step('[断言校验]实际值等于期望值:{}'.format(desc_msg)):
            AllureHelper.attachText("", "实际值:{}".format(actual_value))
            AllureHelper.attachText("", "期望值:{}".format(expect_value))
            assert expect_value == actual_value
Пример #8
0
    def simulate_device_uploadPic(self, img_time=None, score=None, img_path=None, body_img_path=None, userStatus=None, capAngle=None):

        if img_time is None:
            img_time = TimeHelper.get_time(t=TimeHelper.get_time_from_timestamp(), offset=10)
        if score is None:
            score = str(random.randint(80, 190) / 100)
        if img_path is None:
            img_path = gen_bnsData.get_face_picture(index=1)
        face_frame = ImageHelper.pic_to_bytes(img_path)
        if body_img_path is None:
            body_frame = face_frame
        else:
            body_frame = ImageHelper.pic_to_bytes(body_img_path)
        if userStatus is None:
            userStatus = 2  # 默认进店
        if capAngle is None:
            capAngle = 0  # 默认正脸
        alarmId = gen_bnsData.get_alarmId(timestamp=TimeHelper.get_timestamp_from_time(assigned_time=img_time))

        pb_login_msg = pb_business.upload_v4_data(self.aes_key, img_time, face_frame, body_frame, float(score), userStatus, capAngle, alarmId)
        msg_aes_len = len(pb_login_msg)
        format = '>BIHI%ds' % (msg_aes_len)
        send_msg = struct.pack(format, int('0x1A', 16), msg_aes_len, func_num_map.DankiV4ReportData, 0, pb_login_msg)

        # 定义函数需要返回的信息
        info_dict = dict()
        info_dict.setdefault('img_time', img_time)
        info_dict.setdefault('score', score)
        info_dict.setdefault('alarmId', alarmId)
        info_dict.setdefault('userStatus', userStatus)
        info_dict.setdefault('capAngle', capAngle)
        # info_dict.setdefault('face_frame', face_frame)

        self.checkLoginInfo()

        self.send_message(send_msg)
        self.log.log_info("设备上报图片信息:{}".format(info_dict))

        self.checkReplyInfo()

        AllureHelper.attachJson(info_dict, "设备上报的信息")
        AllureHelper.attachPic(face_frame, "设备上报的图片")

        return info_dict
Пример #9
0
    def assert_actual_notContain_expect(self, desc_msg, actual_value, expect_value):
        """
        断言方法:expect_value不被actual_value包含
        :param desc_msg: 对不期望被包含内容的一个解释说明
        :param actual_var: 实际值
        :param expect_var: 期望值
        """

        if not isinstance(actual_value, str):
            actual_value = str(actual_value)

        if not isinstance(expect_value, str):
            expect_value = str(expect_value)

        validator.check_paramType_str(desc_msg, expect_value, actual_value)

        with allure.step('[断言校验]实际值不包含期望值:{}'.format(desc_msg)):
            AllureHelper.attachText("", "实际值:{}".format(actual_value))
            AllureHelper.attachText("", "期望值:{}".format(expect_value))
            assert expect_value not in actual_value
Пример #10
0
    def test_基本的数据处理流程_去重时间外普客多次到访(self, api_technicalSupport, 关联_抓拍子节点_进店,
                                   关联_设备绑定节点):

        with allure.step('前置条件:模拟设备上报一张人脸图片'):
            gen_devData.simulate_device_upload_pic(
                关联_设备绑定节点["deviceCodeOrBar"], score=1.2)

        with allure.step('店客云及技术支持:查看抓拍列表'):
            actual_count = api_technicalSupport.scn_snap_list(
                areaCodesList=[关联_抓拍子节点_进店["areaCode"]],
                expected_value=1,
                res_accurate=True)
            AllureHelper.assert_equal("抓拍列表人数统计", 1, actual_count)

        with allure.step('店客云及技术支持:查看访客列表'):
            actual_count = api_technicalSupport.scn_snap_visit_list(
                areaCode=关联_抓拍子节点_进店["areaCode"],
                expected_value=1,
                res_accurate=True)
            AllureHelper.assert_equal("访客列表人数统计", 1, actual_count)

        with allure.step('前置条件:去重时间外模拟设备上报同一张人脸图片'):
            gen_devData.simulate_device_upload_pic(
                deviceCode=关联_设备绑定节点["deviceCodeOrBar"],
                img_time=gen_bnsData.TimeHelper.get_custom_time(
                    timestamp_offset=4000),
                score=1.2)

        with allure.step('店客云及技术支持:查看抓拍列表'):
            actual_count = api_technicalSupport.scn_snap_list(
                areaCodesList=[关联_抓拍子节点_进店["areaCode"]],
                expected_value=2,
                res_accurate=True)
            AllureHelper.assert_equal("抓拍列表人数统计", 2, actual_count)
            # TODO:验证回头客属性

        with allure.step('店客云及技术支持:查看访客列表'):
            actual_count = api_technicalSupport.scn_snap_visit_list(
                areaCode=关联_抓拍子节点_进店["areaCode"],
                expected_value=2,
                res_accurate=True)
            AllureHelper.assert_equal("访客列表人数统计", 2, actual_count)
Пример #11
0
    def test_基本的数据处理流程_普客及去重(self, api_technicalSupport, 关联_抓拍子节点_进店,
                             关联_设备绑定节点):

        with allure.step('前置条件:模拟设备上报一张人脸图片'):
            gen_devData.simulate_device_upload_pic(
                关联_设备绑定节点["deviceCodeOrBar"], score=1.2)

        with allure.step('店客云及技术支持:查看抓拍列表'):
            actual_count = api_technicalSupport.scn_snap_list(
                areaCodesList=[关联_抓拍子节点_进店["areaCode"]],
                expected_value=1,
                res_accurate=True)
            AllureHelper.assert_equal("抓拍列表人数统计", 1, actual_count)

        with allure.step('店客云及技术支持:查看访客列表'):
            actual_count = api_technicalSupport.scn_snap_visit_list(
                areaCode=关联_抓拍子节点_进店["areaCode"],
                expected_value=1,
                res_accurate=True)
            AllureHelper.assert_equal("访客列表人数统计", 1, actual_count)

        with allure.step('前置条件:去重时间内模拟设备上报同一张人脸图片'):
            gen_devData.simulate_device_upload_pic(
                关联_设备绑定节点["deviceCodeOrBar"], score=1.2)

        with allure.step('店客云及技术支持:查看抓拍列表'):
            actual_count = api_technicalSupport.scn_snap_list(
                areaCodesList=[关联_抓拍子节点_进店["areaCode"]],
                expected_value=2,
                res_accurate=True)
            AllureHelper.assert_equal("抓拍列表人数统计", 2, actual_count)

        with allure.step('店客云及技术支持:查看访客列表'):
            actual_count = api_technicalSupport.scn_snap_visit_list(
                areaCode=关联_抓拍子节点_进店["areaCode"],
                expected_value=1,
                res_accurate=True)
            AllureHelper.assert_equal("访客列表人数统计", 1, actual_count)
Пример #12
0
def positive_check_order_response(res_info, order_id):
    with allure.step('校验:接口响应信息'):
        with allure.step('校验:接口状态码'):
            actual_code = JsonHelper.parseJson_by_objectpath(
                res_info, "$.code")
            actual_msg = JsonHelper.parseJson_by_objectpath(res_info, "$.msg")
            expect_code = '200'
            expect_msg = "处理成功"
            expect_data = order_id
            actual_data = JsonPath.json_path(res_info, "$.data..forderId")[0]
            AllureHelper.assert_equal("接口业内容", expect_data, actual_data)
            AllureHelper.assert_equal("接口业务码", actual_code, expect_code)
            AllureHelper.assert_equal("接口业消息", actual_msg, expect_msg)

    with allure.step('校验:关联业务'):
        # 每个关联业务写成一个step
        pass

    with allure.step('清理用例'):
        pass
Пример #13
0
def snap_age_identification(response, expect_age_value, expect_deciceCode):
    with allure.step('校验:接口响应信息'):
        with allure.step('校验:查询数据为一条'):
            expect_value = 1
            actual_value = JsonHelper.parseJson_by_objectpath(
                response, "$..*[@.total]")[0]
            AllureHelper.assert_equal("接口查询返回条数", actual_value, expect_value)

        with allure.step('校验:查询结果中为该设备上报的抓拍数据'):
            expected_value = expect_deciceCode
            actual_value = JsonHelper.parseJson_by_objectpath(
                response, "$..*[@.deviceCode]")
            AllureHelper.assert_isContain("抓拍数据", expected_value, actual_value)

        with allure.step('校验:查询结果中年龄识别结果小于等于{}'.format(expect_age_value)):
            expected_value = expect_age_value
            actual_value = JsonHelper.parseJson_by_objectpath(
                response, "$..*[@.ageInit]")[0]
            AllureHelper.assert_except_ge_actual("年龄", expected_value,
                                                 actual_value)
Пример #14
0
def positive_check_stock_response(res_info):
    with allure.step('校验:接口响应信息'):
        with allure.step('校验:接口状态码'):
            actual_code = JsonHelper.parseJson_by_objectpath(
                res_info, "$.code")
            actual_msg = JsonHelper.parseJson_by_objectpath(res_info, "$.msg")
            expect_code = '200'
            expect_msg = "处理成功"
            expect_data = []
            actual_data = JsonHelper.parseJson_by_objectpath(
                res_info, "$.data")
            AllureHelper.assert_notEqual("接口业内容", expect_data, actual_data)
            AllureHelper.assert_equal("接口业务码", actual_code, expect_code)
            AllureHelper.assert_equal("接口业消息", actual_msg, expect_msg)

    with allure.step('校验:关联业务'):
        # 每个关联业务写成一个step
        pass

    with allure.step('清理用例'):
        pass
Пример #15
0
    def test_基本的数据处理流程_会员注册及识别(self, api_technicalSupport, 关联_抓拍子节点_进店,
                               关联_设备绑定节点):

        with allure.step('前置条件:模拟设备上报一张人脸图片'):
            gen_devData.simulate_device_upload_pic(
                关联_设备绑定节点["deviceCodeOrBar"], score=1.2)

        with allure.step('店客云及技术支持:查看访客列表'):
            res = api_technicalSupport.scn_snap_visit_list(
                areaCode=关联_抓拍子节点_进店["areaCode"], expected_value=1)
            visitor_count = JsonHelper.parseJson_by_objectpath(
                res, "count($..*[@.userType is 0])")
            AllureHelper.assert_equal("访客列表普客人数", 1, visitor_count)

        with allure.step('店客云及技术支持:注册人脸为会员'):
            faceId = JsonHelper.parseJson_by_objectpath(res,
                                                        "$..*['faceId']",
                                                        res_firstOne=True)
            imagePath = JsonHelper.parseJson_by_objectpath(
                res, "$..*['featureImageUrl']", res_firstOne=True)
            shopAreaCode = JsonHelper.parseJson_by_objectpath(
                res, "$..*['mallCode']", res_firstOne=True)
            api_technicalSupport.scn_member_add(mallareaCode=shopAreaCode,
                                                imagePath=imagePath,
                                                faceId=faceId)

        with allure.step('店客云及技术支持:查看访客列表'):
            userType = 0
            i = 0
            while userType == 0 and i < 20:
                res = api_technicalSupport.scn_snap_visit_list(
                    areaCode=关联_抓拍子节点_进店["areaCode"], expected_value=1)
                userType = JsonHelper.parseJson_by_objectpath(
                    res, "$..*['userType']", res_firstOne=True)
                i += 1
                time.sleep(1)
            member_count = JsonHelper.parseJson_by_objectpath(
                res, "count($..*[@.userType is 1])", res_allowNone=True)
            AllureHelper.assert_equal("访客列表会员人数", 1, member_count)

        with allure.step('前置条件:去重时间内模拟设备上报同一张人脸图片'):
            gen_devData.simulate_device_upload_pic(
                关联_设备绑定节点["deviceCodeOrBar"], score=1.2)

        with allure.step('店客云及技术支持:查看抓拍列表'):
            i = 0
            while member_count < 2 and i < 20:
                res = api_technicalSupport.scn_snap_list(
                    areaCodesList=[关联_抓拍子节点_进店["areaCode"]], expected_value=1)
                member_count = JsonHelper.parseJson_by_objectpath(
                    res, "count($..*[@.userType is 1])", res_allowNone=True)
                i += 1
                time.sleep(1)
            AllureHelper.assert_equal("抓拍列表会员人数", 2, member_count)

        with allure.step('店客云及技术支持:查看访客列表'):
            res = api_technicalSupport.scn_snap_visit_list(
                areaCode=关联_抓拍子节点_进店["areaCode"], expected_value=1)
            member_count = JsonHelper.parseJson_by_objectpath(
                res, "count($..*[@.userType is 1])", res_allowNone=True)
            AllureHelper.assert_equal("访客列表会员人数", 1, member_count)
Пример #16
0
 def fild_retry(*args, **kwargs):
     res_json = func(*args, **kwargs)
     AllureHelper.attachJson(res_json, "接口信息:{}".format(interface_desc))
     return res_json
Пример #17
0
def positive_check_node(api, res_data):
    with allure.step("节点详情接口校验"):
        res_json1 = api.scn_node_detail(areaCode=res_data["areaCode"])
        res_data1 = JsonHelper.parseJson_by_objectpath(res_json1, "$.data")
        AllureHelper.assert_equal("上级节点编码校验", res_data["parentAreaCode"],
                                  res_data1["parentAreaCode"])
        AllureHelper.assert_equal("节点名称校验", res_data["name"],
                                  res_data1["name"])
        AllureHelper.assert_equal("节点编码校验", res_data["areaCode"],
                                  res_data1["areaCode"])
        AllureHelper.assert_equal("节点类型校验", res_data["areaType"],
                                  res_data1["areaType"])
        AllureHelper.assert_equal("节点等级校验", res_data["nodeLevel"],
                                  res_data1["nodeLevel"])
        AllureHelper.assert_equal("节点id校验", res_data["areaId"],
                                  res_data1["areaId"])
    with allure.step("节点列表接口校验"):
        res_json2 = api.scn_node_list(
            parentAreaCode=res_data["parentAreaCode"], name=res_data["name"])
        res_data2 = JsonHelper.parseJson_by_objectpath(res_json2,
                                                       "$.data.list[0]")
        AllureHelper.assert_equal("上级节点编码校验", res_data["parentAreaCode"],
                                  res_data2["parentAreaCode"])
        AllureHelper.assert_equal("节点编码校验", res_data["areaCode"],
                                  res_data2["areaCode"])
        AllureHelper.assert_equal("节点名称校验", res_data["name"],
                                  res_data2["name"])
        AllureHelper.assert_equal("节点类型校验", res_data["areaType"],
                                  res_data2["areaType"])
        AllureHelper.assert_equal("节点等级校验", res_data["nodeLevel"],
                                  res_data2["nodeLevel"])
        AllureHelper.assert_equal("节点id校验", res_data["areaId"],
                                  res_data2["areaId"])
    with allure.step("节点树接口校验"):
        res_json3 = api.bns_node_tree(
            parentAreaCode=res_data["parentAreaCode"], nodeLevel=5)
        res_data3 = JsonHelper.parseJson_by_objectpath(
            res_json3,
            "$.response_data.data[@.name is %s][0]" % res_data["name"])
        AllureHelper.assert_equal("上级节点编码校验", res_data["parentAreaCode"],
                                  res_data3["parentAreaCode"])
        AllureHelper.assert_equal("节点名称校验", res_data["name"],
                                  res_data3["name"])
        AllureHelper.assert_equal("节点编码校验", res_data["areaCode"],
                                  res_data3["areaCode"])
        AllureHelper.assert_equal("节点类型校验", res_data["areaType"],
                                  res_data3["areaType"])
        AllureHelper.assert_equal("节点等级校验", res_data["nodeLevel"],
                                  res_data3["nodeLevel"])
        AllureHelper.assert_equal("节点id校验", res_data["areaId"],
                                  res_data3["areaId"])
    with allure.step("节点树(有分组)接口校验"):
        res_json4 = api.bns_node_treeGroup(
            parentAreaCode=res_data["parentAreaCode"], nodeLevel=5)
        res_data4 = JsonHelper.parseJson_by_objectpath(
            res_json4,
            "$.response_data.data[@.name is %s][0]" % res_data["name"])
        AllureHelper.assert_equal("上级节点编码校验", res_data["parentAreaCode"],
                                  res_data4["parentAreaCode"])
        AllureHelper.assert_equal("节点名称校验", res_data["name"],
                                  res_data4["name"])
        AllureHelper.assert_equal("节点编码校验", res_data["areaCode"],
                                  res_data4["areaCode"])
        AllureHelper.assert_equal("节点类型校验", res_data["areaType"],
                                  res_data4["areaType"])
        AllureHelper.assert_equal("节点等级校验", res_data["nodeLevel"],
                                  res_data4["nodeLevel"])
        AllureHelper.assert_equal("节点id校验", res_data["areaId"],
                                  res_data4["areaId"])
Пример #18
0
    def test_基本权限操作流程_运营用户多权限(self, 关联_门店节点, 关联_门店节点2):

        with allure.step('超级管理员:创建账号A,关联所有角色权限(技术支持,数据修正,安装人员)'):
            api_admin = Api()
            userName = gen_bnsData.random_operateUser_userName()
            userPhone = gen_bnsData.random_operateUser_userPhone()
            roleId = fixed_bnsData.operateUserId.techSupport.value
            areaCodesList = ["0000"]
            roleId2 = fixed_bnsData.operateUserId.data_correct.value
            areaCodesList2 = [关联_门店节点["areaCode"]]
            roleId3 = fixed_bnsData.operateUserId.installation_person.value
            areaCodesList3 = [关联_门店节点2["areaCode"]]

            res_json = api_admin.bns_operateUser_add(
                userName=userName,
                userPhone=userPhone,
                roleId=roleId,
                areaCodesList=areaCodesList,
                roleId2=roleId2,
                areaCodesList2=areaCodesList2,
                roleId3=roleId3,
                areaCodesList3=areaCodesList3)

            with allure.step("校验: 业务状态码是否正确"):
                actual_code = JsonHelper.parseJson_by_objectpath(
                    res_json, "$.response_data.code")
                AllureHelper.assert_equal("业务状态码", actual_code, 0)

            with allure.step('超级管理员:获取创建账号A对应UserID及账号密码'):
                userInfo = api_admin.bns_operateUser_list(userInfo=userPhone)
                userId_A = JsonHelper.parseJson_by_objectpath(
                    userInfo, "$..*[@.id]", res_firstOne=True)
                password_by_md5 = get_md5Password_from_mysql_in_mall(userPhone)

        with allure.step('登录账号A校验:包含安装人员角色的账号不可登录'):
            res = dkyj.BusinessApi.bns_user_login(userName=userPhone,
                                                  userPasswd=password_by_md5)
            with allure.step("校验: 业务状态码是否正确"):
                actual_code = JsonHelper.parseJson_by_objectpath(
                    res, "$.response_data.code")
                expect_code = 2037
                AllureHelper.assert_equal("业务状态码", actual_code, expect_code)
            with allure.step("校验: 提示信息是否正确"):
                actual_msg = JsonHelper.parseJson_by_objectpath(
                    res, "$.response_data.message")
                expect_msg = "安装人员仅允许在APP登录"
                AllureHelper.assert_equal("提示信息", actual_msg, expect_msg)

        with allure.step('超级管理员:创建账号B,关联所有角色权限(技术支持,数据修正)'):
            userName = gen_bnsData.random_operateUser_userName()
            userPhone = gen_bnsData.random_operateUser_userPhone()
            roleId = fixed_bnsData.operateUserId.techSupport.value
            areaCodesList = ["0000"]
            roleId2 = fixed_bnsData.operateUserId.data_correct.value
            areaCodesList2 = [关联_门店节点["areaCode"]]

            res_json = api_admin.bns_operateUser_add(
                userName=userName,
                userPhone=userPhone,
                roleId=roleId,
                areaCodesList=areaCodesList,
                roleId2=roleId2,
                areaCodesList2=areaCodesList2)

            with allure.step("校验: 业务状态码是否正确"):
                actual_code = JsonHelper.parseJson_by_objectpath(
                    res_json, "$.response_data.code")
                AllureHelper.assert_equal("业务状态码", actual_code, 0)

            with allure.step('超级管理员:获取创建账号B对应UserID及账号密码'):
                userInfo = api_admin.bns_operateUser_list(userInfo=userPhone)
                userId_B = JsonHelper.parseJson_by_objectpath(
                    userInfo, "$..*[@.id]", res_firstOne=True)
                password_by_md5 = get_md5Password_from_mysql_in_mall(userPhone)

        with allure.step('步骤: 登录账号B及修改密码为Dj123456'):
            api_operateUser = Api(username=userPhone, password=password_by_md5)
            api_operateUser.bns_operateUser_modifyPassword(
                oldPasswordMd5=password_by_md5, newPassword="******")
            api_operateUser = Api(username=userPhone, password="******")
            res = api_operateUser.bns_operateUser_getUserRoleList()

            with allure.step('校验: 账号B关联的角色权限ID列表'):
                userRoleId_list = JsonHelper.parseJson_by_objectpath(
                    res, "$..*['roleId']")
                expect_userRoleId_list = [2, 3]
                AllureHelper.assert_equal("角色权限ID列表", sorted(userRoleId_list),
                                          expect_userRoleId_list)

                userId_techSupport = JsonHelper.parseJson_by_objectpath(
                    res, "$..*[@.'roleId' is 2].id", res_firstOne=True)
                userId_data_correct = JsonHelper.parseJson_by_objectpath(
                    res, "$..*[@.'roleId' is 3].id", res_firstOne=True)

        with allure.step('步骤: 选择账号B,切换技术支持角色'):
            res = api_operateUser.bns_operateUser_changeUserRole(
                userId=userId_techSupport)
            with allure.step("校验: 业务状态码是否正确"):
                actual_code = JsonHelper.parseJson_by_objectpath(
                    res, "$.response_data.code")
                AllureHelper.assert_equal("业务状态码", actual_code, 0)
            with allure.step('校验: 技术支持角色权限'):
                # TODO:待完成技术支持权限功能校验
                pass

        with allure.step('步骤: 选择账号B,切换数据修正角色'):
            res = api_operateUser.bns_operateUser_changeUserRole(
                userId=userId_data_correct)
            with allure.step("校验: 业务状态码是否正确"):
                actual_code = JsonHelper.parseJson_by_objectpath(
                    res, "$.response_data.code")
                AllureHelper.assert_equal("业务状态码", actual_code, 0)
            with allure.step('校验: 数据修正角色权限'):
                # TODO:待完成数据修正权限功能校验
                pass

        with allure.step('数据清理: 删除账号A'):
            api_admin_new = Api()
            res = api_admin_new.bns_operateUser_delete(userId=userId_A)
            actual_code = JsonHelper.parseJson_by_objectpath(
                res, "$.response_data.code")
            AllureHelper.assert_equal("业务状态码", actual_code, 0)

        with allure.step('数据清理: 删除账号B'):
            res = api_admin_new.bns_operateUser_delete(userId=userId_B)
            actual_code = JsonHelper.parseJson_by_objectpath(
                res, "$.response_data.code")
            AllureHelper.assert_equal("业务状态码", actual_code, 0)