Beispiel #1
0
def test_edit_valid_portrait(
        sb, login,
        setup_portrait_with_portrait_database_and_delete_portrait_database,
        image_path):
    old_img_src = PortraitPage.get_portrait_img_src_by_name(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'])
    portrait = Portrait(
        name=setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'],
        id_number=
        setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'],
        image_path=os.getcwd() + image_path,
        portrait_databases=[
            setup_portrait_with_portrait_database_and_delete_portrait_database[
                'portrait_database']
        ])
    PortraitPage.edit_portrait_by_name(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'], portrait)
    new_img_src = PortraitPage.get_portrait_img_src_by_name(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'])
    assert new_img_src != old_img_src
def setup_portrait_database_name_and_delete_portrait_database(sb):
    """ 生成人像库名称并清理该人像库 """
    request = {'name': generate_uuid()}
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    yield request
    sb.save_teardown_screenshot()
    PortraitPage.delete_portrait_database_by_name(sb, request['name'])
def setup_face_alert_deployment_task_name_and_delete_task(sb):
    """ 生成监控任务名称并清理该任务 """
    request = {'name': generate_uuid()}
    MenuBar.click_menu_item_by_text(sb, '配置', '地图管理')
    MapPage.add_floor_by_root_floor_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '设备管理')
    DevicePage.add_group_by_root_group_name(sb, request['name'])
    rtsp_device = RTSP(request['name'], request['name'], request['name'],
                       request['name'],
                       'rtsp://confidence.119:6554/SchoolAnniversary.264')
    DevicePage.add_device_by_type(sb, rtsp_device, '网络摄像机')
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.add_portrait_database_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '任务管理')
    yield request
    sb.save_teardown_screenshot()
    MenuBar.click_menu_item_by_text(sb, '配置', '任务管理')
    TaskPage.click_task_tab_by_type(sb, type='人脸-布控任务')
    TaskPage.delete_task_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.delete_portrait_database_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '设备管理')
    DevicePage.delete_group_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '地图管理')
    MapPage.delete_floor_by_name(sb, request['name'])
Beispiel #4
0
def test_delete_existing_portrait_in_two_portrait_databases_from_current_portrait_database(
        sb, login,
        setup_portrait_with_two_portrait_databases_and_delete_portrait_databases
):
    PortraitPage.search_portrait_by_keyword(
        sb,
        setup_portrait_with_two_portrait_databases_and_delete_portrait_databases[
            'name'])
    PortraitPage.click_portrait_database_by_name(
        sb,
        setup_portrait_with_two_portrait_databases_and_delete_portrait_databases[
            'portrait_databases'][0])
    PortraitPage.delete_portrait_by_name(
        sb,
        setup_portrait_with_two_portrait_databases_and_delete_portrait_databases[
            'name'],
        from_current_group=True)
    PortraitPage.assert_alert_message(sb, '删除人像成功')
    PortraitPage.search_portrait_by_keyword(
        sb,
        setup_portrait_with_two_portrait_databases_and_delete_portrait_databases[
            'name'])
    sb.is_element_visible(
        f'//div[@title="{setup_portrait_with_two_portrait_databases_and_delete_portrait_databases["portrait_databases"][1]}" and text()="{setup_portrait_with_two_portrait_databases_and_delete_portrait_databases["portrait_databases"][1]} (1)"]'
    )
Beispiel #5
0
def test_search_existing_portrait_database(
        sb, login, setup_portrait_database_and_delete_portrait_database):
    PortraitPage.search_portrait_database_by_name(
        sb, setup_portrait_database_and_delete_portrait_database['name'])
    sb.is_element_visible(
        f'//div[@title="{setup_portrait_database_and_delete_portrait_database["name"]}"]'
    )
def setup_portrait_database(sb, portrait_type):
    """ 添加人像库 """
    request = {'name': generate_uuid()}
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.add_portrait_database_by_name(sb,
                                               request['name'],
                                               type=portrait_type)
    yield request
    sb.save_teardown_screenshot()
