def setUp(self): """Set up test fixtures, if any.""" mock_input_values = (-1, -1, None) mock_modules = [ SetupModule(*mock_input_values), InputModule(*mock_input_values), OutputModule(*mock_input_values), Button(*mock_input_values), Dial(*mock_input_values), Env(*mock_input_values), Gyro(*mock_input_values), Ir(*mock_input_values), Mic(*mock_input_values), Ultrasonic(*mock_input_values), Display(*mock_input_values), Led(*mock_input_values), Motor(*mock_input_values), Speaker(*mock_input_values), ] self.modi = MODI(nb_modules=len(mock_modules), test=True) self.modi._ser_proc = mock.Mock() self.modi._exe_thrd = mock.Mock() self.modi._modules = mock_modules
def setUp(self): """Set up test fixtures, if any.""" self.conn = MockConn() mock_args = (-1, -1, self.conn) self.gyro = Gyro(*mock_args)
def setUp(self): """Set up test fixtures, if any.""" mock_args = (-1, -1, None) self.gyro = Gyro(*mock_args) self.gyro._get_property = mock.Mock()
class TestGyro(unittest.TestCase): """Tests for 'Gyro' class.""" def setUp(self): """Set up test fixtures, if any.""" mock_args = (-1, -1, None) self.gyro = Gyro(*mock_args) self.gyro._get_property = mock.Mock() def tearDown(self): """Tear down test fixtures, if any.""" del self.gyro def test_get_roll(self): """Test get_roll method.""" self.gyro.get_roll() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.ROLL) def test_get_pitch(self): """Test get_pitch method.""" self.gyro.get_pitch() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.PITCH) def test_get_yaw(self): """Test get_yaw method.""" self.gyro.get_yaw() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.YAW) def test_get_angular_vel_x(self): """Test get_angular_vel_x method.""" self.gyro.get_angular_vel_x() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.ANGULAR_VEL_X) def test_get_angular_vel_y(self): """Test get_angular_vel_y method.""" self.gyro.get_angular_vel_y() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.ANGULAR_VEL_Y) def test_get_angular_vel_z(self): """Test get_angular_vel_z method.""" self.gyro.get_angular_vel_z() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.ANGULAR_VEL_Z) def test_get_acceleration_x(self): """Test get_acceleration_x method.""" self.gyro.get_acceleration_x() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.ACCELERATION_X) def test_get_acceleration_y(self): """Test get_acceleration_x method.""" self.gyro.get_acceleration_y() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.ACCELERATION_Y) def test_get_acceleration_z(self): """Test get_acceleration_z method.""" self.gyro.get_acceleration_z() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.ACCELERATION_Z) def test_get_vibration(self): """Test get_vibration method.""" self.gyro.get_vibration() self.gyro._get_property.assert_called_once_with( self.gyro.PropertyType.VIBRATION)
def setUp(self): """Set up test fixtures, if any.""" self.send_q = Queue() mock_args = (-1, -1, self.send_q) self.gyro = Gyro(*mock_args)
def test_get_vibration(self): """Test get_vibration method.""" _ = self.gyro.vibration self.assertEqual( self.send_q.get(), Gyro.request_property(-1, Gyro.PropertyType.VIBRATION))
def test_get_acceleration_z(self): """Test get_acceleration_z method.""" _ = self.gyro.acceleration_z self.assertEqual( self.send_q.get(), Gyro.request_property(-1, Gyro.PropertyType.ACCELERATION_Z))
def test_get_angular_vel_z(self): """Test get_angular_vel_z method.""" _ = self.gyro.angular_vel_z self.assertEqual( self.send_q.get(), Gyro.request_property(-1, Gyro.PropertyType.ANGULAR_VEL_Z))
def test_get_yaw(self): """Test get_yaw method.""" _ = self.gyro.yaw self.assertEqual(self.send_q.get(), Gyro.request_property(-1, Gyro.PropertyType.YAW))
def test_get_pitch(self): """Test get_pitch method.""" _ = self.gyro.pitch self.assertEqual(self.send_q.get(), Gyro.request_property(-1, Gyro.PropertyType.PITCH))
def test_get_roll(self): """Test get_roll method.""" _ = self.gyro.roll self.assertEqual(self.send_q.get(), Gyro.request_property(-1, Gyro.PropertyType.ROLL))