Skip to content

Commit 1ed37e9

Browse files
committed
Expose schedule filter helper
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 76f2163a-0773-4889-b627-1bd4e5c7bea0
1 parent 231eff2 commit 1ed37e9

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

durabletask/scheduled/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ def list_schedules(self, schedule_query: ScheduleQuery | None = None) -> list[Sc
131131
state = metadata.get_typed_state(ScheduleState)
132132
if state is None or state.schedule_configuration is None:
133133
continue
134-
if not self._matches_filter(state, schedule_query):
134+
if not self.matches_filter(state, schedule_query):
135135
continue
136136
results.append(state.to_description())
137137
return results
138138

139139
@staticmethod
140-
def _matches_filter(state: ScheduleState, schedule_query: ScheduleQuery | None) -> bool:
140+
def matches_filter(state: ScheduleState, schedule_query: ScheduleQuery | None) -> bool:
141141
if schedule_query is None:
142142
return True
143143
if schedule_query.status is not None and state.status != schedule_query.status:
@@ -261,6 +261,6 @@ async def list_schedules(
261261
for metadata in await self._client.get_all_entities(query):
262262
state = metadata.get_typed_state(ScheduleState)
263263
if state is not None and state.schedule_configuration is not None and \
264-
ScheduledTaskClient._matches_filter(state, schedule_query):
264+
ScheduledTaskClient.matches_filter(state, schedule_query):
265265
results.append(state.to_description())
266266
return results

tests/durabletask/scheduled/test_client_filter_and_capability.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,39 @@ def test_naive_bound_does_not_crash_against_aware_created_at(self):
3030
# A naive bound is normalized by ScheduleQuery, so the comparison must
3131
# not raise "can't compare offset-naive and offset-aware".
3232
q = ScheduleQuery(created_from=datetime(2026, 1, 1, 0, 0, 0))
33-
assert ScheduledTaskClient._matches_filter(state, q) is True
33+
assert ScheduledTaskClient.matches_filter(state, q) is True
3434

3535
def test_created_from_is_exclusive(self):
3636
# Bounds match .NET's exclusive semantics: a schedule created exactly at
3737
# the bound is excluded.
3838
boundary = datetime(2026, 1, 1, tzinfo=timezone.utc)
3939
state = _state_created_at(boundary)
4040
q = ScheduleQuery(created_from=boundary)
41-
assert ScheduledTaskClient._matches_filter(state, q) is False
41+
assert ScheduledTaskClient.matches_filter(state, q) is False
4242

4343
def test_created_to_is_exclusive(self):
4444
boundary = datetime(2026, 1, 1, tzinfo=timezone.utc)
4545
state = _state_created_at(boundary)
4646
q = ScheduleQuery(created_to=boundary)
47-
assert ScheduledTaskClient._matches_filter(state, q) is False
47+
assert ScheduledTaskClient.matches_filter(state, q) is False
4848

4949
def test_inside_window_matches(self):
5050
state = _state_created_at(datetime(2026, 1, 15, tzinfo=timezone.utc))
5151
q = ScheduleQuery(
5252
created_from=datetime(2026, 1, 1, tzinfo=timezone.utc),
5353
created_to=datetime(2026, 2, 1, tzinfo=timezone.utc),
5454
)
55-
assert ScheduledTaskClient._matches_filter(state, q) is True
55+
assert ScheduledTaskClient.matches_filter(state, q) is True
5656

5757
def test_outside_window_is_excluded(self):
5858
state = _state_created_at(datetime(2026, 3, 1, tzinfo=timezone.utc))
5959
q = ScheduleQuery(created_to=datetime(2026, 2, 1, tzinfo=timezone.utc))
60-
assert ScheduledTaskClient._matches_filter(state, q) is False
60+
assert ScheduledTaskClient.matches_filter(state, q) is False
6161

6262
def test_status_filter(self):
6363
state = _state_created_at(datetime(2026, 1, 1, tzinfo=timezone.utc))
64-
assert ScheduledTaskClient._matches_filter(state, ScheduleQuery(status=ScheduleStatus.ACTIVE)) is True
65-
assert ScheduledTaskClient._matches_filter(state, ScheduleQuery(status=ScheduleStatus.PAUSED)) is False
64+
assert ScheduledTaskClient.matches_filter(state, ScheduleQuery(status=ScheduleStatus.ACTIVE)) is True
65+
assert ScheduledTaskClient.matches_filter(state, ScheduleQuery(status=ScheduleStatus.PAUSED)) is False
6666

6767

6868
class TestScheduledTasksCapability:

0 commit comments

Comments
 (0)