Skip to content

Commit

Permalink
feat: add privacy policy and terms of use urls to gql api
Browse files Browse the repository at this point in the history
Refs HP-2332
  • Loading branch information
nicobav committed Apr 3, 2024
1 parent ef96a78 commit db9c567
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from snapshottest import Snapshot


snapshots = Snapshot()

snapshots['test_graphql_schema_matches_the_reference 1'] = '''type Query {
Expand Down Expand Up @@ -50,6 +51,8 @@
isPureKeycloak: Boolean!
title(language: TranslationLanguage): String
description(language: TranslationLanguage): String
privacyPolicyUrl(language: TranslationLanguage): String
termsOfUseUrl(language: TranslationLanguage): String
}
interface Node {
Expand Down
2 changes: 2 additions & 0 deletions services/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class Meta:
"gdpr_url",
"gdpr_query_scope",
"gdpr_delete_scope",
"privacy_policy_url",
"terms_of_use_url",
)
filter_fields = []
interfaces = (relay.Node,)
Expand Down
46 changes: 46 additions & 0 deletions services/tests/test_gql_services_query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
from guardian.shortcuts import assign_perm

from open_city_profile import settings
from open_city_profile.tests.asserts import assert_match_error_code
from services.models import Service

Expand Down Expand Up @@ -97,3 +99,47 @@ def test_requires_view_service_permission(user_gql_client):

assert executed["data"] == {"services": None}
assert_match_error_code(executed, "PERMISSION_DENIED_ERROR")


@pytest.mark.parametrize("language", dict(settings.LANGUAGES).keys())
def test_query_service_terms_of_use_url(user_gql_client, language):
terms_of_use_url = f"https://example.com/terms-of-use/{language}/"
service = ServiceFactory()
service.set_current_language(language)
service.terms_of_use_url = terms_of_use_url
service.save()
service.set_current_language("fr")

assign_perm("services.view_service", user_gql_client.user)
query = (
"""
query {
services {
edges {
node {
name
termsOfUseUrl(language: %s)
}
}
}
}
"""
% language.upper()
)

executed = user_gql_client.execute(query, service=None)

assert executed["data"] == {
"services": {
"edges": [
{
"node": {
"name": service.name,
"termsOfUseUrl": terms_of_use_url,
}
}
]
}
}

assert "errors" not in executed

0 comments on commit db9c567

Please sign in to comment.