def main(): prefixPort = '/dev/ttyACM' for j in range(0, 20): try: port = prefixPort + str(j) monUART = UARTDriver(port, 115200) robot = Robot(monUART) robot.start() break except Exception as e: print e
class TestRobot(TestCase): def setUp(self): uartDriver = Mock(spec=UARTDriver) self.robot = Robot(uartDriver) def test_demarrerAlignementIle(self): self.robot.demarrerAlignementIle = MagicMock() self.robot.traiterCommande('alignement_ile', 0) self.assertTrue(self.robot.demarrerAlignementIle.called) def test_demarrerAlignementStation(self): self.robot.demarrerAlignementStation = MagicMock() self.robot.traiterCommande('alignement_station', 0) self.assertTrue(self.robot.demarrerAlignementStation.called) def test_demarrerAlignementTresor(self): self.robot.demarrerAlignementTresor = MagicMock() self.robot.traiterCommande('alignement_tresor', 0) self.assertTrue(self.robot.demarrerAlignementTresor.called)
def setUp(self): uartDriver = Mock(spec=UARTDriver) self.robot = Robot(uartDriver)