def testCreate(self): stateMachine = ai.state.Machine({'name': 'MyMachine'}) deps = core.SubsystemList() deps.append(core.Subsystem('A', core.SubsystemList())) deps.append(core.Subsystem('B', core.SubsystemList())) deps.append(ai.state.Machine()) deps.append(core.Subsystem('C', core.SubsystemList())) deps.append(stateMachine) aiSys = ai.subsystem.AI({'AIMachineName': 'MyMachine'}, deps) # Make sure it finds the AI with a custom name self.assertEqual(stateMachine, aiSys.mainStateMachine)
def testVirtualMethods(self): subsystem = core.Subsystem('Test') # None of these methods should throw subsystem.background(20) self.assertEquals(False, subsystem.backgrounded()) subsystem.unbackground(True) subsystem.update(0.1)
def testGetSubsystemOfExactType(self): a = core.Subsystem('Bob') b = SubsystemD('John') deps = [a, b] # Empty List core.Subsystem.getSubsystemOfExactType(SubsystemD, []) self.assertRaises(Exception, core.Subsystem.getSubsystemOfExactType, SubsystemD, [], nonNone=True) # Actual List subsystem = core.Subsystem.getSubsystemOfExactType(SubsystemD, deps) self.assertEquals(b, subsystem) subsystem = core.Subsystem.getSubsystemOfExactType( core.Subsystem, deps) self.assertEquals(a, subsystem)
def testGetSubsystemOfType(self): a = core.Subsystem('Bob') b = SubsystemD('John') deps = [b, a] # Empty List core.Subsystem.getSubsystemOfType(SubsystemD, []) self.assertRaises(Exception, core.Subsystem.getSubsystemOfType, SubsystemD, [], nonNone=True) # Actual List subsystem = core.Subsystem.getSubsystemOfType(SubsystemD, deps) self.assertEquals(b, subsystem) # Note how we get a 'b' where, which is really of type SubsystemD subsystem = core.Subsystem.getSubsystemOfType(core.Subsystem, deps) self.assertEquals(b, subsystem)