class TestWalkingCapsule(unittest.TestCase): def test_integration(self): data = {} self.connector = Connector(data) self.connector.walking_capsule().start_walking(forward_key=WalkingCapsule.MEDIUM_FORWARD, sidewards_key=WalkingCapsule.FAST_SIDEWARDS_RIGHT) conf = get_config()["Behaviour"]["Common"]["Walking"] self.assertEquals(conf[WalkingCapsule.MEDIUM_FORWARD], data["Walking.Forward"]) self.assertEquals(conf[WalkingCapsule.FAST_SIDEWARDS_RIGHT], data["Walking.Sideward"]) self.assertEquals(True, data["Walking.Active"]) def test_walking_not_active_on_only_zero_keys(self): data = {} self.walking_capsule = WalkingCapsule(data) self.walking_capsule.start_walking() self.assertTrue("Walking.Active" not in data) def test_walking_not_active_on_only_zero_keys_2(self): data = { "Walking.Forward": 3, "Walking.Sideward": 4, "Walking.Angular": 2, "Walking.Active": True } self.walking_capsule = WalkingCapsule(data) self.walking_capsule.stop_walking() self.assertEquals(0, data["Walking.Forward"]) self.assertEquals(0, data["Walking.Sideward"]) self.assertEquals(0, data["Walking.Angular"]) self.assertEquals(False, data["Walking.Active"])
def test_based_on_duty_y_center_for_tracking_is_set_correctly(self): behaviour_mock = mock.MagicMock() confirm = TrackBall() confirm.setup_internals(behaviour_mock, {}) nt = namedtuple("x", "y") nt.x = 0 nt.y = 0 connector = Connector(data={ DATA_KEY_BALL_FOUND: True, DATA_KEY_BALL_INFO: nt, "BallLastSeen": time.time(), "Pose": PyPose(), "Ipc": mock.MagicMock() }) connector.set_duty("Goalie") self.assertEquals("Goalie", connector.get_duty()) confirm.perform(connector) confirm.perform(connector) confirm.perform(connector) confirm.perform(connector) self.assertEqual(get_config()["Behaviour"]["Common"]["Tracking"]["yCenterGoalie"], confirm.b_center_goalie)
def setup_connector(self): smi = SharedMemoryIPC() connector = Connector(data={ DATA_KEY_BALL_FOUND: False, "Pose": smi.get_pose(), "Ipc": smi }) connector.set_duty("Goalie") return connector
def test_set_walking(self): data = {"Walking.Active": False, "Walking.Forward": 0, "Walking.Angular": 0} connector = Connector(data) connector.walking_capsule().start_walking_plain(1, 2) self.assertIs(data["Walking.Forward"], 1) self.assertIs(data["Walking.Angular"], 2) self.assertTrue(data["Walking.Active"]) connector.walking_capsule().stop_walking() self.assertIs(data["Walking.Forward"], 0) self.assertIs(data["Walking.Angular"], 0) self.assertFalse(data["Walking.Active"])
def test_integration(self): data = {} self.connector = Connector(data) self.connector.walking_capsule().start_walking(forward_key=WalkingCapsule.MEDIUM_FORWARD, sidewards_key=WalkingCapsule.FAST_SIDEWARDS_RIGHT) conf = get_config()["Behaviour"]["Common"]["Walking"] self.assertEquals(conf[WalkingCapsule.MEDIUM_FORWARD], data["Walking.Forward"]) self.assertEquals(conf[WalkingCapsule.FAST_SIDEWARDS_RIGHT], data["Walking.Sideward"]) self.assertEquals(True, data["Walking.Active"])
def test_last_seen(self): connector = Connector({"BallLastSeen": 1, "GoalYellowLastSeen": 2, "GoalBlueLastSeen": 3}) self.assertIs(connector.raw_vision_capsule().get_last_seen("Ball"), 1) with self.assertRaises(KeyError): connector.raw_vision_capsule().get_last_seen("Fliegendes Schwein") with self.assertRaises(KeyError): connector.raw_vision_capsule().get_last_seen("")