@@ -26,9 +26,13 @@ def test_create_delete(nc):
2626 calendars = principal .calendars ()
2727 assert calendars
2828 all_events_before = calendar .events ()
29+ # Use a past date so the event isn't picked up by Nextcloud's
30+ # calendar-status automation (which scans events in [now, now+5m]
31+ # and caches the result for 5 minutes, breaking user_status tests).
32+ past = datetime .datetime .now () - datetime .timedelta (days = 400 )
2933 event = calendar .save_event (
30- dtstart = datetime . datetime . now () ,
31- dtend = datetime . datetime . now () + datetime .timedelta (hours = 1 ),
34+ dtstart = past ,
35+ dtend = past + datetime .timedelta (hours = 1 ),
3236 summary = "NcPyApi + CalDAV test" ,
3337 )
3438 all_events_after = calendar .events ()
@@ -83,7 +87,9 @@ def test_event_full_lifecycle(nc):
8387 calendar = principal .make_calendar ("test_ncpyapi_ops" )
8488 try :
8589 # --- Event lifecycle ---
86- now = datetime .datetime .now ()
90+ # Use a past anchor so these events don't trigger Nextcloud's
91+ # calendar-status automation (see test_create_delete for details).
92+ now = datetime .datetime .now () - datetime .timedelta (days = 400 )
8793 calendar .save_event (
8894 dtstart = now ,
8995 dtend = now + datetime .timedelta (hours = 2 ),
@@ -126,21 +132,24 @@ def test_event_date_range_search(nc):
126132 principal = nc .cal .principal ()
127133 calendar = principal .make_calendar ("test_ncpyapi_search" )
128134 try :
129- base = datetime .datetime .now ().replace (hour = 12 , minute = 0 , second = 0 , microsecond = 0 )
135+ # Anchor the search range in the past so none of these events fall
136+ # into Nextcloud's calendar-status window ([now, now+5m]); the
137+ # date-range search logic under test doesn't depend on "today".
138+ base = (datetime .datetime .now () - datetime .timedelta (days = 400 )).replace (hour = 12 , minute = 0 , second = 0 , microsecond = 0 )
130139 calendar .save_event (
131140 dtstart = base ,
132141 dtend = base + datetime .timedelta (hours = 1 ),
133- summary = "Today Event" ,
142+ summary = "Day 0 Event" ,
134143 )
135144 calendar .save_event (
136145 dtstart = base + datetime .timedelta (days = 1 ),
137146 dtend = base + datetime .timedelta (days = 1 , hours = 1 ),
138- summary = "Tomorrow Event" ,
147+ summary = "Day +1 Event" ,
139148 )
140149 calendar .save_event (
141150 dtstart = base + datetime .timedelta (days = 7 ),
142151 dtend = base + datetime .timedelta (days = 7 , hours = 1 ),
143- summary = "Next Week Event" ,
152+ summary = "Day +7 Event" ,
144153 )
145154 assert len (calendar .events ()) == 3
146155
@@ -151,19 +160,19 @@ def test_event_date_range_search(nc):
151160 event = True ,
152161 )
153162 summaries = {str (e .icalendar_component .get ("SUMMARY" )) for e in results }
154- assert "Today Event" in summaries
155- assert "Tomorrow Event" not in summaries
163+ assert "Day 0 Event" in summaries
164+ assert "Day +1 Event" not in summaries
156165
157- # Search for today + tomorrow
166+ # Search for day 0 + day +1
158167 results = calendar .search (
159168 start = base - datetime .timedelta (hours = 1 ),
160169 end = base + datetime .timedelta (days = 1 , hours = 2 ),
161170 event = True ,
162171 )
163172 summaries = {str (e .icalendar_component .get ("SUMMARY" )) for e in results }
164- assert "Today Event" in summaries
165- assert "Tomorrow Event" in summaries
166- assert "Next Week Event" not in summaries
173+ assert "Day 0 Event" in summaries
174+ assert "Day +1 Event" in summaries
175+ assert "Day +7 Event" not in summaries
167176 finally :
168177 calendar .delete ()
169178
0 commit comments