Exemplo n.º 1
0
 def test_state(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     result = base.state()
     self.assertIsInstance(result, tuple)
     self.assertEqual(len(result), 4)
     self.assertIsInstance(result[0], int)
     self.assertIsInstance(result[1], int)
     self.assertIsInstance(result[2], int)
     self.assertIsInstance(result[3], int)
     self.assertEqual(result[0], 0)
     self.assertEqual(result[1], 0)
     self.assertEqual(result[2], 0)
     self.assertEqual(result[3], 0)
Exemplo n.º 2
0
    def test_run_until_stalled(self):
        motor = Motor(Port.A)

        result = motor.run_until_stalled(100)
        self.assertIsInstance(result, int)
        self.assertEqual(0, result)

        result = motor.run_until_stalled(100, Stop.HOLD)
        self.assertIsInstance(result, int)
        self.assertEqual(0, result)

        result = motor.run_until_stalled(100, Stop.HOLD, 50)
        self.assertIsInstance(result, int)
        self.assertEqual(0, result)
Exemplo n.º 3
0
    def test_constructor(self):
        self.assertRaises(ValueError, Motor, Port.S1)
        self.assertRaises(ValueError, Motor, Port.S2)
        self.assertRaises(ValueError, Motor, Port.S3)
        self.assertRaises(ValueError, Motor, Port.S4)

        try:
            Motor(Port.A)
            Motor(Port.B)
            Motor(Port.C)
            Motor(Port.D)
        except:
            self.fail()

        try:
            Motor(Port.A, Direction.COUNTERCLOCKWISE, [1, 2])
            Motor(Port.A, Direction.COUNTERCLOCKWISE, [[1, 2], [2, 4]])
        except:
            self.fail()
Exemplo n.º 4
0
 def test_drive(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.drive(0, 0))
Exemplo n.º 5
0
 def test_stop(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.stop())
Exemplo n.º 6
0
 def test_turn(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.turn(0))
Exemplo n.º 7
0
 def test_settings_no_return(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.settings(0))
     self.assertIsNone(base.settings(0, 0))
     self.assertIsNone(base.settings(0, 0, 0))
     self.assertIsNone(base.settings(0, 0, 0, 0))
Exemplo n.º 8
0
 def test_track_target(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.track_target(100))
Exemplo n.º 9
0
 def test_controls(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsInstance(base.distance_control, Control)
     self.assertIsInstance(base.heading_control, Control)
Exemplo n.º 10
0
 def test_constructor(self):
     try:
         DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     except:
         self.fail()
Exemplo n.º 11
0
 def test_brake(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.brake())
Exemplo n.º 12
0
 def test_run_target(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.run_target(100, 100))
     self.assertIsNone(motor.run_target(100, 100, Stop.HOLD))
     self.assertIsNone(motor.run_target(100, 100, Stop.HOLD, False))
Exemplo n.º 13
0
 def test_reset_angle(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.reset_angle(100))
Exemplo n.º 14
0
 def test_run_angle(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.run_angle(100, 100))
     self.assertIsNone(motor.run_angle(100, 100, Stop.COAST))
     self.assertIsNone(motor.run_angle(100, 100, Stop.COAST, False))
Exemplo n.º 15
0
 def test_run(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.run(100))
Exemplo n.º 16
0
 def test_hold(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.hold())
Exemplo n.º 17
0
 def test_angle(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     result = base.angle()
     self.assertIsInstance(result, int)
     self.assertEqual(result, 0)
Exemplo n.º 18
0
 def test_angle(self):
     motor = Motor(Port.A)
     result = motor.angle()
     self.assertIsInstance(result, int)
     self.assertEqual(0, result)
Exemplo n.º 19
0
 def test_dc(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.dc(100))
Exemplo n.º 20
0
 def test_stop(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.stop())
Exemplo n.º 21
0
 def test_reset(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.reset())
Exemplo n.º 22
0
 def test_speed(self):
     motor = Motor(Port.A)
     result = motor.speed()
     self.assertIsInstance(result, int)
     self.assertEqual(0, result)