-
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.
- Loading branch information
1 parent
51725af
commit 47204dd
Showing
2 changed files
with
97 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,9 @@ | ||
from datetime import datetime, timedelta | ||
from pathlib import Path | ||
from typing import Any, Dict | ||
|
||
import pytest | ||
from datahub.metadata.schema_classes import DomainPropertiesClass | ||
|
||
from datahub_client.entities import ( | ||
AccessInformation, | ||
CustomEntityProperties, | ||
DataSummary, | ||
DomainRef, | ||
EntityRef, | ||
EntitySummary, | ||
FurtherInformation, | ||
GlossaryTermRef, | ||
Governance, | ||
OwnerRef, | ||
RelationshipType, | ||
TagRef, | ||
UsageRestrictions, | ||
) | ||
|
||
from .test_helpers.graph_helpers import MockDataHubGraph | ||
from .test_helpers.mce_helpers import check_golden_file | ||
|
||
|
@@ -67,85 +50,3 @@ def pytest_addoption(parser): | |
default=False, | ||
) | ||
parser.addoption("--copy-output-files", action="store_true", default=False) | ||
|
||
|
||
@pytest.fixture | ||
def entity_data_with_timestamps_in_future(): | ||
future_timestamp = datetime.now() + timedelta(days=1) | ||
return { | ||
"urn": "urn:li:chart:(justice-data,absconds)", | ||
"display_name": "Absconds", | ||
"name": "Absconds", | ||
"fully_qualified_name": "", | ||
"description": "Number of absconds", | ||
"relationships": { | ||
RelationshipType.PARENT: [ | ||
EntitySummary( | ||
entity_ref=EntityRef( | ||
urn="urn:li:database:example", display_name="example" | ||
), | ||
description="entity for an example", | ||
entity_type="DATABASE", | ||
tags=[ | ||
TagRef( | ||
urn="urn:li:tag:dc_display_in_catalogue", | ||
display_name="dc_display_in_catalogue", | ||
) | ||
], | ||
) | ||
] | ||
}, | ||
"domain": DomainRef(display_name="HMPPS", urn="urn:li:domain:HMCTS"), | ||
"governance": Governance( | ||
data_owner=OwnerRef( | ||
display_name="John Doe", | ||
email="[email protected]", | ||
urn="urn:li:corpuser:john.doe", | ||
), | ||
data_stewards=[ | ||
OwnerRef( | ||
display_name="Jane Smith", | ||
email="[email protected]", | ||
urn="urn:li:corpuser:jane.smith", | ||
) | ||
], | ||
data_custodians=[ | ||
OwnerRef( | ||
display_name="Rosanne Columns", | ||
email="[email protected]", | ||
urn="urn:li:corpuser:rosanne.columns", | ||
) | ||
], | ||
), | ||
"glossary_terms": [ | ||
GlossaryTermRef( | ||
display_name="Essential Shared Data Asset (ESDA)", | ||
urn="urn:li:glossaryTerm:ESDA", | ||
description="An ESDA is...", | ||
) | ||
], | ||
"metadata_last_ingested": future_timestamp, | ||
"created": future_timestamp, | ||
"data_last_modified": future_timestamp, | ||
"platform": EntityRef(urn="urn:li:dataPlatform:kafka", display_name="Kafka"), | ||
"custom_properties": CustomEntityProperties( | ||
usage_restrictions=UsageRestrictions( | ||
dpia_required=False, dpia_location="OneTrust" | ||
), | ||
access_information=AccessInformation( | ||
dc_where_to_access_dataset="Analytical platform", | ||
source_dataset_name="stg_xhibit_bw_history", | ||
s3_location="s3://alpha-hmpps-reports-data", | ||
dc_access_requirements="Access granted on request", | ||
), | ||
data_summary=DataSummary(row_count=123, refresh_period="Daily"), | ||
further_information=FurtherInformation( | ||
dc_slack_channel_name="#data-engineering", | ||
dc_slack_channel_url="https://hmpps-data-engineering.slack.com", | ||
dc_teams_channel_name="Data team", | ||
dc_teams_channel_url="https://teams.microsoft.com/l/channel/123", | ||
dc_team_email="[email protected]", | ||
), | ||
), | ||
"tags_to_display": ["nomis", "data-warehouse"], | ||
} |
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,9 +1,104 @@ | ||
from datetime import datetime, timedelta | ||
|
||
import pytest | ||
|
||
from datahub_client.entities import Entity | ||
from datahub_client.entities import ( | ||
AccessInformation, | ||
CustomEntityProperties, | ||
DataSummary, | ||
DomainRef, | ||
Entity, | ||
EntityRef, | ||
EntitySummary, | ||
FurtherInformation, | ||
GlossaryTermRef, | ||
Governance, | ||
OwnerRef, | ||
RelationshipType, | ||
TagRef, | ||
UsageRestrictions, | ||
) | ||
|
||
|
||
def test_entity_timestamps_in_future_validation(entity_data_with_timestamps_in_future): | ||
def test_entity_timestamps_in_future_validation(): | ||
future_timestamp = datetime.now() + timedelta(days=1) | ||
entity_data_with_timestamps_in_future = { | ||
"urn": "urn:li:chart:(justice-data,absconds)", | ||
"display_name": "Absconds", | ||
"name": "Absconds", | ||
"fully_qualified_name": "", | ||
"description": "Number of absconds", | ||
"relationships": { | ||
RelationshipType.PARENT: [ | ||
EntitySummary( | ||
entity_ref=EntityRef( | ||
urn="urn:li:database:example", display_name="example" | ||
), | ||
description="entity for an example", | ||
entity_type="DATABASE", | ||
tags=[ | ||
TagRef( | ||
urn="urn:li:tag:dc_display_in_catalogue", | ||
display_name="dc_display_in_catalogue", | ||
) | ||
], | ||
) | ||
] | ||
}, | ||
"domain": DomainRef(display_name="HMPPS", urn="urn:li:domain:HMCTS"), | ||
"governance": Governance( | ||
data_owner=OwnerRef( | ||
display_name="John Doe", | ||
email="[email protected]", | ||
urn="urn:li:corpuser:john.doe", | ||
), | ||
data_stewards=[ | ||
OwnerRef( | ||
display_name="Jane Smith", | ||
email="[email protected]", | ||
urn="urn:li:corpuser:jane.smith", | ||
) | ||
], | ||
data_custodians=[ | ||
OwnerRef( | ||
display_name="Rosanne Columns", | ||
email="[email protected]", | ||
urn="urn:li:corpuser:rosanne.columns", | ||
) | ||
], | ||
), | ||
"glossary_terms": [ | ||
GlossaryTermRef( | ||
display_name="Essential Shared Data Asset (ESDA)", | ||
urn="urn:li:glossaryTerm:ESDA", | ||
description="An ESDA is...", | ||
) | ||
], | ||
"metadata_last_ingested": future_timestamp, | ||
"created": future_timestamp, | ||
"data_last_modified": future_timestamp, | ||
"platform": EntityRef(urn="urn:li:dataPlatform:kafka", display_name="Kafka"), | ||
"custom_properties": CustomEntityProperties( | ||
usage_restrictions=UsageRestrictions( | ||
dpia_required=False, dpia_location="OneTrust" | ||
), | ||
access_information=AccessInformation( | ||
dc_where_to_access_dataset="Analytical platform", | ||
source_dataset_name="stg_xhibit_bw_history", | ||
s3_location="s3://alpha-hmpps-reports-data", | ||
dc_access_requirements="Access granted on request", | ||
), | ||
data_summary=DataSummary(row_count=123, refresh_period="Daily"), | ||
further_information=FurtherInformation( | ||
dc_slack_channel_name="#data-engineering", | ||
dc_slack_channel_url="https://hmpps-data-engineering.slack.com", | ||
dc_teams_channel_name="Data team", | ||
dc_teams_channel_url="https://teams.microsoft.com/l/channel/123", | ||
dc_team_email="[email protected]", | ||
), | ||
), | ||
"tags_to_display": ["nomis", "data-warehouse"], | ||
} | ||
with pytest.raises(ValueError) as exc: | ||
Entity(**entity_data_with_timestamps_in_future) | ||
|
||
|