-
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.
Merge branch 'main' into fmd-808-nginx-rate-limiting
- Loading branch information
Showing
10 changed files
with
308 additions
and
51 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from home.service.details import ( | ||
DashboardDetailsService, | ||
DatabaseDetailsService, | ||
DatasetDetailsService, | ||
) | ||
|
||
|
||
class DatasetDetailsCsvFormatter: | ||
def __init__(self, details_service: DatasetDetailsService): | ||
self.details_service = details_service | ||
|
||
def data(self): | ||
return [ | ||
( | ||
column.name, | ||
column.display_name, | ||
column.type, | ||
column.description, | ||
) | ||
for column in self.details_service.table_metadata.column_details | ||
] | ||
|
||
def headers(self): | ||
return [ | ||
"name", | ||
"display_name", | ||
"type", | ||
"description", | ||
] | ||
|
||
|
||
class DatabaseDetailsCsvFormatter: | ||
def __init__(self, details_service: DatabaseDetailsService): | ||
self.details_service = details_service | ||
|
||
def data(self): | ||
return [ | ||
( | ||
table.entity_ref.urn, | ||
table.entity_ref.display_name, | ||
table.description, | ||
) | ||
for table in self.details_service.entities_in_database | ||
] | ||
|
||
def headers(self): | ||
return [ | ||
"urn", | ||
"display_name", | ||
"description", | ||
] | ||
|
||
|
||
class DashboardDetailsCsvFormatter: | ||
def __init__(self, details_service: DashboardDetailsService): | ||
self.details_service = details_service | ||
|
||
def data(self): | ||
return [ | ||
(chart.entity_ref.urn, chart.entity_ref.display_name, chart.description) | ||
for chart in self.details_service.children | ||
] | ||
|
||
def headers(self): | ||
return ["urn", "display_name", "description"] |
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,116 @@ | ||
from unittest.mock import MagicMock | ||
|
||
from data_platform_catalogue.entities import Column, EntityRef, EntitySummary | ||
|
||
from home.service.details import ( | ||
DashboardDetailsService, | ||
DatabaseDetailsService, | ||
DatasetDetailsService, | ||
) | ||
from home.service.details_csv import ( | ||
DashboardDetailsCsvFormatter, | ||
DatabaseDetailsCsvFormatter, | ||
DatasetDetailsCsvFormatter, | ||
) | ||
|
||
|
||
def test_dataset_details_csv_formatter(example_table): | ||
details_service = MagicMock(spec=DatasetDetailsService) | ||
columns = [ | ||
Column( | ||
name="foo", | ||
display_name="Foo", | ||
type="string", | ||
description="an example", | ||
nullable=False, | ||
is_primary_key=True, | ||
), | ||
Column( | ||
name="bar", | ||
display_name="Bar", | ||
type="integer", | ||
description="another example", | ||
nullable=True, | ||
is_primary_key=False, | ||
), | ||
] | ||
details_service.table_metadata = example_table | ||
example_table.column_details = columns | ||
csv_formatter = DatasetDetailsCsvFormatter(details_service) | ||
|
||
assert csv_formatter.headers() == [ | ||
"name", | ||
"display_name", | ||
"type", | ||
"description", | ||
] | ||
assert csv_formatter.data() == [ | ||
( | ||
"foo", | ||
"Foo", | ||
"string", | ||
"an example", | ||
), | ||
( | ||
"bar", | ||
"Bar", | ||
"integer", | ||
"another example", | ||
), | ||
] | ||
|
||
|
||
def test_database_details_csv_formatter(example_database): | ||
tables = [ | ||
EntitySummary( | ||
entity_ref=EntityRef(display_name="foo", urn="urn:foo"), | ||
description="an example", | ||
entity_type="Table", | ||
tags=[], | ||
), | ||
EntitySummary( | ||
entity_ref=EntityRef(display_name="bar", urn="urn:bar"), | ||
description="another example", | ||
entity_type="Table", | ||
tags=[], | ||
), | ||
] | ||
|
||
details_service = MagicMock(spec=DatabaseDetailsService) | ||
details_service.entities_in_database = tables | ||
|
||
csv_formatter = DatabaseDetailsCsvFormatter(details_service) | ||
|
||
assert csv_formatter.headers() == ["urn", "display_name", "description"] | ||
assert csv_formatter.data() == [ | ||
("urn:foo", "foo", "an example"), | ||
("urn:bar", "bar", "another example"), | ||
] | ||
|
||
|
||
def test_dashboard_details_csv_formatter(example_dashboard): | ||
charts = [ | ||
EntitySummary( | ||
entity_ref=EntityRef(display_name="foo", urn="urn:foo"), | ||
description="an example", | ||
entity_type="Chart", | ||
tags=[], | ||
), | ||
EntitySummary( | ||
entity_ref=EntityRef(display_name="bar", urn="urn:bar"), | ||
description="another example", | ||
entity_type="Chart", | ||
tags=[], | ||
), | ||
] | ||
|
||
details_service = MagicMock(spec=DashboardDetailsService) | ||
details_service.children = charts | ||
|
||
csv_formatter = DashboardDetailsCsvFormatter(details_service) | ||
|
||
assert csv_formatter.headers() == ["urn", "display_name", "description"] | ||
assert csv_formatter.data() == [ | ||
("urn:foo", "foo", "an example"), | ||
("urn:bar", "bar", "another example"), | ||
] |
Oops, something went wrong.