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