|
3 | 3 | from unittest.mock import MagicMock, patch
|
4 | 4 |
|
5 | 5 | import pytest
|
| 6 | + |
6 | 7 | from data_platform_catalogue.client.datahub_client import (
|
7 | 8 | DataHubCatalogueClient,
|
8 | 9 | InvalidDomain,
|
@@ -500,6 +501,95 @@ def test_get_chart_details(self, datahub_client, base_mock_graph):
|
500 | 501 | external_url="https://data.justice.gov.uk/prisons/public-protection/absconds",
|
501 | 502 | )
|
502 | 503 |
|
| 504 | + def test_get_database_details_filters_entities( |
| 505 | + self, datahub_client, base_mock_graph |
| 506 | + ): |
| 507 | + urn = "urn:li:container:foo" |
| 508 | + datahub_response = { |
| 509 | + "container": { |
| 510 | + "urn": "urn:li:container", |
| 511 | + "type": "CONTAINER", |
| 512 | + "platform": {"name": "platform"}, |
| 513 | + "parentContainers": { |
| 514 | + "count": 0, |
| 515 | + }, |
| 516 | + "entities": { |
| 517 | + "total": 2, |
| 518 | + "searchResults": [ |
| 519 | + { |
| 520 | + "entity": { |
| 521 | + "name": "DatasetToShow", |
| 522 | + "properties": { |
| 523 | + "name": "DatasetToShow", |
| 524 | + "description": "Dataset to show", |
| 525 | + }, |
| 526 | + "tags": { |
| 527 | + "tags": [ |
| 528 | + { |
| 529 | + "tag": { |
| 530 | + "urn": "urn:li:tag:dc_display_in_catalogue", |
| 531 | + "properties": { |
| 532 | + "name": "dc:display_in_catalogue", |
| 533 | + }, |
| 534 | + } |
| 535 | + } |
| 536 | + ] |
| 537 | + }, |
| 538 | + } |
| 539 | + }, |
| 540 | + { |
| 541 | + "entity": { |
| 542 | + "name": "DatasetToHide", |
| 543 | + "properties": { |
| 544 | + "name": "DatasetToHide", |
| 545 | + "description": "Dataset to hide", |
| 546 | + }, |
| 547 | + "tags": {"tags": []}, |
| 548 | + } |
| 549 | + }, |
| 550 | + ], |
| 551 | + }, |
| 552 | + "ownership": None, |
| 553 | + "properties": { |
| 554 | + "name": "Some database", |
| 555 | + "description": "a test description", |
| 556 | + "customProperties": [], |
| 557 | + "lastModified": {"time": 0}, |
| 558 | + }, |
| 559 | + }, |
| 560 | + "extensions": {}, |
| 561 | + } |
| 562 | + base_mock_graph.execute_graphql = MagicMock(return_value=datahub_response) |
| 563 | + |
| 564 | + with patch( |
| 565 | + "data_platform_catalogue.client.datahub_client.DataHubCatalogueClient.check_entity_exists_by_urn" |
| 566 | + ) as mock_exists: |
| 567 | + mock_exists.return_value = True |
| 568 | + database = datahub_client.get_database_details(urn) |
| 569 | + assert database.tables == [ |
| 570 | + { |
| 571 | + "entity": { |
| 572 | + "name": "DatasetToShow", |
| 573 | + "properties": { |
| 574 | + "description": "Dataset to show", |
| 575 | + "name": "DatasetToShow", |
| 576 | + }, |
| 577 | + "tags": { |
| 578 | + "tags": [ |
| 579 | + { |
| 580 | + "tag": { |
| 581 | + "properties": { |
| 582 | + "name": "dc:display_in_catalogue", |
| 583 | + }, |
| 584 | + "urn": "urn:li:tag:dc_display_in_catalogue", |
| 585 | + }, |
| 586 | + }, |
| 587 | + ], |
| 588 | + }, |
| 589 | + } |
| 590 | + } |
| 591 | + ] |
| 592 | + |
503 | 593 | def test_upsert_table_and_database(
|
504 | 594 | self,
|
505 | 595 | datahub_client,
|
|
0 commit comments