|
27 | 27 | from datahub.ingestion.source.tableau import tableau_constant as c
|
28 | 28 | from datahub.ingestion.source.tableau.tableau import (
|
29 | 29 | TableauConfig,
|
| 30 | + TableauProject, |
30 | 31 | TableauSiteSource,
|
31 | 32 | TableauSource,
|
32 | 33 | TableauSourceReport,
|
@@ -1342,6 +1343,82 @@ def test_permission_warning(pytestconfig, tmp_path, mock_datahub_graph):
|
1342 | 1343 |
|
1343 | 1344 |
|
1344 | 1345 | @freeze_time(FROZEN_TIME)
|
| 1346 | +@pytest.mark.parametrize( |
| 1347 | + "extract_project_hierarchy, allowed_projects", |
| 1348 | + [ |
| 1349 | + (True, ["project1", "project4", "project3"]), |
| 1350 | + (False, ["project1", "project4"]), |
| 1351 | + ], |
| 1352 | +) |
| 1353 | +def test_extract_project_hierarchy(extract_project_hierarchy, allowed_projects): |
| 1354 | + context = PipelineContext(run_id="0", pipeline_name="test_tableau") |
| 1355 | + |
| 1356 | + config_dict = config_source_default.copy() |
| 1357 | + |
| 1358 | + del config_dict["stateful_ingestion"] |
| 1359 | + del config_dict["projects"] |
| 1360 | + |
| 1361 | + config_dict["project_pattern"] = { |
| 1362 | + "allow": ["project1", "project4"], |
| 1363 | + "deny": ["project2"], |
| 1364 | + } |
| 1365 | + |
| 1366 | + config_dict["extract_project_hierarchy"] = extract_project_hierarchy |
| 1367 | + |
| 1368 | + config = TableauConfig.parse_obj(config_dict) |
| 1369 | + |
| 1370 | + site_source = TableauSiteSource( |
| 1371 | + config=config, |
| 1372 | + ctx=context, |
| 1373 | + platform="tableau", |
| 1374 | + site=SiteItem(name="Site 1", content_url="site1"), |
| 1375 | + site_id="site1", |
| 1376 | + report=TableauSourceReport(), |
| 1377 | + server=Server("https://test-tableau-server.com"), |
| 1378 | + ) |
| 1379 | + |
| 1380 | + all_project_map: Dict[str, TableauProject] = { |
| 1381 | + "p1": TableauProject( |
| 1382 | + id="1", |
| 1383 | + name="project1", |
| 1384 | + path=[], |
| 1385 | + parent_id=None, |
| 1386 | + parent_name=None, |
| 1387 | + description=None, |
| 1388 | + ), |
| 1389 | + "p2": TableauProject( |
| 1390 | + id="2", |
| 1391 | + name="project2", |
| 1392 | + path=[], |
| 1393 | + parent_id="1", |
| 1394 | + parent_name="project1", |
| 1395 | + description=None, |
| 1396 | + ), |
| 1397 | + "p3": TableauProject( |
| 1398 | + id="3", |
| 1399 | + name="project3", |
| 1400 | + path=[], |
| 1401 | + parent_id="1", |
| 1402 | + parent_name="project1", |
| 1403 | + description=None, |
| 1404 | + ), |
| 1405 | + "p4": TableauProject( |
| 1406 | + id="4", |
| 1407 | + name="project4", |
| 1408 | + path=[], |
| 1409 | + parent_id=None, |
| 1410 | + parent_name=None, |
| 1411 | + description=None, |
| 1412 | + ), |
| 1413 | + } |
| 1414 | + |
| 1415 | + site_source._init_tableau_project_registry(all_project_map) |
| 1416 | + |
| 1417 | + assert allowed_projects == [ |
| 1418 | + project.name for project in site_source.tableau_project_registry.values() |
| 1419 | + ] |
| 1420 | + |
| 1421 | + |
1345 | 1422 | @pytest.mark.integration
|
1346 | 1423 | def test_connection_report_test(requests_mock):
|
1347 | 1424 | server_info_response = """
|
|
0 commit comments