def test_build_params_missing_non_required_fields(self, add_tags_patch): acon_dict = self._create_acon_dict({ "source_table": self.SOURCE_TABLE, "target_table": self.TARGET_TABLE, "source_field": self.SOURCE_FIELD, "substring_positions": self.SUBSTRING_POSITIONS }) emr_system = self._create_emr_system() configuration = self._create_algorithm_configuration(acon_dict) algorithm = AlgorithmFixedLengthStringExtractor( emr_system, configuration.get_algorithm_instance(), configuration.get_algorithm_params() ) generated_params = algorithm.build_params() expected_full_source_table = self._create_full_table_name(self.SOURCE_TABLE) expected_full_target_table = self._create_full_table_name(self.TARGET_TABLE) expected_params = { "source_table": expected_full_source_table, "target_table": expected_full_target_table, "source_field": self.SOURCE_FIELD, "substring_positions": self.SUBSTRING_POSITIONS } assert generated_params == expected_params add_tags_patch.assert_called_once() add_tags_patch_call_args, _ = add_tags_patch.call_args assert sorted(add_tags_patch_call_args[0], key=lambda x: x["Key"]) == sorted([ {"Key": "SourceTable", "Value": expected_full_source_table}, {"Key": "TargetTable", "Value": expected_full_target_table} ], key=lambda x: x["Key"])
def test_build_params_with_rules_and_conditions(self, _): acon_dict = self._create_acon_dict({ "source_table": self.SOURCE_TABLE, "target_table": self.TARGET_TABLE, "source_field": self.SOURCE_FIELD, "target_partitions": self.TARGET_PARTITIONS, "select_conditions": self.SELECT_CONDITIONS, "select_rules": self.SELECT_RULES, "substring_positions": self.SUBSTRING_POSITIONS }) emr_system = self._create_emr_system() configuration = self._create_algorithm_configuration(acon_dict) with pytest.raises(M3DIllegalArgumentException) as ex_info: AlgorithmFixedLengthStringExtractor( emr_system, configuration.get_algorithm_instance(), configuration.get_algorithm_params()) assert str(ex_info.value).startswith( "Unable to use both select_conditions and select_rules at the same time" )
def test_build_params_missing_substring_positions(self, _): acon_dict = self._create_acon_dict({ "source_table": self.SOURCE_TABLE, "target_table": self.TARGET_TABLE, "source_field": self.SOURCE_FIELD, "partition_columns": self.PARTITION_COLUMNS, "select_conditions": self.SELECT_CONDITIONS }) emr_system = self._create_emr_system() configuration = self._create_algorithm_configuration(acon_dict) with pytest.raises(M3DIllegalArgumentException) as ex_info: AlgorithmFixedLengthStringExtractor( emr_system, configuration.get_algorithm_instance(), configuration.get_algorithm_params() ) assert str(ex_info.value).startswith("Substring positions specification is missing in the acon-file")