Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nexla_sdk/models/destinations/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nexla_sdk/models/notifications/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 43 additions & 1 deletion tests/unit/test_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
48 changes: 48 additions & 0 deletions tests/unit/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading