Ejemplo n.º 1
0
def test_user_can_see_only_own_profile(user_api_client, profile):
    other_user_profile = ProfileFactory()

    data = get(user_api_client, PROFILE_URL)
    results = data["results"]
    assert len(results) == 1
    assert Profile.objects.count() > 1

    get(user_api_client, get_user_profile_url(other_user_profile), status_code=404)
Ejemplo n.º 2
0
def test_superuser_can_view_all_profiles(superuser_api_client):
    a_user_profile = ProfileFactory()
    other_user_profile = ProfileFactory()  # noqa

    data = get(superuser_api_client, PROFILE_URL)
    results = data["results"]
    assert len(results) == 2

    get(superuser_api_client, get_user_profile_url(a_user_profile), status_code=200)
def test_superuser_can_view_all_youth_profiles(superuser_api_client):
    a_youth_profile = YouthProfileFactory()
    other_youth_profile = YouthProfileFactory()  # noqa

    data = get(superuser_api_client, YOUTH_PROFILE_URL)
    results = data["results"]
    assert len(results) == YouthProfile.objects.count()

    get(superuser_api_client,
        get_youth_profile_url(a_youth_profile),
        status_code=200)
Ejemplo n.º 4
0
def test_concept_of_interest_to_representation(user_api_client, profile, concept):
    profile.concepts_of_interest.add(concept)
    user_profile_url = get_user_profile_url(profile)
    profile_endpoint_data = get(user_api_client, user_profile_url)

    serialized_concept_of_interest = "{}:{}".format(
        concept.vocabulary.prefix, concept.code
    )

    assert (
        serialized_concept_of_interest in profile_endpoint_data["concepts_of_interest"]
    )
Ejemplo n.º 5
0
def test_expected_profile_data_fields(user_api_client, profile):
    expected_fields = {
        "nickname",
        "image",
        "email",
        "phone",
        "language",
        "contact_method",
        "concepts_of_interest",
        "divisions_of_interest",
        "preferences",
        "legal_relationships",
    }

    user_profile_url = get_user_profile_url(profile)
    profile_endpoint_data = get(user_api_client, user_profile_url)

    assert set(profile_endpoint_data.keys()) == expected_fields
def test_expected_profile_data_fields(user_api_client, youth_profile):
    expected_fields = {
        "profile",
        "ssn",
        "school_name",
        "school_class",
        "expiration",
        "preferred_language",
        "volunteer_info",
        "gender",
        "illnesses",
        "allergies",
        "notes",
    }

    youth_profile_url = get_youth_profile_url(youth_profile)
    youth_profile_endpoint_data = get(user_api_client, youth_profile_url)

    assert set(youth_profile_endpoint_data.keys()) == expected_fields
def test_translations_formatting(api_client, concept):
    fi_label = "konsepti"
    en_label = "concept"

    concept.set_current_language("fi")
    concept.label = fi_label
    concept.save()

    concept.set_current_language("en")
    concept.label = en_label
    concept.save()

    concept_api_result = get(api_client, get_interest_concept_url(concept.pk))
    expected_result = {
        "code": concept.code,
        "vocabulary": concept.vocabulary.prefix,
        "label": {
            "en": en_label,
            "fi": fi_label
        },
    }

    assert concept_api_result == expected_result
Ejemplo n.º 8
0
def test_unauthenticated_user_cannot_access(api_client):
    get(api_client, PROFILE_URL, 401)