import pytest from pydantic import ValidationError from monday_com_orca_backend.api.routers.models import ( BaseCollectionResponse, BaseErrorResponse, ) class TestBaseCollectionResponse: @pytest.mark.parametrize( "data,more,expected_count", [ ([{"id": 1, "name": "Item 1"}, {"id": 2, "name": "Item 2"}], True, 2), ([], False, 0), ], ) def test_collection_response(self, data, more, expected_count): resp = BaseCollectionResponse(data=data, more=more) assert resp.data == data assert resp.more is more assert resp.count == expected_count serialized = resp.model_dump() assert serialized["count"] == expected_count assert serialized["data"] == data assert serialized["more"] is more def test_invalid_data_type(self): with pytest.raises(ValidationError): BaseCollectionResponse(data="notalist", more=False) # noqa class TestBaseErrorResponse: @pytest.mark.parametrize( "detail", [ "Something went wrong.", "Not found.", ], ) def test_error_response(self, detail): resp = BaseErrorResponse(detail=detail) assert resp.detail == detail serialized = resp.model_dump() assert serialized["detail"] == detail def test_missing_detail(self): with pytest.raises(ValidationError): BaseErrorResponse() # noqa