Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 0b1b54e

Browse files
committed
add unit tests for a temp schema
1 parent 2a85528 commit 0b1b54e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/cloud/test_data_source.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
TestDataSourceStatus,
2222
create_ds_config,
2323
_check_data_source_exists,
24+
_get_temp_schema,
2425
_test_data_source,
2526
)
2627

@@ -144,6 +145,22 @@ def setUp(self) -> None:
144145
self.api.get_data_source_schema_config.return_value = self.data_source_schema
145146
self.api.get_data_sources.return_value = self.data_sources
146147

148+
@parameterized.expand([(c,) for c in DATA_SOURCE_CONFIGS], name_func=format_data_source_config_test)
149+
@patch("data_diff.dbt_parser.DbtParser.__new__")
150+
def test_get_temp_schema(self, config: TDsConfig, mock_dbt_parser):
151+
diff_vars = {
152+
"prod_database": "db",
153+
"prod_schema": "schema",
154+
}
155+
mock_dbt_parser.get_datadiff_variables.return_value = diff_vars
156+
temp_schema = f'{diff_vars["prod_database"]}.{diff_vars["prod_schema"]}'
157+
if config.type == "snowflake":
158+
temp_schema = temp_schema.upper()
159+
elif config.type in {"pg", "postgres_aurora", "postgres_aws_rds", "redshift"}:
160+
temp_schema = temp_schema.lower()
161+
162+
assert _get_temp_schema(dbt_parser=mock_dbt_parser, db_type=config.type) == temp_schema
163+
147164
@parameterized.expand([(c,) for c in DATA_SOURCE_CONFIGS], name_func=format_data_source_config_test)
148165
def test_create_ds_config(self, config: TDsConfig):
149166
inputs = list(config.options.values()) + [config.temp_schema, config.float_tolerance]

0 commit comments

Comments
 (0)