diff --git a/cognite/client/data_classes/extractionpipelines.py b/cognite/client/data_classes/extractionpipelines.py index 144d9da380..afa37ac0da 100644 --- a/cognite/client/data_classes/extractionpipelines.py +++ b/cognite/client/data_classes/extractionpipelines.py @@ -30,27 +30,24 @@ class ExtractionPipelineContact(CogniteObject): """A contact for an extraction pipeline Args: - name (str): Name of contact - email (str): Email address of contact - role (str): Role of contact, such as Owner, Maintainer, etc. - send_notification (bool): Whether to send notifications to this contact or not + name (str | None): Name of contact + email (str | None): Email address of contact + role (str | None): Role of contact, such as Owner, Maintainer, etc. + send_notification (bool | None): Whether to send notifications to this contact or not """ - def __init__(self, name: str, email: str, role: str, send_notification: bool) -> None: + def __init__( + self, + name: str | None = None, + email: str | None = None, + role: str | None = None, + send_notification: bool | None = None, + ) -> None: self.name = name self.email = email self.role = role self.send_notification = send_notification - @classmethod - def _load(cls, resource: dict, cognite_client: CogniteClient | None = None) -> ExtractionPipelineContact: - return cls( - name=resource["name"], - email=resource["email"], - role=resource["role"], - send_notification=resource["sendNotification"], - ) - @dataclass class ExtractionPipelineNotificationConfiguration(CogniteObject): diff --git a/tests/tests_unit/test_data_classes/test_extraction_pipipelines.py b/tests/tests_unit/test_data_classes/test_extraction_pipipelines.py new file mode 100644 index 0000000000..94178cb4d9 --- /dev/null +++ b/tests/tests_unit/test_data_classes/test_extraction_pipipelines.py @@ -0,0 +1,29 @@ +from typing import Any + +import pytest + +from cognite.client.data_classes.extractionpipelines import ExtractionPipelineContact + + +class TestExtractionPipeline: + @pytest.mark.parametrize( + "raw, expected", + [ + pytest.param( + {"name": "Homer", "email": "homer@springiefield.com"}, + ExtractionPipelineContact(name="Homer", email="homer@springiefield.com"), + id="Partial Contact", + ), + pytest.param( + {"name": "Marge", "email": "marge@springfield.com", "role": "Wife", "sendNotification": True}, + ExtractionPipelineContact( + name="Marge", email="marge@springfield.com", role="Wife", send_notification=True + ), + id="Full Contact", + ), + ], + ) + def test_load_dump_contracts(self, raw: dict[str, Any], expected: ExtractionPipelineContact) -> None: + loaded = ExtractionPipelineContact._load(raw) + assert loaded == expected + assert raw == loaded.dump()