Skip to content

Commit

Permalink
Use strings for Enum types in CustomEntityProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
murdo-moj committed Nov 15, 2024
1 parent 8fccaca commit 740e953
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/datahub-client/data_platform_catalogue/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,12 @@ class CustomEntityProperties(BaseModel):
)
audience: Audience = Field(
description="If the data is published or not",
default=Audience.INTERNAL,
default="Internal",
)

class Config:
use_enum_values = True


class Entity(BaseModel):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ReferencedEntityMissing,
)
from data_platform_catalogue.entities import (
Audience,
AccessInformation,
Chart,
Column,
Expand Down Expand Up @@ -331,7 +332,6 @@ def test_get_dataset(
},
"lastIngested": 1709619407814,
"domain": None,
"audience": "Internal",
"provider": "LAA",
"schemaMetadata": {
"fields": [
Expand Down Expand Up @@ -376,6 +376,7 @@ def test_get_dataset(
fully_qualified_name="Foo.Dataset",
description="Dataset",
relationships={
RelationshipType.DATA_LINEAGE: [],
RelationshipType.PARENT: [
EntitySummary(
entity_ref=EntityRef(
Expand All @@ -391,7 +392,6 @@ def test_get_dataset(
entity_type="Database",
)
],
RelationshipType.DATA_LINEAGE: [],
},
domain=DomainRef(display_name="", urn=""),
governance=Governance(
Expand All @@ -400,7 +400,6 @@ def test_get_dataset(
),
tags=[TagRef(display_name="some-tag", urn="urn:li:tag:Entity")],
last_modified=1709619407814,
audience="Internal",
provider="LAA",
created=None,
platform=EntityRef(urn="datahub", display_name="datahub"),
Expand Down Expand Up @@ -483,6 +482,7 @@ def test_get_dataset_minimal_properties(
),
data_summary=DataSummary(),
further_information=FurtherInformation(),
audience=Audience.INTERNAL,
),
column_details=[],
)
Expand Down Expand Up @@ -542,6 +542,7 @@ def test_get_chart_details(self, datahub_client, base_mock_graph):
),
data_summary=DataSummary(),
further_information=FurtherInformation(),
audience=Audience.INTERNAL,
),
external_url="https://data.justice.gov.uk/prisons/public-protection/absconds",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
parse_updated,
)
from data_platform_catalogue.entities import (
Audience,
AccessInformation,
Column,
ColumnRef,
Expand Down Expand Up @@ -285,6 +286,7 @@ def test_parse_properties():
{"key": "s3_location", "value": "s3://databucket/"},
{"key": "row_count", "value": 100},
{"key": "Not_IN", "value": "dddd"},
{"key": "audience", "value": "Internal"},
],
"name": "test",
"description": "test description",
Expand Down Expand Up @@ -313,6 +315,7 @@ def test_parse_properties():
further_information=FurtherInformation(
dc_slack_channel_name="test-channel", dc_slack_channel_url="test-url"
),
audience=Audience.INTERNAL,
)


Expand All @@ -328,6 +331,7 @@ def test_parse_properties_with_none_values():
{"key": "s3_location", "value": "s3://databucket/"},
{"key": "row_count", "value": 100},
{"key": "Not_IN", "value": "dddd"},
{"key": "audience", "value": "Internal"},
],
"name": "test",
"description": None,
Expand Down Expand Up @@ -356,6 +360,7 @@ def test_parse_properties_with_none_values():
),
data_summary=DataSummary(row_count=100),
further_information=FurtherInformation(),
audience=Audience.INTERNAL,
)


Expand Down
2 changes: 1 addition & 1 deletion lib/datahub-client/tests/client/datahub/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ def test_search_for_container(mock_graph, searcher):
"name": "test_db",
},
metadata={
"audience": Audience.INTERNAL,
"audience": "Internal",
"owner": "Shannon Lovett",
"owner_email": "[email protected]",
"domain_name": "testdom",
Expand Down

0 comments on commit 740e953

Please sign in to comment.