class SetThrustTankTest(unittest.TestCase): def test_SetThrustZero(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 0.23, 0.0, 0.0, 0.0) self.tank.set_thrust_level(0.0) self.assertEqual(self.tank.get_thrust_level(), 0.0) def test_SetThrustPositiveSubOne(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 0.85, 0.0, 0.0, 0.0) self.tank.set_thrust_level(0.23) self.assertEqual(self.tank.get_thrust_level(), 0.23) def test_SetThrustPositiveAboveOne(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 0.85, 0.0, 0.0, 0.0) with self.assertRaises(ValueError): self.tank.set_thrust_level(1.23) def test_SetThrustNegative(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 0.85, 0.0, 0.0, 0.0) with self.assertRaises(ValueError): self.tank.set_thrust_level(-0.23) def test_SetThrustFalseNonZero(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 0.85, 0.0, 0.0, 0.0) self.tank.set_thrust_level(0.75) self.assertNotEqual(self.tank.get_thrust_level(), 0.85)
class GetMassChangeTest(unittest.TestCase): def test_GetMassChangeZero(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) self.assertEqual(self.tank.get_mass_change(), 0.0) def test_GetMassChangePositive(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 230.0, 0.0, 0.0, 0.0) self.assertEqual(self.tank.get_mass_change(), 230.0) def test_GetMassChangePositiveReducedThrustLevel(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 230.0, 0.0, 0.0, 0.0) self.tank.set_thrust_level(0.5) self.assertEqual(self.tank.get_mass_change(), 230.0 * 0.5) def test_GetMassChangeNegative(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 230.0, 0.0, 0.0, 0.0) self.tank.thrust_level_tank = -0.5 with self.assertRaises(ValueError): self.tank.get_mass_change()