2525
2626from caldav .jmap import AsyncJMAPClient , JMAPClient
2727from caldav .jmap .constants import CALENDAR_CAPABILITY
28+ from caldav .jmap .convert import jscal_to_ical
2829from caldav .jmap .error import JMAPMethodError
2930from caldav .jmap .session import fetch_session
3031
@@ -149,14 +150,15 @@ def test_calendars_have_id_and_name(self, client):
149150
150151class TestJMAPEventIntegration :
151152 def test_event_create_get (self , client , created_event_id ):
152- ical = client .get_event (created_event_id )
153+ obj = client .get_event (created_event_id )
154+ ical = jscal_to_ical (obj .get_data ())
153155 assert "BEGIN:VCALENDAR" in ical
154156 assert "Integration Test Event" in ical
155157
156158 def test_event_update (self , client , created_event_id ):
157159 client .update_event (created_event_id , _minimal_ical ("Updated Title" ))
158- fetched = client .get_event (created_event_id )
159- assert "Updated Title" in fetched
160+ obj = client .get_event (created_event_id )
161+ assert "Updated Title" in jscal_to_ical ( obj . get_data ())
160162
161163 def test_event_delete (self , client , calendar_id ):
162164 event_id = client .create_event (calendar_id , _minimal_ical ("To Be Deleted" ))
@@ -171,22 +173,22 @@ def test_event_query_time_range(self, client, calendar_id, created_event_id):
171173 end = "2026-06-02T00:00:00" ,
172174 )
173175 assert len (results ) >= 1
174- assert any ("Integration Test Event" in r for r in results )
176+ assert any ("Integration Test Event" in jscal_to_ical ( r . get_data ()) for r in results )
175177
176178 def test_event_sync (self , client , calendar_id ):
177179 token_before = client .get_sync_token ()
178180 event_id = client .create_event (calendar_id , _minimal_ical ("Sync Test Event" ))
179181 try :
180182 added , _modified , _deleted = client .get_objects_by_sync_token (token_before )
181- assert any ("Sync Test Event" in a for a in added )
183+ assert any ("Sync Test Event" in jscal_to_ical ( a . get_data ()) for a in added )
182184 finally :
183185 client .delete_event (event_id )
184186
185187 def test_ical_roundtrip (self , client , calendar_id ):
186188 start = datetime (2026 , 7 , 15 , 9 , 0 , 0 , tzinfo = timezone .utc )
187189 event_id = client .create_event (calendar_id , _minimal_ical ("Roundtrip Event" , start = start ))
188190 try :
189- fetched = client .get_event (event_id )
191+ fetched = jscal_to_ical ( client .get_event (event_id ). get_data () )
190192 assert "Roundtrip Event" in fetched
191193 assert "20260715" in fetched
192194 finally :
@@ -196,7 +198,8 @@ def test_ical_roundtrip(self, client, calendar_id):
196198class TestAsyncJMAPEventIntegration :
197199 @pytest .mark .asyncio
198200 async def test_event_create_get (self , async_client , async_created_event_id ):
199- ical = await async_client .get_event (async_created_event_id )
201+ obj = await async_client .get_event (async_created_event_id )
202+ ical = jscal_to_ical (obj .get_data ())
200203 assert "BEGIN:VCALENDAR" in ical
201204 assert "Async Integration Test Event" in ical
202205
@@ -205,8 +208,8 @@ async def test_event_update(self, async_client, async_created_event_id):
205208 await async_client .update_event (
206209 async_created_event_id , _minimal_ical ("Async Updated Title" )
207210 )
208- fetched = await async_client .get_event (async_created_event_id )
209- assert "Async Updated Title" in fetched
211+ obj = await async_client .get_event (async_created_event_id )
212+ assert "Async Updated Title" in jscal_to_ical ( obj . get_data ())
210213
211214 @pytest .mark .asyncio
212215 async def test_event_delete (self , async_client , async_calendar_id ):
@@ -227,7 +230,7 @@ async def test_event_query_time_range(
227230 end = "2026-06-02T00:00:00" ,
228231 )
229232 assert len (results ) >= 1
230- assert any ("Async Integration Test Event" in r for r in results )
233+ assert any ("Async Integration Test Event" in jscal_to_ical ( r . get_data ()) for r in results )
231234
232235 @pytest .mark .asyncio
233236 async def test_event_sync (self , async_client , async_calendar_id ):
@@ -237,7 +240,7 @@ async def test_event_sync(self, async_client, async_calendar_id):
237240 )
238241 try :
239242 added , _modified , _deleted = await async_client .get_objects_by_sync_token (token_before )
240- assert any ("Async Sync Test Event" in a for a in added )
243+ assert any ("Async Sync Test Event" in jscal_to_ical ( a . get_data ()) for a in added )
241244 finally :
242245 await async_client .delete_event (event_id )
243246
@@ -248,7 +251,7 @@ async def test_ical_roundtrip(self, async_client, async_calendar_id):
248251 async_calendar_id , _minimal_ical ("Async Roundtrip Event" , start = start )
249252 )
250253 try :
251- fetched = await async_client .get_event (event_id )
254+ fetched = jscal_to_ical (( await async_client .get_event (event_id )). get_data () )
252255 assert "Async Roundtrip Event" in fetched
253256 assert "20260715" in fetched
254257 finally :
0 commit comments