def test_given_invalid_json_then_we_fail_to_parse_it_to_operator_config(): expected_error = "Invalid input, operator config must contain operator_name" with pytest.raises(InvalidParamException, match=expected_error): OperatorConfig.from_json({ "masking_char": "*", "chars_to_mask": 4, "from_end": True })
def operators_config_from_json(data: Dict) -> Dict[str, 'OperatorConfig']: """ Go over the operators list and get the relevant create operator config entity. :param data: contains the list of configuration value - OperatorConfig """ if data is not None: return { key: OperatorConfig.from_json(operator_json) for (key, operator_json) in data.items() } return {}
def test_given_valid_json_then_we_parse_it_to_operator_config(): operator_config = OperatorConfig.from_json({ "type": "mask", "masking_char": "*", "chars_to_mask": 4, "from_end": True }) assert operator_config.operator_name == "mask" assert operator_config.params == { "masking_char": "*", "chars_to_mask": 4, "from_end": True }
def test_given_json_then_anonymizer_config_is_created_properly(class_name): json = {"type": class_name, "param_1": "my_parameter"} operator_config = OperatorConfig.from_json(json) assert operator_config.operator_name == class_name assert operator_config.params == {"param_1": "my_parameter"}