@@ -13,9 +13,13 @@ async def test_create_delete_async(anc):
1313 calendars = principal .calendars ()
1414 assert calendars
1515 all_events_before = calendar .events ()
16+ # Use a past date so the event isn't picked up by Nextcloud's
17+ # calendar-status automation (which scans events in [now, now+5m]
18+ # and caches the result for 5 minutes, breaking user_status tests).
19+ past = datetime .datetime .now () - datetime .timedelta (days = 400 )
1620 event = calendar .save_event (
17- dtstart = datetime . datetime . now () ,
18- dtend = datetime . datetime . now () + datetime .timedelta (hours = 1 ),
21+ dtstart = past ,
22+ dtend = past + datetime .timedelta (hours = 1 ),
1923 summary = "NcPyApi + CalDAV test" ,
2024 )
2125 all_events_after = calendar .events ()
@@ -71,7 +75,9 @@ async def test_event_full_lifecycle_async(anc):
7175 calendar = principal .make_calendar ("test_ncpyapi_ops" )
7276 try :
7377 # --- Event lifecycle ---
74- now = datetime .datetime .now ()
78+ # Use a past anchor so these events don't trigger Nextcloud's
79+ # calendar-status automation (see test_create_delete for details).
80+ now = datetime .datetime .now () - datetime .timedelta (days = 400 )
7581 calendar .save_event (
7682 dtstart = now ,
7783 dtend = now + datetime .timedelta (hours = 2 ),
@@ -114,21 +120,26 @@ async def test_event_date_range_search_async(anc):
114120 principal = anc .cal .principal ()
115121 calendar = principal .make_calendar ("test_ncpyapi_search" )
116122 try :
117- base = datetime .datetime .now ().replace (hour = 12 , minute = 0 , second = 0 , microsecond = 0 )
123+ # Anchor the search range in the past so none of these events fall
124+ # into Nextcloud's calendar-status window ([now, now+5m]); the
125+ # date-range search logic under test doesn't depend on "today".
126+ base = (datetime .datetime .now () - datetime .timedelta (days = 400 )).replace (
127+ hour = 12 , minute = 0 , second = 0 , microsecond = 0
128+ )
118129 calendar .save_event (
119130 dtstart = base ,
120131 dtend = base + datetime .timedelta (hours = 1 ),
121- summary = "Today Event" ,
132+ summary = "Day 0 Event" ,
122133 )
123134 calendar .save_event (
124135 dtstart = base + datetime .timedelta (days = 1 ),
125136 dtend = base + datetime .timedelta (days = 1 , hours = 1 ),
126- summary = "Tomorrow Event" ,
137+ summary = "Day +1 Event" ,
127138 )
128139 calendar .save_event (
129140 dtstart = base + datetime .timedelta (days = 7 ),
130141 dtend = base + datetime .timedelta (days = 7 , hours = 1 ),
131- summary = "Next Week Event" ,
142+ summary = "Day +7 Event" ,
132143 )
133144 assert len (calendar .events ()) == 3
134145
@@ -139,19 +150,19 @@ async def test_event_date_range_search_async(anc):
139150 event = True ,
140151 )
141152 summaries = {str (e .icalendar_component .get ("SUMMARY" )) for e in results }
142- assert "Today Event" in summaries
143- assert "Tomorrow Event" not in summaries
153+ assert "Day 0 Event" in summaries
154+ assert "Day +1 Event" not in summaries
144155
145- # Search for today + tomorrow
156+ # Search for day 0 + day +1
146157 results = calendar .search (
147158 start = base - datetime .timedelta (hours = 1 ),
148159 end = base + datetime .timedelta (days = 1 , hours = 2 ),
149160 event = True ,
150161 )
151162 summaries = {str (e .icalendar_component .get ("SUMMARY" )) for e in results }
152- assert "Today Event" in summaries
153- assert "Tomorrow Event" in summaries
154- assert "Next Week Event" not in summaries
163+ assert "Day 0 Event" in summaries
164+ assert "Day +1 Event" in summaries
165+ assert "Day +7 Event" not in summaries
155166 finally :
156167 calendar .delete ()
157168
0 commit comments