Beispiel #7
0
def test_edit_invalid_portrait_image(
        sb, login,
        setup_portrait_with_portrait_database_and_delete_portrait_database,
        image_path, alert_message):
    TableList.click_edit_button_by_name(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'])
    PortraitPage.upload_portrait_image(sb, '编辑', os.getcwd() + image_path)
    Dialog.click_dialog_footer_button_by_text(sb, '编辑', '取消')
Beispiel #8
0
def test_search_existing_portrait(
        sb, login,
        setup_portrait_with_portrait_database_and_delete_portrait_database):
    PortraitPage.search_portrait_by_keyword(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'])
    sb.is_element_visible(
        f'//table//div[@class="cell" and contains(text(), "{setup_portrait_with_portrait_database_and_delete_portrait_database["name"]}")]'
    )
Beispiel #9
0
 def test_portrait(self):
     # 访问人像库管理页面
     MenuBar.click_menu_item_by_text(self, '配置', '人像库管理')
     # 添加白名单库
     PortraitPage.add_portrait_database_by_name(
         self, SmokeTest.SMOKE_PORTRAIT_DATABASE_WHITELIST_NAME, type='白名单')
     # PortraitPage.assert_alert_message(self, '创建下一级分组成功')
     # 添加重点人员库
     PortraitPage.add_portrait_database_by_name(
         self,
         SmokeTest.SMOKE_PORTRAIT_DATABASE_KEY_PERSONNEL_NAME,
         type='重点人员')
def setup_face_access_control_task_name_with_mul_portrait_and_delete_task(sb):
    """ 生成人脸通行任务名称并清理该任务 """
    request = {'name': generate_uuid(), 'name2': generate_uuid()}
    MenuBar.click_menu_item_by_text(sb, '配置', '地图管理')
    MapPage.add_floor_by_root_floor_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '设备管理')
    DevicePage.add_group_by_root_group_name(sb, request['name'])
    frontend_device = Frontend(request['name'], request['name'],
                               request['name'], request['name'], 'SensePass')
    DevicePage.add_device_by_type(sb, frontend_device, '人脸识别机(前)')
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.add_portrait_database_by_name(sb, request['name'])
    PortraitPage.add_portrait_database_by_name(sb, request['name2'])
    MenuBar.click_menu_item_by_text(sb, '配置', '任务管理')
    yield request
    sb.save_teardown_screenshot()
    MenuBar.click_menu_item_by_text(sb, '配置', '任务管理')
    TaskPage.click_task_tab_by_type(sb, type='人脸-通行任务')
    TaskPage.delete_task_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.delete_portrait_database_by_name(sb, request['name'])
    PortraitPage.delete_portrait_database_by_name(sb, request['name2'])
    MenuBar.click_menu_item_by_text(sb, '配置', '设备管理')
    DevicePage.delete_group_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '地图管理')
    MapPage.delete_floor_by_name(sb, request['name'])
Beispiel #11
0
def test_required_fields_when_adding_portrait(sb, login, setup_portrait_name):
    PortraitPage.click_add_portrait_button(sb)
    Dialog.click_dialog_footer_button_by_text(sb, '添加人像', '确定')
    sb.is_element_visible(
        '//div[@class="el-form-item__error" and contains(text(), "请上传本地人像照片")]'
    )
    sb.is_element_visible(
        '//div[@class="el-form-item__error" and contains(text(), "请输入姓名")]')
    sb.is_element_visible(
        '//div[@class="el-form-item__error" and contains(text(), "请输入No.")]')
    sb.is_element_visible(
        '//div[@class="el-form-item__error" and contains(text(), "请选择人像库")]')
    sb.is_element_visible(
        '//div[@class="el-form-item__error" and contains(text(), "请选择时间")]')
def setup_portrait_with_portrait_database_and_delete_portrait_database(
        sb, setup_portrait_database_and_delete_portrait_database):
    """ 添加人像到人像库并删除人像库 """
    request = {
        'name':
        generate_uuid(),
        'portrait_database':
        setup_portrait_database_and_delete_portrait_database['name']
    }
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    portrait = Portrait(name=request['name'],
                        id_number=request['name'],
                        image_path=os.getcwd() +
                        '/guard/data/portrait/001-JPG.jpg',
                        portrait_databases=[request['portrait_database']])
    PortraitPage.add_portrait(sb, portrait)
    yield request
    sb.save_teardown_screenshot()
