# Path: navigation/RobotSerialCommandsConverter.py
# class RobotSerialCommandsConverter:
#     MAX_ANGLE = 180
#     MIN_ANGLE = 0
#     MOTOR_COMMAND = 'M:{0}:{1}'
#     LIGHT_COMMAND = 'L:{0}'
#     MESSAGE_TERMINATOR = ';'
#     POWER_LIMITS = {'forward': {'max': 50, 'min': 0}, 'backward': {'max': -50, 'min': 0}}
#     DIRECTION_LIMITS = {'right': 50, 'left': -50}
# 
#     def get_steer_command(self, angle: int, percent_power: int, forward: bool) -> str:
#         direction = self.__get_converted_direction(angle)
#         power = self.__get_converted_power(percent_power, forward)
#         return self.MOTOR_COMMAND.format(direction, power)
# 
#     def get_lights_command(self, state: bool) -> str:
#         literal_state = {True: '1', False: '0'}
#         return self.LIGHT_COMMAND.format(literal_state[state])
# 
#     def __get_converted_power(self, percent_power: int, forward: bool) -> str:
#         power_limits_key = {True: 'forward', False: 'backward'}[forward]
#         return str(MathUtils.remap(
#                 percent_power, 0, 100,
#                 self.POWER_LIMITS[power_limits_key]['min'], self.POWER_LIMITS[power_limits_key]['max']))
# 
#     def __get_converted_direction(self, angle: int) -> int:
#         return MathUtils.remap(angle, self.MIN_ANGLE, self.MAX_ANGLE,
#                                self.DIRECTION_LIMITS['left'], self.DIRECTION_LIMITS['right'])


import unittest
from navigation.RobotSerialCommandsConverter import RobotSerialCommandsConverter



class TestRobotCommands(unittest.TestCase):
    def test_steer(self):
        robot_commands = RobotSerialCommandsConverter()
        self.assertEqual(robot_commands.get_steer_command(0, 0, True), 'M:-50:0')
        self.assertEqual(robot_commands.get_steer_command(180, 50, True), 'M:50:25')
        self.assertEqual(robot_commands.get_steer_command(90, 50, True), 'M:0:25')
        self.assertEqual(robot_commands.get_steer_command(45, 100, True), 'M:-25:50')
        self.assertEqual(robot_commands.get_steer_command(45, 100, False), 'M:-25:-50')

    def test_light(self):

# Path: navigation/RobotSerialCommandsConverter.py
# class RobotSerialCommandsConverter:
#     MAX_ANGLE = 180
#     MIN_ANGLE = 0
#     MOTOR_COMMAND = 'M:{0}:{1}'
#     LIGHT_COMMAND = 'L:{0}'
#     MESSAGE_TERMINATOR = ';'
#     POWER_LIMITS = {'forward': {'max': 50, 'min': 0}, 'backward': {'max': -50, 'min': 0}}
#     DIRECTION_LIMITS = {'right': 50, 'left': -50}
# 
#     def get_steer_command(self, angle: int, percent_power: int, forward: bool) -> str:
#         direction = self.__get_converted_direction(angle)
#         power = self.__get_converted_power(percent_power, forward)
#         return self.MOTOR_COMMAND.format(direction, power)
# 
#     def get_lights_command(self, state: bool) -> str:
#         literal_state = {True: '1', False: '0'}
#         return self.LIGHT_COMMAND.format(literal_state[state])
# 
#     def __get_converted_power(self, percent_power: int, forward: bool) -> str:
#         power_limits_key = {True: 'forward', False: 'backward'}[forward]
#         return str(MathUtils.remap(
#                 percent_power, 0, 100,
#                 self.POWER_LIMITS[power_limits_key]['min'], self.POWER_LIMITS[power_limits_key]['max']))
# 
#     def __get_converted_direction(self, angle: int) -> int:
#         return MathUtils.remap(angle, self.MIN_ANGLE, self.MAX_ANGLE,
#                                self.DIRECTION_LIMITS['left'], self.DIRECTION_LIMITS['right'])


# Path: test/navigation/TestRobotCommands.py
import unittest
from navigation.RobotSerialCommandsConverter import RobotSerialCommandsConverter




class TestRobotCommands(unittest.TestCase):
    def test_steer(self):
        robot_commands = RobotSerialCommandsConverter()
        self.assertEqual(robot_commands.get_steer_command(0, 0, True), 'M:-50:0')
        self.assertEqual(robot_commands.get_steer_command(180, 50, True), 'M:50:25')
        self.assertEqual(robot_commands.get_steer_command(90, 50, True), 'M:0:25')
        self.assertEqual(robot_commands.get_steer_command(45, 100, True), 'M:-25:50')
        self.assertEqual(robot_commands.get_steer_command(45, 100, False), 'M:-25:-50')

    def test_light(self):

        robot_commands = RobotSerialCommandsConverter()