def setUp(self): buoyData = {vision.Color.YELLOW: vision.BuoyEvent()} BuoyTrackingTest.setUp(self, buoy.Recover, buoy.Recover, buoy.Searching, buoyData=buoyData)
def testBuoyLost(self): """Make sure losing the light goes back to search""" # Put a fake event in the buoyData event = vision.BuoyEvent(-0.5, 0.5, vision.Color.YELLOW) self.ai.data['buoyData'][vision.Color.YELLOW] = event self.injectEvent(vision.EventType.BUOY_LOST, vision.BuoyEvent, color = vision.Color.YELLOW) self.assertCurrentState(buoy.FindAttempt)
def testIncorrectBuoyLost(self): """ Buoy data for incorrect buoys should be deleted, but the state should not be changed """ event = vision.BuoyEvent(0.0, 0.0, vision.Color.RED) self.ai.data['buoyData'][vision.Color.RED] = event self.injectEvent(vision.EventType.BUOY_LOST, vision.BuoyEvent, color = vision.Color.RED) #self.assert_(not self.ai.data['buoyData'].has_key(vision.Color.RED)) self.assertCurrentState(self._myState)
def testBuoyLost(self): """ Buoy data should be deleted and the state should change to the lost state """ # Setup the dictionary as if we had received a found event event = vision.BuoyEvent(0.0, 0.0, vision.Color.YELLOW) self.ai.data['buoyData'][vision.Color.YELLOW] = event self.injectEvent(vision.EventType.BUOY_LOST, vision.BuoyEvent, color = vision.Color.YELLOW) #self.assert_(not self.ai.data['buoyData'].has_key(vision.Color.YELLOW)) self.assertCurrentState(self._lostState)
def testBuoyLost(self): """Make sure losing the light goes back to search""" BuoyTrackingTest.testBuoyLost(self) # Add a lastLightEvent for FindAttempt self.ai.data['buoyData'][vision.Color.YELLOW] = \ vision.BuoyEvent(0, 0, vision.Color.YELLOW) self.injectEvent(vision.EventType.LIGHT_LOST, vision.BuoyEvent, color = vision.Color.YELLOW) self.assertCurrentState(buoy.FindAttemptSeek) # Test that it reenters Seek when it's refound self.injectEvent(vision.EventType.BUOY_FOUND, vision.BuoyEvent, 0, 0, vision.Color.YELLOW) self.assertCurrentState(buoy.Seek)