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)
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"])
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",
    }

    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
Exemple #4
0
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
def test_unauthenticated_user_cannot_access(api_client):
    get(api_client, PROFILE_URL, 401)