diff --git a/nexla_sdk/models/destinations/responses.py b/nexla_sdk/models/destinations/responses.py index 481b183..4c8742b 100644 --- a/nexla_sdk/models/destinations/responses.py +++ b/nexla_sdk/models/destinations/responses.py @@ -29,7 +29,7 @@ class DataMapInfo(BaseModel): owner_id: int org_id: int name: str - description: str + description: Optional[str] = None public: bool created_at: datetime updated_at: datetime diff --git a/nexla_sdk/models/notifications/responses.py b/nexla_sdk/models/notifications/responses.py index 5b46a53..6e01a05 100644 --- a/nexla_sdk/models/notifications/responses.py +++ b/nexla_sdk/models/notifications/responses.py @@ -56,7 +56,7 @@ class NotificationSetting(BaseModel): owner_id: int channel: str notification_resource_type: str - resource_id: int + resource_id: Optional[int] = None status: str # PAUSED, ACTIVE notification_type_id: int name: str diff --git a/tests/unit/test_destinations.py b/tests/unit/test_destinations.py index ebaa4b7..d171ff8 100644 --- a/tests/unit/test_destinations.py +++ b/tests/unit/test_destinations.py @@ -9,7 +9,7 @@ DestinationCreate, DestinationUpdate, ) -from nexla_sdk.models.destinations.responses import Destination +from nexla_sdk.models.destinations.responses import DataMapInfo, Destination from tests.utils.assertions import assert_model_list_valid from tests.utils.mock_builders import MockResponseBuilder @@ -298,3 +298,45 @@ def test_empty_list_response(self, mock_client): # Assert assert destinations == [] assert len(destinations) == 0 + + def test_destination_with_null_data_map_description(self, mock_client): + """Test that destinations with None data_map.description validate correctly.""" + mock_response = MockResponseBuilder.destination( + { + "id": 100, + "name": "Dest with null map desc", + "data_map": { + "id": 1, + "owner_id": 10, + "org_id": 5, + "name": "Test Map", + "description": None, + "public": False, + "created_at": "2025-01-01T00:00:00Z", + "updated_at": "2025-01-01T00:00:00Z", + }, + } + ) + mock_client.http_client.add_response("/data_sinks/100", mock_response) + + destination = mock_client.destinations.get(100) + + assert isinstance(destination, Destination) + assert destination.data_map is not None + assert isinstance(destination.data_map, DataMapInfo) + assert destination.data_map.description is None + + def test_data_map_info_with_null_description(self): + """Test DataMapInfo model validates with description=None.""" + data = { + "id": 1, + "owner_id": 10, + "org_id": 5, + "name": "Map", + "description": None, + "public": False, + "created_at": "2025-01-01T00:00:00Z", + "updated_at": "2025-01-01T00:00:00Z", + } + model = DataMapInfo.model_validate(data) + assert model.description is None diff --git a/tests/unit/test_notifications.py b/tests/unit/test_notifications.py index 0939f46..bfba17f 100644 --- a/tests/unit/test_notifications.py +++ b/tests/unit/test_notifications.py @@ -280,3 +280,51 @@ def test_notification_types_and_settings(self, client, mock_http_client): "SOURCE", 1, expand=True, filter_overridden=True, notification_type_id=1 ) assert isinstance(lst3[0], NotificationSetting) + + def test_notification_setting_with_null_resource_id(self, client, mock_http_client): + mock_http_client.add_response( + "/notification_settings", + [ + { + "id": 10, + "org_id": 1, + "owner_id": 1, + "channel": "APP", + "notification_resource_type": "USER", + "resource_id": None, + "status": "ACTIVE", + "notification_type_id": 1, + "name": "n", + "description": "d", + "code": 0, + "category": "SYSTEM", + "event_type": "X", + "resource_type": "SOURCE", + "config": {}, + } + ], + ) + lst = client.notifications.list_settings() + assert isinstance(lst[0], NotificationSetting) + assert lst[0].resource_id is None + + def test_notification_setting_model_with_null_resource_id(self): + data = { + "id": 10, + "org_id": 1, + "owner_id": 1, + "channel": "APP", + "notification_resource_type": "USER", + "resource_id": None, + "status": "ACTIVE", + "notification_type_id": 1, + "name": "n", + "description": "d", + "code": 0, + "category": "SYSTEM", + "event_type": "X", + "resource_type": "SOURCE", + "config": {}, + } + model = NotificationSetting.model_validate(data) + assert model.resource_id is None