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