Esempio 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)
Esempio 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)
Esempio 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()
Esempio n. 4
0
 def test_drive(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.drive(0, 0))
Esempio n. 5
0
 def test_stop(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.stop())
Esempio n. 6
0
 def test_turn(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.turn(0))
Esempio 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))
Esempio n. 8
0
 def test_track_target(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.track_target(100))
Esempio 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)
Esempio n. 10
0
 def test_constructor(self):
     try:
         DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     except:
         self.fail()
Esempio n. 11
0
 def test_brake(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.brake())
Esempio 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))
Esempio n. 13
0
 def test_reset_angle(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.reset_angle(100))
Esempio 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))
Esempio n. 15
0
 def test_run(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.run(100))
Esempio n. 16
0
 def test_hold(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.hold())
Esempio 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)
Esempio n. 18
0
 def test_angle(self):
     motor = Motor(Port.A)
     result = motor.angle()
     self.assertIsInstance(result, int)
     self.assertEqual(0, result)
Esempio n. 19
0
 def test_dc(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.dc(100))
Esempio n. 20
0
 def test_stop(self):
     motor = Motor(Port.A)
     self.assertIsNone(motor.stop())
Esempio n. 21
0
 def test_reset(self):
     base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0)
     self.assertIsNone(base.reset())
Esempio n. 22
0
 def test_speed(self):
     motor = Motor(Port.A)
     result = motor.speed()
     self.assertIsInstance(result, int)
     self.assertEqual(0, result)