Beispiel #13
0
def test_view_portrait_database(
        sb, login, portrait_type,
        setup_portrait_database_and_delete_portrait_database):
    PortraitPage.view_portrait_database_by_name(
        sb,
        setup_portrait_database_and_delete_portrait_database['name'],
        confirm=False)
    sb.is_element_visible('//div[@class="left"]/span[text()="分组类型"]')
    sb.is_element_visible('//div[@class="left"]/span[text()="分组名称"]')
    sb.is_element_visible('//div[@class="left"]/span[text()="创建时间"]')
    sb.is_element_visible('//div[@class="left"]/span[text()="创建者"]')
    sb.is_element_visible(
        f'//div[@class="right"]/span[text()="{portrait_type}"]')
    sb.is_element_visible(
        f'//div[@class="right"]/span[text()="{setup_portrait_database_and_delete_portrait_database["name"]}"]'
    )
    sb.is_element_visible(
        f'//div[@class="right"]/span[text()="{sb_config.username}"]')
Beispiel #14
0
def test_delete_existing_portrait_in_one_portrait_database_from_global_portrait_database(
        sb, login,
        setup_portrait_with_portrait_database_and_delete_portrait_database):
    PortraitPage.search_portrait_by_keyword(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'])
    PortraitPage.delete_portrait_by_name(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'])
    PortraitPage.assert_alert_message(sb, '删除人像成功')
    PortraitPage.search_portrait_by_keyword(
        sb, setup_portrait_with_portrait_database_and_delete_portrait_database[
            'name'])
    sb.is_element_visible('//span[text()="暂无数据"]')
Beispiel #15
0
def test_rename_existing_portrait_database(sb, login, setup_portrait_database):
    new_name = f'{setup_portrait_database["name"]}N'
    PortraitPage.rename_portrait_database_by_name(
        sb, setup_portrait_database['name'], new_name)
    PortraitPage.search_portrait_database_by_name(
        sb, setup_portrait_database['name'])
    sb.is_element_visible(f'//div[@title="{new_name}"]')
    PortraitPage.delete_portrait_database_by_name(sb, new_name)
def setup_vehicle_illegally_parking_detection_task_name_and_delete_task(sb):
    """ 生成车辆违停检测任务名称并清理该任务 """
    request = {'name': generate_uuid()}
    MenuBar.click_menu_item_by_text(sb, '配置', '地图管理')
    MapPage.add_floor_by_root_floor_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '设备管理')
    DevicePage.add_group_by_root_group_name(sb, request['name'])
    rtsp_device = RTSP(request['name'], request['name'], request['name'],
                       request['name'], 'rtsp://confidence.119:6554/test.264')
    DevicePage.add_device_by_type(sb, rtsp_device, '网络摄像机')
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.add_portrait_database_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '任务管理')
    yield request
    sb.save_teardown_screenshot()
    MenuBar.click_menu_item_by_text(sb, '配置', '任务管理')
    TaskPage.click_task_tab_by_type(sb, type='车辆-违停检测任务')
    TaskPage.delete_task_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.delete_portrait_database_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '设备管理')
    DevicePage.delete_group_by_name(sb, request['name'])
    MenuBar.click_menu_item_by_text(sb, '配置', '地图管理')
    MapPage.delete_floor_by_name(sb, request['name'])
Beispiel #17
0
def test_add_portrait_database(
        sb, login, portrait_type,
        setup_portrait_database_name_and_delete_portrait_database):
    PortraitPage.add_portrait_database_by_name(
        sb,
        setup_portrait_database_name_and_delete_portrait_database['name'],
        type=portrait_type)
    PortraitPage.assert_alert_message(sb, '创建下一级分组成功')
    PortraitPage.search_portrait_database_by_name(
        sb, setup_portrait_database_name_and_delete_portrait_database['name'])
    sb.is_element_visible(
        f'//div[@title="{setup_portrait_database_name_and_delete_portrait_database["name"]}"]'
    )
