diff --git a/tests/tests_unit/test_data_classes/test_data_models/test_containers.py b/tests/tests_unit/test_data_classes/test_data_models/test_containers.py index 2ea095b8df..00d3aee6e6 100644 --- a/tests/tests_unit/test_data_classes/test_data_models/test_containers.py +++ b/tests/tests_unit/test_data_classes/test_data_models/test_containers.py @@ -1,6 +1,7 @@ import pytest from cognite.client.data_classes._base import UnknownCogniteObject +from cognite.client.data_classes.data_modeling import data_types from cognite.client.data_classes.data_modeling.containers import ( Constraint, Container, @@ -43,6 +44,18 @@ def test_load_dump__only_required(self, data: dict) -> None: actual = ContainerProperty.load(data).dump(camel_case=True) assert data == actual + def test_dump_no_longer_camelCases_everything_when_used(self) -> None: + cp = ContainerProperty( + data_types.Enum( + { + "Closed_I_think": data_types.EnumValue("Valve_is_closed"), + "Opened or not": data_types.EnumValue("Valve is opened"), + } + ) + ) + assert ContainerProperty._load(cp.dump()) == cp + assert sorted(cp.dump(camel_case=True)["type"]["values"]) == ["Closed_I_think", "Opened or not"] # type: ignore [index] + class TestConstraint: @pytest.mark.parametrize( diff --git a/tests/tests_unit/test_data_classes/test_data_models/test_data_types.py b/tests/tests_unit/test_data_classes/test_data_models/test_data_types.py index 980daa362a..f984721fee 100644 --- a/tests/tests_unit/test_data_classes/test_data_models/test_data_types.py +++ b/tests/tests_unit/test_data_classes/test_data_models/test_data_types.py @@ -3,6 +3,7 @@ from cognite.client.data_classes._base import UnknownCogniteObject from cognite.client.data_classes.data_modeling.data_types import ( DirectRelationReference, + Enum, PropertyType, PropertyTypeWithUnit, Text, @@ -66,7 +67,7 @@ def test_load_ignore_unknown_properties(self) -> None: data.pop("unknownProperty") assert data == actual - def test_load_dump_unkown_property(self) -> None: + def test_load_dump_unknown_property(self) -> None: data = {"type": "unknowngibberish", "list": True, "unit": {"externalId": "known"}} obj = PropertyType.load(data) assert isinstance(obj, UnknownCogniteObject) @@ -82,6 +83,29 @@ def test_load_text_without_collation(self) -> None: data["collation"] = "ucs_basic" assert data == actual + def test_dump_enum_no_camel_casing_of_user_values(self) -> None: + obj = PropertyType.load( + { + "type": "enum", + "values": { + "string_valWe ird_Case": { + "name": "string_valWe ird_Case", + "description": "Time series with string data points.", + }, + "numeric_valWe ird_Case": { + "name": "numeric_valWe ird_Case", + "description": "Time series with double floating point data points.", + }, + }, + } + ) + assert isinstance(obj, Enum) + + expected_values = ["numeric_valWe ird_Case", "string_valWe ird_Case"] + assert sorted(obj.values) == expected_values + assert sorted(obj.dump(camel_case=False)["values"]) == expected_values + assert sorted(obj.dump(camel_case=True)["values"]) == expected_values + class TestUnitSupport: @pytest.mark.parametrize(