From 39b6761ed587b4d5189ce918810c74c6801dd4eb Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Mon, 11 Nov 2024 16:06:05 +0100 Subject: [PATCH] test: implement sad path mapper tests for grouped models --- .../test_sad_path_mapper_grouped_models.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/tests_mapper/test_sad_path_mapper_grouped_models.py diff --git a/tests/tests_mapper/test_sad_path_mapper_grouped_models.py b/tests/tests_mapper/test_sad_path_mapper_grouped_models.py new file mode 100644 index 0000000..b4a54d8 --- /dev/null +++ b/tests/tests_mapper/test_sad_path_mapper_grouped_models.py @@ -0,0 +1,28 @@ +import pytest + +from pydantic import BaseModel, ConfigDict +from rdfproxy import ModelBindingsMapper +from rdfproxy.utils._exceptions import ( + MissingModelConfigException, + UnboundGroupingKeyException, +) + + +class ModelMissingGroupByConfig(BaseModel): + x: list[int] + + +class ModelMissingGroupByValue(BaseModel): + model_config = ConfigDict(group_by="y") + + x: list[int] + + +def test_sad_path_adapter_missing_grouping_config(): + with pytest.raises(MissingModelConfigException): + ModelBindingsMapper(ModelMissingGroupByConfig, {"x": 1}).get_models() + + +def test_sad_path_adapter_missing_grouping_value(): + with pytest.raises(UnboundGroupingKeyException): + ModelBindingsMapper(ModelMissingGroupByValue, {"x": 1}).get_models()