Пример #1
0
    def test_format_temperature_4(self):
        current_mode = TemperatureUnit.CELCIUS
        store_mode = TemperatureUnit.CELCIUS

        self.assertEqual(
            0, Temperature.format_temperature(0, store_mode, current_mode))
        self.assertEqual(
            40, Temperature.format_temperature(40, store_mode, current_mode))
Пример #2
0
    def test_format_temperature_3(self):
        current_mode = TemperatureUnit.FAHRENHEIT
        store_mode = TemperatureUnit.FAHRENHEIT

        self.assertEqual(
            0, Temperature.format_temperature(0, store_mode, current_mode))
        self.assertEqual(
            40, Temperature.format_temperature(40, store_mode, current_mode))
Пример #3
0
 def test_format_temperature_1(self):
     store_mode = TemperatureUnit.CELCIUS
     current_mode = TemperatureUnit.FAHRENHEIT
     self.assertEqual(
         0, Temperature.format_temperature(32, store_mode, current_mode))
     self.assertEqual(
         40, Temperature.format_temperature(104, store_mode, current_mode))
     self.assertEqual(
         -50, Temperature.format_temperature(-58, store_mode, current_mode))
Пример #4
0
    def test_format_temperature_2(self):
        current_mode = TemperatureUnit.CELCIUS
        store_mode = TemperatureUnit.FAHRENHEIT

        self.assertEqual(
            32, Temperature.format_temperature(0, store_mode, current_mode))
        self.assertEqual(
            104, Temperature.format_temperature(40, store_mode, current_mode))
        self.assertEqual(
            -58, Temperature.format_temperature(-50, store_mode, current_mode))
Пример #5
0
    def test_init(self):
        name = 'test1'
        thresh_val = randrange(0, 10)
        threshold_1 = Threshold(name, thresh_val)

        self.assertEqual(threshold_1.name, name)
        self.assertEqual(threshold_1.thresh_val_c, thresh_val)
        self.assertEqual(threshold_1.thresh_val_f,
                         Temperature.convert_celcius_to_fahrenheit(thresh_val))
        self.assertEqual(threshold_1.direction, Direction.ANY)
        self.assertFalse(threshold_1.reached)
Пример #6
0
    def test_init_2(self):
        name = 'test1'
        thresh_val = randrange(0, 10)
        direction = Direction.GREATER
        unit = TemperatureUnit.FAHRENHEIT
        threshold_1 = Threshold(name, thresh_val, unit, direction)

        self.assertEqual(threshold_1.name, name)
        self.assertEqual(threshold_1.thresh_val_f, thresh_val)
        self.assertEqual(threshold_1.thresh_val_c,
                         Temperature.convert_fahrenheit_to_celcius(thresh_val))
        self.assertEqual(threshold_1.direction, direction)
        self.assertFalse(threshold_1.reached)
Пример #7
0
 def test_convert_celcius_to_fahrenheit(self):
     self.assertEqual(32, Temperature.convert_celcius_to_fahrenheit(0))
     self.assertEqual(104, Temperature.convert_celcius_to_fahrenheit(40))
     self.assertEqual(-58, Temperature.convert_celcius_to_fahrenheit(-50))
Пример #8
0
 def test_convert_fahrenheit_to_celcius(self):
     self.assertEqual(0, Temperature.convert_fahrenheit_to_celcius(32))
     self.assertEqual(40, Temperature.convert_fahrenheit_to_celcius(104))
     self.assertEqual(-50, Temperature.convert_fahrenheit_to_celcius(-58))