Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(ingest/tableau): add test for extract_project_hierarchy scenario #12079

Merged
merged 17 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from datahub.ingestion.source.tableau import tableau_constant as c
from datahub.ingestion.source.tableau.tableau import (
TableauConfig,
TableauProject,
TableauSiteSource,
TableauSource,
TableauSourceReport,
Expand Down Expand Up @@ -1341,6 +1342,82 @@ def test_permission_warning(pytestconfig, tmp_path, mock_datahub_graph):


@freeze_time(FROZEN_TIME)
@pytest.mark.parametrize(
"extract_project_hierarchy, allowed_projects",
[
(True, ["project1", "project4", "project3"]),
(False, ["project1", "project4"]),
],
)
def test_extract_project_hierarchy(extract_project_hierarchy, allowed_projects):
context = PipelineContext(run_id="0", pipeline_name="test_tableau")

config_dict = config_source_default.copy()

del config_dict["stateful_ingestion"]
del config_dict["projects"]

config_dict["project_pattern"] = {
"allow": ["project1", "project4"],
"deny": ["project2"],
}

config_dict["extract_project_hierarchy"] = extract_project_hierarchy

config = TableauConfig.parse_obj(config_dict)

site_source = TableauSiteSource(
config=config,
ctx=context,
platform="tableau",
site=SiteItem(name="Site 1", content_url="site1"),
site_id="site1",
report=TableauSourceReport(),
server=Server("https://test-tableau-server.com"),
)

all_project_map: Dict[str, TableauProject] = {
"p1": TableauProject(
id="1",
name="project1",
path=[],
parent_id=None,
parent_name=None,
description=None,
),
"p2": TableauProject(
id="2",
name="project2",
path=[],
parent_id="1",
parent_name="project1",
description=None,
),
"p3": TableauProject(
id="3",
name="project3",
path=[],
parent_id="1",
parent_name="project1",
description=None,
),
"p4": TableauProject(
id="4",
name="project4",
path=[],
parent_id=None,
parent_name=None,
description=None,
),
}

site_source._init_tableau_project_registry(all_project_map)

assert allowed_projects == [
project.name for project in site_source.tableau_project_registry.values()
]


@pytest.mark.integration
def test_connection_report_test(requests_mock):
server_info_response = """
Expand Down
Loading