app/tests/utils.py
def validate_admin_or_participant_view(
    *, two_challenge_set, client: Client, **kwargs
):
    """
    Assert that a view is only accessible to administrators or participants
    of that particular challenge.
    """

    # No user
    assert_viewname_redirect(
        redirect_url=settings.LOGIN_URL,
        challenge=two_challenge_set.challenge_set_1.challenge,
        client=client,
        **kwargs,
    )

    tests = [
        (403, two_challenge_set.challenge_set_1.non_participant),
        (200, two_challenge_set.challenge_set_1.participant),
        (200, two_challenge_set.challenge_set_1.participant1),
        (200, two_challenge_set.challenge_set_1.creator),
        (200, two_challenge_set.challenge_set_1.admin),
        (403, two_challenge_set.challenge_set_2.non_participant),
        (403, two_challenge_set.challenge_set_2.participant),
        (403, two_challenge_set.challenge_set_2.participant1),
        (403, two_challenge_set.challenge_set_2.creator),
        (403, two_challenge_set.challenge_set_2.admin),
        (200, two_challenge_set.admin12),
        (200, two_challenge_set.participant12),
        (200, two_challenge_set.admin1participant2),
    ]

    for test in tests:
        assert_viewname_status(
            code=test[0],
            challenge=two_challenge_set.challenge_set_1.challenge,
            client=client,
            user=test[1],
            **kwargs,
        )

    Assert that a view is only accessible to administrators or participants
    of that particular challenge.
    
Assert that a view is only accessible to administrators or participants
of that particular challenge.
Assert that a view is only accessible to administrators or participants of that particular challenge .
def validate_admin_or_participant_view(
    *, two_challenge_set, client: Client, **kwargs
):
    assert_viewname_redirect(
        redirect_url=settings.LOGIN_URL,
        challenge=two_challenge_set.challenge_set_1.challenge,
        client=client,
        **kwargs,
    )
    tests = [
        (403, two_challenge_set.challenge_set_1.non_participant),
        (200, two_challenge_set.challenge_set_1.participant),
        (200, two_challenge_set.challenge_set_1.participant1),
        (200, two_challenge_set.challenge_set_1.creator),
        (200, two_challenge_set.challenge_set_1.admin),
        (403, two_challenge_set.challenge_set_2.non_participant),
        (403, two_challenge_set.challenge_set_2.participant),
        (403, two_challenge_set.challenge_set_2.participant1),
        (403, two_challenge_set.challenge_set_2.creator),
        (403, two_challenge_set.challenge_set_2.admin),
        (200, two_challenge_set.admin12),
        (200, two_challenge_set.participant12),
        (200, two_challenge_set.admin1participant2),
    ]
    for test in tests:
        assert_viewname_status(
            code=test[0],
            challenge=two_challenge_set.challenge_set_1.challenge,
            client=client,
            user=test[1],
            **kwargs,
        )
def validate_admin_or_participant_view ( * , two_challenge_set , client : Client , ** kwargs ) : assert_viewname_redirect ( redirect_url = settings . LOGIN_URL , challenge = two_challenge_set . challenge_set_1 . challenge , client = client , ** kwargs , ) tests = [ ( 403 , two_challenge_set . challenge_set_1 . non_participant ) , ( 200 , two_challenge_set . challenge_set_1 . participant ) , ( 200 , two_challenge_set . challenge_set_1 . participant1 ) , ( 200 , two_challenge_set . challenge_set_1 . creator ) , ( 200 , two_challenge_set . challenge_set_1 . admin ) , ( 403 , two_challenge_set . challenge_set_2 . non_participant ) , ( 403 , two_challenge_set . challenge_set_2 . participant ) , ( 403 , two_challenge_set . challenge_set_2 . participant1 ) , ( 403 , two_challenge_set . challenge_set_2 . creator ) , ( 403 , two_challenge_set . challenge_set_2 . admin ) , ( 200 , two_challenge_set . admin12 ) , ( 200 , two_challenge_set . participant12 ) , ( 200 , two_challenge_set . admin1participant2 ) , ] for test in tests : assert_viewname_status ( code = test [ 0 ] , challenge = two_challenge_set . challenge_set_1 . challenge , client = client , user = test [ 1 ] , ** kwargs , )
Assert that a view is only accessible to administrators or participants
of that particular challenge.
Assert that a view is only accessible to administrators or participants of that particular challenge .
"""
    Assert that a view is only accessible to administrators or participants
    of that particular challenge.
    """ # No user
two_challenge_set
client
Client