Beispiel #18
0
def test_add_valid_portrait(
        sb, login, setup_portrait_database_and_delete_portrait_database,
        setup_portrait_name, image_path):
    portrait = Portrait(
        name=setup_portrait_name['name'],
        id_number=setup_portrait_name['name'],
        image_path=os.getcwd() + image_path,
        portrait_databases=[
            setup_portrait_database_and_delete_portrait_database['name']
        ])
    PortraitPage.add_portrait(sb, portrait)
    PortraitPage.assert_alert_message(sb, '添加人像成功')
    PortraitPage.search_portrait_by_keyword(sb, setup_portrait_name['name'])
    sb.is_element_visible(
        f'//table//div[@class="cell" and contains(text(), "{setup_portrait_name["name"]}")]'
    )
def setup_portrait_with_two_portrait_databases_and_delete_portrait_databases(
        sb, setup_portrait_database_name):
    """ 添加人像到人像库并删除人像库 """
    request = {
        'name':
        generate_uuid(),
        'portrait_databases': [
            f'{setup_portrait_database_name["name"]}1',
            f'{setup_portrait_database_name["name"]}2'
        ]
    }
    for portrait_database in request['portrait_databases']:
        PortraitPage.add_portrait_database_by_name(sb, portrait_database)
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    portrait = Portrait(name=request['name'],
                        id_number=request['name'],
                        image_path=os.getcwd() +
                        '/guard/data/portrait/001-JPG.jpg',
                        portrait_databases=request['portrait_databases'])
    PortraitPage.add_portrait(sb, portrait)
    yield request
    sb.save_teardown_screenshot()
    for portrait_database in request['portrait_databases']:
        PortraitPage.delete_portrait_database_by_name(sb, portrait_database)
Beispiel #20
0
def test_fields_length_when_adding_portrait(sb, login, setup_portrait_name):
    PortraitPage.click_add_portrait_button(sb)
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="姓名"]/parent::*//input',
        'maxlength', '40')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="别名"]/parent::*//input',
        'maxlength', '40')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="No."]/parent::*//input',
        'maxlength', '32')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="年龄"]/parent::*//input',
        'maxlength', '3')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="公司"]/parent::*//input',
        'maxlength', '40')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="部门"]/parent::*//input',
        'maxlength', '40')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="联系方式"]/parent::*//input',
        'maxlength', '40')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="车牌号"]/parent::*//input',
        'maxlength', '40')
    PortraitPage.assert_element_attribute_value(
        sb, '//div[@aria-label="添加人像"]//label[text()="住址"]/parent::*//input',
        'maxlength', '30')
Beispiel #21
0
def test_search_not_existing_portrait(sb, login, setup_portrait_name):
    PortraitPage.search_portrait_by_keyword(sb, setup_portrait_name['name'])
    sb.is_element_visible('//span[text()="暂无数据"]')
Beispiel #22
0
def test_add_portrait_database_with_invalid_name(sb, login, name):
    MenuBar.click_menu_item_by_text(sb, '配置', '人像库管理')
    PortraitPage.add_portrait_database_by_name(sb, name)
    PortraitPage.assert_element_text(sb, '.tips > span', '请输入分组名称')
Beispiel #23
0
def test_add_invalid_portrait_image(sb, login, setup_portrait_name, image_path,
                                    alert_message):
    PortraitPage.click_add_portrait_button(sb)
    PortraitPage.upload_portrait_image(sb, '添加人像', os.getcwd() + image_path)
    PortraitPage.assert_alert_message(sb, alert_message)
Beispiel #24
0
def test_rename_existing_portrait_database_with_invalid_name(
        sb, login, name, setup_portrait_database_and_delete_portrait_database):
    PortraitPage.rename_portrait_database_by_name(
        sb, setup_portrait_database_and_delete_portrait_database['name'], name)
    PortraitPage.assert_element_text(sb, '.tips > span', '请输入分组名称')
    Dialog.click_dialog_footer_button_by_text(sb, '编辑', '取消')
Beispiel #25
0
def test_delete_existing_portrait_database(sb, login, setup_portrait_database):
    PortraitPage.delete_portrait_database_by_name(
        sb, setup_portrait_database['name'])
    PortraitPage.assert_alert_message(sb, '删除分组成功')
    sb.is_element_visible('//span[text()="暂无数据"]')