|
35 | 35 | validate_all_providers_have_committed_successfully,
|
36 | 36 | )
|
37 | 37 | from tests.unit.glue.test_glue_source_stubs import (
|
38 |
| - databases_1, |
39 |
| - databases_2, |
| 38 | + flights_database, |
| 39 | + test_database, |
40 | 40 | get_bucket_tagging,
|
41 | 41 | get_databases_delta_response,
|
42 | 42 | get_databases_response,
|
|
64 | 64 | tables_2,
|
65 | 65 | tables_profiling_1,
|
66 | 66 | target_database_tables,
|
| 67 | + empty_database, |
67 | 68 | )
|
68 | 69 |
|
69 | 70 | FROZEN_TIME = "2020-04-14 07:00:00"
|
@@ -310,6 +311,33 @@ def test_config_without_platform():
|
310 | 311 | assert source.platform == "glue"
|
311 | 312 |
|
312 | 313 |
|
| 314 | +def test_get_databases_filters_by_catalog(): |
| 315 | + def format_databases(databases): |
| 316 | + return set(d["Name"] for d in databases) |
| 317 | + |
| 318 | + all_catalogs_source: GlueSource = GlueSource( |
| 319 | + config=GlueSourceConfig(), ctx=PipelineContext(run_id="glue-source-test") |
| 320 | + ) |
| 321 | + with Stubber(all_catalogs_source.glue_client) as glue_stubber: |
| 322 | + glue_stubber.add_response("get_databases", get_databases_response, {}) |
| 323 | + |
| 324 | + expected = format_databases([flights_database, test_database, empty_database]) |
| 325 | + assert format_databases(all_catalogs_source.get_all_databases()) == expected |
| 326 | + |
| 327 | + catalog_id = "123412341234" |
| 328 | + single_catalog_source = GlueSource( |
| 329 | + config=GlueSourceConfig(catalog_id=catalog_id), |
| 330 | + ctx=PipelineContext(run_id="glue-source-test"), |
| 331 | + ) |
| 332 | + with Stubber(single_catalog_source.glue_client) as glue_stubber: |
| 333 | + glue_stubber.add_response( |
| 334 | + "get_databases", get_databases_response, {"CatalogId": catalog_id} |
| 335 | + ) |
| 336 | + |
| 337 | + expected = format_databases([flights_database, test_database]) |
| 338 | + assert format_databases(single_catalog_source.get_all_databases()) == expected |
| 339 | + |
| 340 | + |
313 | 341 | @freeze_time(FROZEN_TIME)
|
314 | 342 | def test_glue_stateful(pytestconfig, tmp_path, mock_time, mock_datahub_graph):
|
315 | 343 | deleted_actor_golden_mcs = "{}/glue_deleted_actor_mces_golden.json".format(
|
@@ -357,8 +385,8 @@ def test_glue_stateful(pytestconfig, tmp_path, mock_time, mock_datahub_graph):
|
357 | 385 | tables_on_first_call = tables_1
|
358 | 386 | tables_on_second_call = tables_2
|
359 | 387 | mock_get_all_databases_and_tables.side_effect = [
|
360 |
| - (databases_1, tables_on_first_call), |
361 |
| - (databases_2, tables_on_second_call), |
| 388 | + ([flights_database], tables_on_first_call), |
| 389 | + ([test_database], tables_on_second_call), |
362 | 390 | ]
|
363 | 391 |
|
364 | 392 | pipeline_run1 = run_and_get_pipeline(pipeline_config_dict)
|
|
0 commit comments