def test_givenResistanceOf270000_whenGettingColors_thenThirdColorIsYellow( self): resistance = Resistance.round_to_nearest_e12_value(261468.0) *_, third_color = resistance.get_colors() self.assertEqual(third_color, Color.YELLOW)
def take_resistance_measurement(self) -> Resistance: resistance_read = self._ohmmeter.read_resistance() print() print() print(resistance_read) print() print() return Resistance.round_to_nearest_e12_value(resistance_read)
def test_givenResistanceValueOf4437_whenRoundToNearestE12Value_thenReturnClosestE12ValueOf4700( self, ): resistance_read = 4437 expected_resistance = Resistance(4700) actual_resistance = Resistance.round_to_nearest_e12_value( resistance_read) self.assertEqual(expected_resistance, actual_resistance)
def test_givenResistanceValueOf50_whenRoundToNearestE12Value_thenThrowInvalidResistanceException( self, ): resistance_read = 50 rounding_to_nearest_e12_value = ( lambda resistance: Resistance.round_to_nearest_e12_value(resistance )) with self.assertRaises(InvalidResistanceException): rounding_to_nearest_e12_value(resistance_read)