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)
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)
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()
def test_drive(self): base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0) self.assertIsNone(base.drive(0, 0))
def test_stop(self): base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0) self.assertIsNone(base.stop())
def test_turn(self): base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0) self.assertIsNone(base.turn(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))
def test_track_target(self): motor = Motor(Port.A) self.assertIsNone(motor.track_target(100))
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)
def test_constructor(self): try: DriveBase(Motor(Port.A), Motor(Port.B), 0, 0) except: self.fail()
def test_brake(self): motor = Motor(Port.A) self.assertIsNone(motor.brake())
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))
def test_reset_angle(self): motor = Motor(Port.A) self.assertIsNone(motor.reset_angle(100))
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))
def test_run(self): motor = Motor(Port.A) self.assertIsNone(motor.run(100))
def test_hold(self): motor = Motor(Port.A) self.assertIsNone(motor.hold())
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)
def test_angle(self): motor = Motor(Port.A) result = motor.angle() self.assertIsInstance(result, int) self.assertEqual(0, result)
def test_dc(self): motor = Motor(Port.A) self.assertIsNone(motor.dc(100))
def test_stop(self): motor = Motor(Port.A) self.assertIsNone(motor.stop())
def test_reset(self): base = DriveBase(Motor(Port.A), Motor(Port.B), 0, 0) self.assertIsNone(base.reset())
def test_speed(self): motor = Motor(Port.A) result = motor.speed() self.assertIsInstance(result, int) self.assertEqual(0, result)