-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fallback for missing access info
- Loading branch information
Showing
3 changed files
with
102 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
|
@@ -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 | ||
|
@@ -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() | ||
|
@@ -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" | ||
|