@@ -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,26 @@ 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 (
139+ hour = 12 , minute = 0 , second = 0 , microsecond = 0
140+ )
130141 calendar .save_event (
131142 dtstart = base ,
132143 dtend = base + datetime .timedelta (hours = 1 ),
133- summary = "Today Event" ,
144+ summary = "Day 0 Event" ,
134145 )
135146 calendar .save_event (
136147 dtstart = base + datetime .timedelta (days = 1 ),
137148 dtend = base + datetime .timedelta (days = 1 , hours = 1 ),
138- summary = "Tomorrow Event" ,
149+ summary = "Day +1 Event" ,
139150 )
140151 calendar .save_event (
141152 dtstart = base + datetime .timedelta (days = 7 ),
142153 dtend = base + datetime .timedelta (days = 7 , hours = 1 ),
143- summary = "Next Week Event" ,
154+ summary = "Day +7 Event" ,
144155 )
145156 assert len (calendar .events ()) == 3
146157
@@ -151,19 +162,19 @@ def test_event_date_range_search(nc):
151162 event = True ,
152163 )
153164 summaries = {str (e .icalendar_component .get ("SUMMARY" )) for e in results }
154- assert "Today Event" in summaries
155- assert "Tomorrow Event" not in summaries
165+ assert "Day 0 Event" in summaries
166+ assert "Day +1 Event" not in summaries
156167
157- # Search for today + tomorrow
168+ # Search for day 0 + day +1
158169 results = calendar .search (
159170 start = base - datetime .timedelta (hours = 1 ),
160171 end = base + datetime .timedelta (days = 1 , hours = 2 ),
161172 event = True ,
162173 )
163174 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
175+ assert "Day 0 Event" in summaries
176+ assert "Day +1 Event" in summaries
177+ assert "Day +7 Event" not in summaries
167178 finally :
168179 calendar .delete ()
169180
0 commit comments