def test_not_an_operator(self, operator_config): operator_config['implementation'] = __name__ + '.NotAnOperator' with pytest.raises(ConfigParsingError) as e: create_operator(operator_config) assert_terms_in_exception(e, ['not', 'operator'])
def test_invalid_implementation_no_dots(self, operator_config): operator_config['implementation'] = 'thisisnotanoperator' with pytest.raises(ConfigParsingError) as e: create_operator(operator_config) assert_terms_in_exception(e, ['invalid', 'implementation'])
def test_fail_non_param(self, operator_config): operator_config['params']['non_param'] = 10 with pytest.raises(ConfigParsingError) as e: create_operator(operator_config) assert_terms_in_exception(e, ['invalid'])
def test_nested_param_config(): param_value = (3, 4) operator = NestedConfigParamTestOperator() operator.some_param = param_value operator_config = get_operator_config(operator) actual_operator = create_operator(operator_config) assert actual_operator.some_param == (3, 4)
def test_invalid_parameter_value(self, operator_config): class FailingParameter(ParameterSpec): def to_config(self, value: Any) -> Any: raise NotImplementedError() def from_config(self, operator_config: Any) -> None: assert False bak = OperatorForTesting.param1 OperatorForTesting.param1 = FailingParameter(default_value=None) with pytest.raises(ConfigParsingError) as e: create_operator(operator_config) OperatorForTesting.param1 = bak assert_terms_in_exception(e, ['fail', 'pars'])
def test_missing_params(self, operator_config): del operator_config['params']['param2'] operator = create_operator(operator_config) assert operator.param2 == param2_default_value
def test_ignore_non_parameters(self, operator_config): operator = create_operator(operator_config) assert operator.non_param is unique_object
def test_params(self, operator_config): operator = create_operator(operator_config) assert operator.param1 == param1_value assert operator.param2 == param2_value
def test_return_type(self, operator_config): operator = create_operator(operator_config) assert isinstance(operator, OperatorForTesting)
def test_unknown_pipeline_attribute(self, pipeline_config): pipeline_config['abc'] = 42 with pytest.raises(ConfigParsingError) as e: _ = create_operator(pipeline_config) assert_terms_in_exception(e, ['unknown'])
def test_return_value(self, operator_config): operator = create_operator(operator_config) actual_operator_config = get_operator_config(operator) assert actual_operator_config == operator_config
def test_fail_missing_implementation(self, operator_config): del operator_config['implementation'] with pytest.raises(ConfigParsingError): create_operator(operator_config)
def test_fail_extra_config_attributes(self, operator_config): operator_config['unknown_attribute'] = 42 with pytest.raises(ConfigParsingError): create_operator(operator_config)