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 GetThrustLevelTankTest(unittest.TestCase): def test_GetThrustLevelZero(self): self.tank = Tank(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) self.tank.thrust_level_tank = 0.0 self.assertEqual(self.tank.get_thrust_level(), 0.0) def test_GetThrustLevelPositiveSubZero(self): self.tank = Tank(15.0, 2341.2, 94830.1, 0.23, 0.23, 1002.2, 0.0, 0.0) self.tank.thrust_level_tank = 0.23 self.assertEqual(self.tank.get_thrust_level(), 0.23) def test_GetThrustLevelPositiveAboveZero(self): self.tank = Tank(15.0, 2341.2, 94830.1, 0.23, 0.23, 1002.2, 0.0, 0.0) self.tank.thrust_level_tank = 1.23 with self.assertRaises(ValueError): self.tank.get_thrust_level() def test_GetThrustLevelNegative(self): self.tank = Tank(15.0, 2341.2, 94830.1, 0.23, 0.23, 1002.2, 0.0, 0.0) self.tank.thrust_level_tank = -10003.2 with self.assertRaises(ValueError): self.tank.get_thrust_level() def test_GetThrustLevelFalseNonZero(self): self.tank = Tank(15.0, 2341.2, 94830.1, 0.23, 0.23, 1002.2, 0.0, 0.0) self.assertNotEqual(self.tank.get_thrust_level, 0.23)