Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions commands2/commandscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@
for subsystem in subsystems:
self._subsystems.pop(subsystem, None)

def getAllSubsystems(self) -> tuple[Subsystem, ...]:
"""
Gets all registered subsystems as an immutable tuple.
"""
return tuple(self._subsystems.keys())

def unregisterAllSubsystems(self):
"""
Un-registers all registered Subsystems with the scheduler. All currently registered subsystems
Expand Down Expand Up @@ -653,5 +659,5 @@
self.cancel(cancelCmd)

builder.addIntegerArrayProperty(
"Cancel", lambda: [], lambda to_cancel: cancel_commands(to_cancel)

Check failure on line 662 in commands2/commandscheduler.py

View workflow job for this annotation

GitHub Actions / check-mypy

Argument 1 to "cancel_commands" has incompatible type "list[SupportsInt]"; expected "list[int]"
)
18 changes: 18 additions & 0 deletions tests/test_command_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,21 @@ def test_notScheduledCancel(scheduler: commands2.CommandScheduler):
command = commands2.Command()

scheduler.cancel(command)

def test_getAllSubystems(scheduler: commands2.CommandScheduler):
sub1 = commands2.Subsystem()
sub1.setName("test123")
sub2 = commands2.Subsystem()
sub2.setName("hey")
start_spying_on(sub1)
start_spying_on(sub2)
scheduler.registerSubsystem(sub1)
scheduler.registerSubsystem(sub2)
sublist = scheduler.getAllSubsystems()
con1 = sublist[0].getName() == "test123"
con2 = sublist[0].getName() == "hey"
assert con1 or con2
if(con1):
assert sublist[1].getName() == "hey"
else:
assert sublist[1].getName() == "test123"
Loading