|
21 | 21 | TestDataSourceStatus, |
22 | 22 | create_ds_config, |
23 | 23 | _check_data_source_exists, |
| 24 | + _get_temp_schema, |
24 | 25 | _test_data_source, |
25 | 26 | ) |
26 | 27 |
|
@@ -144,6 +145,22 @@ def setUp(self) -> None: |
144 | 145 | self.api.get_data_source_schema_config.return_value = self.data_source_schema |
145 | 146 | self.api.get_data_sources.return_value = self.data_sources |
146 | 147 |
|
| 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 | + |
147 | 164 | @parameterized.expand([(c,) for c in DATA_SOURCE_CONFIGS], name_func=format_data_source_config_test) |
148 | 165 | def test_create_ds_config(self, config: TDsConfig): |
149 | 166 | inputs = list(config.options.values()) + [config.temp_schema, config.float_tolerance] |
|
0 commit comments