def test_create_next_dep_from_Default(self, dep_name, sole_group_name): # 测试从Default根分组创建下一级分组 UserPage(dep_name[0]).create_department_from_Default(sole_group_name, is_peer=False) result = UserPage(dep_name[0]).judge_alert_info() assert "创建下一级分组成功" == result
def setup_user_name_and_delete_user(sb): """ 生成用户名并清理该用户 """ request = {'name': generate_uuid()} MenuBar.click_menu_item_by_text(sb, '配置', '用户管理') yield request sb.save_teardown_screenshot() UserPage.delete_user_by_name(sb, request['name'])
def setup_user_reset_password(sb): request = {'name': generate_uuid()} MenuBar.click_menu_item_by_text(sb, '配置', '用户管理') default_password = UserPage.reset_user_password(sb, request['name']) yield str(default_password).strip() sb.save_teardown_screenshot() UserPage.delete_user_by_name(sb, request['name'])
def setup_subdepartment(sb): """ 添加子部门 """ request = {'name': generate_uuid()} MenuBar.click_menu_item_by_text(sb, '配置', '用户管理') UserPage.add_department_by_parent_department_name(sb, request['name']) yield request sb.save_teardown_screenshot()
def setup_subdepartment_name_and_delete_subdepartment(sb): """ 生成子部门名称并清理该子部门 """ request = {'name': generate_uuid()} MenuBar.click_menu_item_by_text(sb, '配置', '用户管理') yield request sb.save_teardown_screenshot() UserPage.delete_department_by_name(sb, request['name'])
def test_create_peer_dep_from_user_defined(self, dep_name, sole_group_name): # 测试从用户自定义分组创建同级分组 UserPage(dep_name[0]).create_department_from_user_defined( group_name=sole_group_name, parent_name=dep_name[1]) result = UserPage(dep_name[0]).judge_alert_info() assert "创建同级分组成功" == result
def setup_user(sb): """ 添加用户 """ request = {'name': generate_uuid()} MenuBar.click_menu_item_by_text(sb, '配置', '用户管理') user = User(request['name'], request['name']) UserPage.add_user_by_department_name(sb, user) yield request sb.save_teardown_screenshot()
def del_sub_dep_name_to_user(dep_name, sole_group_name): yield # 删除用户自定义分组的下一级分组 UserPage(dep_name[0]).delete_department_by_name(sub_name=sole_group_name, parent_name=dep_name[1], is_peer=False) time.sleep(2)
def test_login_with_reset_locked_account(sb, login, setup_user): #5次登录错误,账户被锁定 MenuBar.click_personal_info_menu_item(sb, '退出系统') for i in range(5): LoginPage.login(sb, setup_user['name'], '123456') sb.sleep(1) #管理员登录,重置密码 LoginPage.login(sb, sb_config.username, sb_config.password) sb.sleep(2) MenuBar.click_menu_item_by_text(sb, '配置', '用户管理') default_password = UserPage.reset_user_password(sb, setup_user['name']) MenuBar.click_personal_info_menu_item(sb, '退出系统') sb.sleep(2) # 重新登录,并修改密码 LoginPage.login(sb, setup_user['name'], str(default_password).strip()) PersonInfoPage.reset_password(sb, str(default_password).strip(), 'Guard123', 'Guard123') sb.sleep(5) # 重新登陆系统,验证密码修改成功 LoginPage.login(sb, setup_user['name'], 'Guard123') sb.assert_element_visible('.avatar-name')
def test_add_department(sb, login, setup_department_name_and_delete_department): UserPage.add_department_by_root_department_name( sb, setup_department_name_and_delete_department['name']) UserPage.assert_alert_message(sb, '创建同级分组成功')
def del_dep_name_to_user(dep_name, sole_group_name): yield # 删除用户自定义分组 UserPage( dep_name[0]).delete_department_by_name(parent_name=sole_group_name) time.sleep(2)
def test_delete_subdepartment(sb, login, setup_department_and_delete_department, setup_subdepartment): UserPage.delete_department_by_name(sb, setup_subdepartment['name']) UserPage.assert_alert_message(sb, '删除分组成功')
def close_alert(user_web): # 删除alert弹框 yield UserPage(user_web).close_alert()
def del_sub_dep_name_to_default(dep_name, sole_group_name): yield # 删除Default分组的下一级分组 UserPage(dep_name[0]).delete_department_by_name(sub_name=sole_group_name, is_peer=False) time.sleep(2)
def test_add_user(sb, login, setup_user_name_and_delete_user): user = User( setup_user_name_and_delete_user['name'], setup_user_name_and_delete_user['name']) UserPage.add_user_by_department_name(sb, user) UserPage.assert_alert_message(sb, '添加用户成功')
def test_delete_existing_user(sb, login, setup_user): MenuBar.click_menu_item_by_text(sb, '配置', '用户管理') UserPage.delete_user_by_name(sb, setup_user['name']) UserPage.assert_alert_message(sb, '删除用户成功')
def test_create_peer_dep_from_Default(self, dep_name): # 测试从Default根分组创建同级分组 UserPage(dep_name[0]).create_department_from_Default(dep_name[1]) result = UserPage(dep_name[0]).judge_alert_info() assert "创建同级分组成功" == result
def test_delete_peer_dep_from_Default(self, dep_name): UserPage( dep_name[0]).delete_department_by_name(parent_name=dep_name[1]) result = UserPage(dep_name[0]).judge_alert_info() assert "删除分组成功" == result
def test_add_sub_department(sb, login, setup_department_and_delete_department, setup_subdepartment_name_and_delete_subdepartment): UserPage.add_department_by_parent_department_name( sb, setup_subdepartment_name_and_delete_subdepartment['name'], setup_department_and_delete_department['name'], is_peer=False)