Skip to content

Commit

Permalink
feat: add fallback for missing access info
Browse files Browse the repository at this point in the history
  • Loading branch information
MatMoore committed Aug 12, 2024
1 parent 0078765 commit 3ab39d2
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 18 deletions.
22 changes: 13 additions & 9 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Find MoJ data\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-08 16:54+0100\n"
"POT-Creation-Date: 2024-08-12 13:45+0100\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -193,7 +193,8 @@ msgstr "Last updated:"
msgid "Domain:"
msgstr "Domain:"

#: templates/details_base.html:73 templates/partial/search_result.html:41
#: templates/details_base.html:73 templates/partial/contact_info.html:36
#: templates/partial/search_result.html:41
msgid "Not provided"
msgstr "Not provided."

Expand Down Expand Up @@ -366,22 +367,25 @@ msgid "Access requirements"
msgstr "Request access"

# Request access link
#: templates/partial/contact_info.html:8
#: templates/partial/contact_info.html:7
msgid "Click link for access information (opens in new tab)"
msgstr "Click link for access information (opens in new tab)"

# Default text for contact info
#: templates/partial/contact_info.html:13
msgid "Processing the data might require permission from IAO or Data owner."
msgstr "Processing the data might require permission from the Data owner."
#: templates/partial/contact_info.html:12
msgid "Please use contact channels to request access."
msgstr "Please use contact channels to request access."

#: templates/partial/contact_info.html:14
msgid "Please contact the data owner for access information."
msgstr "Please contact the data owner for access information."

# Heading
#: templates/partial/contact_info.html:20
#: templates/partial/contact_info.html:22
msgid "Contact channels for questions"
msgstr "Contact channels for questions"

# Heading
#: templates/partial/contact_info.html:32
#: templates/partial/contact_info.html:34
msgid "IAO or Data Owner"
msgstr "Data owner"

Expand Down
6 changes: 5 additions & 1 deletion templates/partial/contact_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ <h2 class="govuk-heading-s govuk-!-margin-bottom-1">{% translate "Access require
{% else %}
<p id="request-access">{{ access_requirements }} </p>
{% endif %}
{% elif slack_channel.dc_slack_channel_url %}
<p id="request-access">{% translate "Please use contact channels to request access." %}</p>
{% elif data_owner_email %}
<p id="request-access">{% translate "Please contact the data owner for access information." %}</p>
{% else %}
<p id="request-access"> {% translate "Processing the data might require permission from IAO or Data owner." %} </p>
<p id="request-access"> {% translate "Not provided" %} </p>
{% endif %}
</div>
<!-- placeholder until we have more contact channels than just slack -->
Expand Down
92 changes: 84 additions & 8 deletions tests/integration/test_details_contact_contents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import pytest
from data_platform_catalogue.entities import AccessInformation, CustomEntityProperties
from data_platform_catalogue.entities import (
AccessInformation,
CustomEntityProperties,
FurtherInformation,
OwnerRef,
)

from tests.conftest import (
generate_database_metadata,
Expand Down Expand Up @@ -41,15 +46,14 @@ def setup(
"To access these data you need to seek permission from the data owner by email",
"p",
),
(
"",
"Processing the data might require permission from the Data owner.",
"p",
),
],
)
def test_access_requirements_content(
self, mock_catalogue, access_reqs, expected_text, expected_tag
self,
mock_catalogue,
access_reqs,
expected_text,
expected_tag,
):
"""
test that what is displayed in the request action section of contacts is what we expect
Expand All @@ -61,9 +65,12 @@ def test_access_requirements_content(
"""
test_database = generate_database_metadata(
custom_properties=CustomEntityProperties(
access_information=AccessInformation(dc_access_requirements=access_reqs)
access_information=AccessInformation(
dc_access_requirements=access_reqs
),
)
)

mock_get_database_details_response(mock_catalogue, test_database)

self.start_on_the_details_page()
Expand All @@ -73,6 +80,75 @@ def test_access_requirements_content(
assert request_access_metadata.text == expected_text
assert request_access_metadata.tag_name == expected_tag

@pytest.mark.parametrize(
"access_reqs, slack_channel, owner, expected_text",
[
(
"Some contact info",
"#contact us",
"[email protected]",
"Some contact info",
),
(
"",
"#contact_us",
"[email protected]",
"Please use contact channels to request access.",
),
(
"",
"",
"[email protected]",
"Please contact the data owner for access information.",
),
(
"",
"",
"",
"Not provided.",
),
],
)
def test_access_requirements_fallbacks(
self, mock_catalogue, access_reqs, slack_channel, owner, expected_text
):
"""
If no access requirements are given, users should use the contact info,
if provided. If not, then they should contact the data owner.
If none of the information is provided, then the catalogue entry is
non-functional - we should prevent this happening at ingestion time
or before.
"""
test_database = generate_database_metadata(
custom_properties=CustomEntityProperties(
access_information=AccessInformation(
dc_access_requirements=access_reqs
),
)
)

if owner:
test_database.governance.data_owner = OwnerRef(
display_name=owner, email=owner, urn="urn:bla"
)
else:
test_database.governance.data_owner.display_name = ""
test_database.governance.data_owner.email = ""

if slack_channel:
test_database.custom_properties.further_information = FurtherInformation(
dc_slack_channel_name=slack_channel,
dc_slack_channel_url="http://bla.com",
)

mock_get_database_details_response(mock_catalogue, test_database)

self.start_on_the_details_page()

request_access_metadata = self.details_database_page.request_access()

assert request_access_metadata.text == expected_text

def start_on_the_details_page(self):
self.selenium.get(
f"{self.live_server_url}/details/database/urn:li:container:test"
Expand Down

0 comments on commit 3ab39d2

Please sign in to comment.