Пример #1
0
def test_SupervisorRolePermission_authenticated_user(authenticated_user_instance):
    obj = Mock()
    obj.check_supervisor = lambda user: user == authenticated_user_instance
    with permissions.SupervisorRolePermission(obj=obj):
        pass
    del obj.check_supervisor
    with pytest.raises(HTTPException):
        with permissions.SupervisorRolePermission():
            pass
def test_SupervisorRolePermission_authenticated_user_with_password_with_check_supervisor(
        authenticated_user_instance):
    authenticated_user_instance.password = "******"
    obj = Mock()
    obj.check_supervisor = lambda user: user == authenticated_user_instance
    with permissions.SupervisorRolePermission(obj=obj,
                                              password_required=True,
                                              password="******"):
        pass
    with pytest.raises(HTTPException):
        with permissions.SupervisorRolePermission(obj=obj,
                                                  password_required=True,
                                                  password="******"):
            pass
Пример #3
0
def test_SupervisorRolePermission_authenticated_user_with_password_without_check_supervisor(
    authenticated_user_instance,
):
    authenticated_user_instance.password = '******'
    obj = Mock()
    del obj.check_supervisor
    with pytest.raises(HTTPException):
        with permissions.SupervisorRolePermission(
            obj=obj, password_required=True, password='******'
        ):
            pass
    with pytest.raises(HTTPException):
        with permissions.SupervisorRolePermission(
            obj=obj, password_required=True, password='******'
        ):
            pass
Пример #4
0
def test_SupervisorRolePermission_anonymous_user_with_password(anonymous_user_instance):
    # pylint: disable=unused-argument
    obj = Mock()
    obj.check_supervisor = lambda user: False
    with pytest.raises(HTTPException):
        with permissions.SupervisorRolePermission(
            obj=obj, password_required=True, password='******'
        ):
            pass
Пример #5
0
def test_SupervisorRolePermission_anonymous_user(anonymous_user_instance):
    # pylint: disable=unused-argument
    with pytest.raises(HTTPException):
        with permissions.SupervisorRolePermission():
            pass