Ejemplo n.º 1
0
    def test_add_robot(self):
        conf = TestRobotState.default_config()
        state = RobotState(conf)

        sidebar = Sidebar(100, 150, 200, 300)
        sidebar_sprite_mock = MagicMock()
        sidebar.init_robot(state.name, state.sensors, state.get_bricks(),
                           [sidebar_sprite_mock])

        self.assertEqual(len(sidebar.robot_info), 1)
Ejemplo n.º 2
0
    def test_setters_getters(self):
        state = RobotState(self.default_config())
        state.setup_pymunk_shapes(1)

        self.assertEqual(len(state.get_shapes()), 4 + 1 + 2 + 1)
        self.assertEqual(
            state.get_sensor((0, 'ev3-ports:in4')).get_ev3type(),
            'ultrasonic_sensor')
        self.assertEqual(state.get_bricks()[0].name, 'brick-left')
        self.assertEqual(len(state.get_sensors()), 1)
        self.assertEqual(state.get_anchor().name, 'brick-left')
        del state.bricks[0]
        self.assertEqual(state.get_anchor(), None)
Ejemplo n.º 3
0
    def test_add_robot_info(self):
        conf = TestRobotState.default_config()
        state = RobotState(conf)

        sidebar = Sidebar(100, 150, 200, 300)
        sidebar_sprite_mock = MagicMock()
        state.values[(0, 'ev3-ports:in4')] = 5
        state.sounds[(0, 'speaker')] = 'test_sound'
        sidebar.init_robot(state.name, state.sensors, state.get_bricks(),
                           [sidebar_sprite_mock])

        sidebar.add_robot_info(state.name, state.values, state.sounds)
        self.assertEqual(
            sidebar.robot_info[state.name][(0, 'ev3-ports:in4')]['value'], 5)
        self.assertEqual(
            sidebar.robot_info[state.name][(0, 'speaker')]['value'],
            'test_sound')