def test_F2K_exceptions(self):
     print(TestConversions.test_F2C_exceptions.__name__)
     print("Exception Tests: Raise typeError if int")
     with self.assertRaises(TypeError) as context:
         conversions.convertFahrenheitToKelvin(300)
     print("Exception Tests: Raise typeError if str")
     with self.assertRaises(TypeError) as context:
         conversions.convertFahrenheitToKelvin('a')
     print("\n")
Beispiel #2
0
    def test_convertFahrenheitToKelvin_when_exception_raised(self):

        print('test_convertFahrenheitToKelvin_when_exception_raised')

        # :given
        fahrenheit = 'someString'

        # :when
        with self.assertRaises(TypeError):
            conversions.convertFahrenheitToKelvin(self, fahrenheit)
 def test_convertFahrenheitToKelvin(self):
     self.assertEqual(conversions.convertFahrenheitToKelvin(110), 316.48)
     print("Test passed! 30F is equal to 272.04K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(-20), 244.26)
     print("Test passed! -20F is equal to 244.26K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(1000), 810.93)
     print("Test passed! 1000F is equal to 810.93K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(-459.67), 0)
     print("Test passed! -459.67F is equal to 0K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(100), 310.93)
     print("Test passed! 100F is equal to 310.93K")
Beispiel #4
0
 def test_convertFahrenheitToKelvin(self):
     self.assertEqual(conversions.convertFahrenheitToKelvin(110), 316.48)
     print("Test is Successful! 30F = 272.04K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(-20), 244.26)
     print("Test is Successful! -20F = 244.26K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(1000), 810.93)
     print("Test is Successful! 1000F = 810.93K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(-459.67), 0)
     print("Test is Successful! -459.67F = 0K")
     self.assertEqual(conversions.convertFahrenheitToKelvin(100), 310.93)
     print("Test is Successful! 100F = 310.93K")
 def test_F2K_good_values(self):
     print(TestConversions.test_F2K_good_values.__name__)
     print('Good Tests: 0.0 to 255.3722222222222')
     result = conversions.convertFahrenheitToKelvin(0.0)
     self.assertEqual(result, 255.3722222222222)
     print('Good Tests: -10.0 to 249.81666666666666')
     result = conversions.convertFahrenheitToKelvin(-10.0)
     self.assertEqual(result, 249.81666666666666)
     print('Good Tests: 300.0 to 422.03888888888895')
     result = conversions.convertFahrenheitToKelvin(300.0)
     self.assertEqual(result, 422.03888888888895)
Beispiel #6
0
 def testConversionFahrenheitToKelvin(self):
     for celsius, fahrenheit, kelvin in conversionInfo.conversiontable:
         print(
             'Validating {} degrees Fahrenheit converts to {} degrees Kelvin'
             .format(fahrenheit, kelvin))
         result = conversions.convertFahrenheitToKelvin(fahrenheit)
         self.assertEqual(kelvin, round(result, 2))
Beispiel #7
0
 def testConvertFahrenheitToKelvin(self):
     """convertFahrenheitToKelvin should give known result with known
         input.
     """
     for fahrenheit, kelvin in self.knownFahrenheitToKelvinValues:
         result = conversions.convertFahrenheitToKelvin(fahrenheit)
         self.assertEqual(kelvin, result)
Beispiel #8
0
def convert(fromUnit, toUnit, value):
    """Convert fromUnit value to toUnit."""

    if fromUnit == 'Fahrenheit':
        if toUnit == 'Celcius':
            return float(conversions.convertFahrenheitToCelcius(value))
        elif toUnit == 'Kelvin':
            return float(conversions.convertFahrenheitToKelvin(value))
        else:
            raise ConversionError('{} cannot be converted to {}'.format(fromUnit, toUnit))

    elif fromUnit == 'Celcius':
        if toUnit == 'Fahrenheit':
            return float(conversions.convertCelciusToFahrenheit(value))
        elif toUnit == 'Kelvin':
            return float(conversions.convertCelciusToKelvin(value))
        else:
            raise ConversionError('{} cannot be converted to {}'.format(fromUnit, toUnit))

    elif fromUnit == 'Kelvin':
        if toUnit == 'Fahrenheit':
            return float(conversions.convertKelvinToFahrenheit(value))
        elif toUnit == 'Celcius':
            return float(conversions.convertKelvinToCelcius(value))

    else:
        raise ConversionNotPossible('Cannot perform conversions')
 def test_kelvin_fahrenheit_table(self):
     """if true will give known result with known input, if false will give known give in backwards order"""
     for kelvin, fahrenheit in self.k_to_f_known_values:
         result = conversions.convertKelvinToFahrenheit(kelvin)
         self.assertEqual(fahrenheit, result)
     for kelvin, fahrenheit in self.k_to_f_known_values:
         result = conversions.convertFahrenheitToKelvin(fahrenheit)
         self.assertEqual(kelvin, result)
Beispiel #10
0
 def test_convertFahrenheitToKelvin(self):
     fahrenheit = 300
     expected = 422.04
     actual = conversions.convertFahrenheitToKelvin(fahrenheit)
     self.assertAlmostEqual(expected,
                            actual,
                            places=2,
                            msg="Fahrenheit to Kelvin conversion failed")
Beispiel #11
0
 def test_convertFahrenheitToKelvin(self):
     fahrenheit = 300
     expected = 422.04
     actual = conversions.convertFahrenheitToKelvin(fahrenheit)
     self.assertAlmostEqual(expected,
                            actual,
                            places=2,
                            msg=msg.format("Fahrenheit", "Kelvin"))
Beispiel #12
0
 def testFtoK(self):
     """tests that convertFahrenheitToKelvin returns the correct values"""
     print 'tests that convertFahrenheitToKelvin returns the correct values'
     for integer, numeral in self.ftokvalues:
         result = conversions.convertFahrenheitToKelvin(integer)
         self.assertEqual(numeral,
                          result,
                          msg='Incorrect result, calculation error')
Beispiel #13
0
	def testFahrenheittoKelvin(self):
		"""fahrenheit/kelvin values should match"""
		for i in range(len(self.fahrenheit)):
			testedKelvin = conversions.convertFahrenheitToKelvin(
				self.fahrenheit[i])
			self.assertEqual(self.kelvin[i],testedKelvin,msg=
				'{}K != {}K'.format(
					testedKelvin,self.kelvin[i]))
Beispiel #14
0
 def test_fahrenheitToKelvin(self):
     for x in self.test_temp:
         kelvin = (x + 459.67) * 5 / 9
         self.assertEqual(conversions.convertFahrenheitToKelvin(x),
                          kelvin)  #compare equal
         print(
             'Temperature conversion fahrenheit to kelvin is %s F is %s K' %
             (x, round(kelvin, 2)))
Beispiel #15
0
    def testFTOK(self):

        print 'tests that convertFahrenheitToKelvin returns the values that are correct'
        for integer, numeral in self.FTOKVALUES:
            result = conversions.convertFahrenheitToKelvin(integer)
            self.assertEqual(numeral,
                             result,
                             msg='Incorrect result, calculation error')
Beispiel #16
0
    def testConvertFahrenheitToKelvin(self):
        print "\nNow testing convertFahrenheitToKelvin function:"

        # Iterate through the known values list
        for i in range(0,len(self.knownValues)):
            result = conversions.convertFahrenheitToKelvin(self.knownValues[i][2]) # result of the conversion from fahrenheit to kelvin
            kelvin = self.knownValues[i][1]
            self.assertEqual(kelvin, result) # comparing if the values are equal
            print "   testing fahrenheit = %f; %f = %f; Passed" % (self.knownValues[i][2], kelvin, result)
Beispiel #17
0
 def test_convertFahrenheitToKelvin(self):
     """
     convertFahrenheitToKelvin should give known results
     with known input
     """
     for celsius, fahrenheit, kelvin in self.known_values:
         result = round(conversions.convertFahrenheitToKelvin(fahrenheit),
                        2)
         self.assertEqual(kelvin, result)
 def testFahrenheitToKelvin(self):
     for val in self.knownvals:
         f = val[1]
         k = val[2]
         expect = conversions.convertFahrenheitToKelvin(f)
         self.assertEqual(expect,
                          k,
                          msg=('{} degrees K '
                               'is not equal to {}'
                               ' degrees K.').format(f, k))
Beispiel #19
0
    def testConvertFahrenheitToKelvin(self):
        print "\nNow testing convertFahrenheitToKelvin function:"

        for i in range(0, len(self.knownValues)):
            result = conversions.convertFahrenheitToKelvin(
                self.knownValues[i][2])
            kelvin = self.knownValues[i][1]
            self.assertEqual(kelvin, result)
            print "   testing fahrenheit = %f; %f = %f; Passed" % (
                self.knownValues[i][2], kelvin, result)
 def testConvertFahrenheitToKelvin(self):
     for val in self.valid_conversions:
         from_val = val[1]
         expected_val = val[2]
         returned_val = conv.convertFahrenheitToKelvin(from_val)
         self.assertEqual(
             returned_val,
             expected_val,
             msg=('{} Kelvin is not equal to expected value of {} Kelvin.'
                  ).format(returned_val, expected_val))
Beispiel #21
0
 def testFahrenheitToKelvin(self):
     """Unit test for converting degress Fahrenheit to degrees Kelvin."""
     for deg in self.degrees:
         fah = deg[0]
         kel = deg[2]
         expect = conversions.convertFahrenheitToKelvin(fah)
         self.assertEqual(expect,
                          kel,
                          msg=('{} degrees Fahrenheit '
                               'is not equal to {}'
                               ' degrees Kelvin.').format(fah, kel))
Beispiel #22
0
 def testFahrenheitToKelvin(self):
     """Tests that the convertFahrenheitToKelvin function returns the
     correct value.
     """
     for val in self.knownvals:
         f = val[1]
         k = val[2]
         expect = conversions.convertFahrenheitToKelvin(f)
         self.assertEqual(expect, k, msg=('{} degrees K '
                                          'is not equal to {}'
                                          ' degrees K.').format(f, k))
Beispiel #23
0
    def test_convertFahrenheitToKelvin_when_fahrenheit_is_negative(self):

        print('test_convertFahrenheitToKelvin_when_fahrenheit_is_negative')
        # :given
        fahrenheit = -30

        # :when
        expected = 238.71
        actual = conversions.convertFahrenheitToKelvin(self, fahrenheit)

        # :then
        self.assertEqual(expected, actual)
Beispiel #24
0
    def test_convertFahrenheitToKelvin_when_fahrenheit_is_0(self):
        print('test_convertFahrenheitToKelvin_when_fahrenheit_is_0')

        # :given
        fahrenheit = 0

        # :when
        expected = 255.37
        actual = conversions.convertFahrenheitToKelvin(self, fahrenheit)

        # :then
        self.assertEqual(expected, actual)
Beispiel #25
0
 def testConvertFahrenheitToKelvin(self):
     """Tests that convertFahrenheitToKelvin returns the expected value."""
     for val in self.known_values:
         from_val = val[1]
         expected_val = val[2]
         returned_val = c.convertFahrenheitToKelvin(from_val)
         self.assertEqual(returned_val,
                         expected_val,
                         msg=(
                                 '{}º Kelvin is not equal to expected value'
                                 ' of {}º Kelvin.') \
                                     .format(returned_val, expected_val)
                             )
Beispiel #26
0
 def test_convertFahrenheitToKelvin(self):
     cases = {
         32: 273.15,
         0: 255.37,
         50: 283.15,
         100: 310.93,
         123: 323.71,
     }
     for input, output in cases.iteritems():
         print "input (F):", input, "expected output (K):", output
         self.assertAlmostEqual(convertFahrenheitToKelvin(input), output, 2)
         self.assertAlmostEqual(convert("fahrenheit", "kelvin", input),
                                output, 2)
Beispiel #27
0
    def test_convertFahrenheitToKelvin_when_fraction(self):

        print('test_convertFahrenheitToKelvin_when_fraction')

        # :given
        fahrenheit = 33.21

        # :when
        expected = 273.82
        actual = conversions.convertFahrenheitToKelvin(self, fahrenheit)

        # :then
        self.assertEqual(expected, actual)
Beispiel #28
0
    def testConvertFahrenheitToKelvin(self):
        print(
            "\n\n\nNow testing the conversion from Fahrenheit to Kelvin using the function convertFahrenheitToKelvin() from conversions.py:\n"
        )

        for i in range(0, len(self.knownValues)):
            conversion = conversions.convertFahrenheitToKelvin(
                self.knownValues[i][1])
            kelvin = self.knownValues[i][2]
            self.assertEqual(kelvin, conversion)
            print(
                "     Now testing whether {:.4f}{}F is equal to {:.4f}{}K; After testing, {:.4f}{}F is in fact {:.4f}{}K; This conversion has passed the test."
                .format(self.knownValues[i][1], deg, kelvin, deg,
                        self.knownValues[i][1], deg, conversion, deg))
Beispiel #29
0
 def testConvertFahrenheitToKelvin(self):
     """  Tests Conversion between Fahrenheit to kelvin
     Args:
        None
     Returns:
         Assertion
     """
     print("\nTesting conversion from Fahrenheit to Kelvin.\n")
     for fahr, kelvin in self.knownValuesFahrToKelvin:
         print('Testing {} conversion should be equal to {}').format(
             fahr, kelvin)
         result = conversions.convertFahrenheitToKelvin(fahr)
         print('The result of the conversion: {}\n').format(result)
         self.assertEqual(kelvin, result)
Beispiel #30
0
    def test_refactor_temp_conversion(self):
        for x, y in self.conversion_list:
            if x == 'celsius' and y == 'kelvin':
                conversion_value = conversions.convertCelsiusToKelvin(
                    self.refactor_temp)
                reconversion_value = conversions_refactored.convert(
                    'celsius', 'kelvin', self.refactor_temp)
                self.assertEqual(conversion_value,
                                 reconversion_value)  # compare equal
            elif x == 'celsius' and y == 'fahrenheit':
                conversion_value = conversions.convertCelsiusToFahrenheit(
                    self.refactor_temp)
                reconversion_value = conversions_refactored.convert(
                    'celsius', 'fahrenheit', self.refactor_temp)
                self.assertEqual(conversion_value,
                                 reconversion_value)  # compare equal
            elif x == 'fahrenheit' and y == 'celsius':
                conversion_value = conversions.convertFahrenheitToCelsius(
                    self.refactor_temp)
                reconversion_value = conversions_refactored.convert(
                    'fahrenheit', 'celsius', self.refactor_temp)
                self.assertEqual(conversion_value,
                                 reconversion_value)  # compare !equal
            elif x == 'fahrenheit' and y == 'kelvin':
                conversion_value = conversions.convertFahrenheitToKelvin(
                    self.refactor_temp)
                reconversion_value = conversions_refactored.convert(
                    'fahrenheit', 'kelvin', self.refactor_temp)
                self.assertEqual(conversion_value,
                                 reconversion_value)  # compare equal
            elif x == 'kelvin' and y == 'fahrenheit':
                conversion_value = conversions.convertKelvinToFahrenheit(
                    self.refactor_temp)
                reconversion_value = conversions_refactored.convert(
                    'kelvin', 'fahrenheit', self.refactor_temp)
                self.assertEqual(conversion_value,
                                 reconversion_value)  # compare equal
            elif x == 'kelvin' and y == 'celsius':
                conversion_value = conversions.convertKelvinToCelsius(
                    self.refactor_temp)
                reconversion_value = conversions_refactored.convert(
                    'kelvin', 'celsius', self.refactor_temp)
                self.assertEqual(conversion_value,
                                 reconversion_value)  # compare equal

            print('Temperature conversion %s to %s is %s %s is %s %s' %
                  (x, y, self.refactor_temp, x[0].upper(),
                   round(reconversion_value, 2), y[0].upper()))
    def test_to_all(self):

        for C, K in self.known_values_C_K:
            result = conversions.convertCelsiusToKelvin(C)
            self.assertAlmostEqual(K, result)
            print('The temperature {0} in Celius is {1} in Kelvim'.format(
                C, result))

        for C, F in self.known_values_C_F:
            result = conversions.convertCelsiusToFahrenheit(C)
            self.assertAlmostEqual(F, result)
            print('The temperature {0} in Celius is {1} in Fahrenheit'.format(
                C, result))

        for F, C in self.known_values_F_C:
            result = conversions.convertFahrenheitToCelsius(F)
            self.assertAlmostEqual(C, result)
            print('The temperature {0} in Fahrenheit is {1} in Celsius'.format(
                F, result))

        for F, K in self.known_values_F_K:
            result = conversions.convertFahrenheitToKelvin(F)
            self.assertAlmostEqual(K, result)
            print('The temperature {0} in Fahrenheit is {1} in Kelvin '.format(
                F, result))

        for K, F in self.known_values_K_F:
            result = conversions.convertKelvinToFahrenheit(K)
            self.assertAlmostEqual(F, result)
            print('The temperature {0} in Kelvin is {1} in Fahrenheit '.format(
                K, result))

        for K, C in self.known_values_K_C:
            result = conversions.convertKelvinToCelsius(K)
            self.assertAlmostEqual(C, result)
            print('The temperature {0} in Kelvin is {1} in Celsius '.format(
                K, result))
Beispiel #32
0
	def testFahrenheitToKelvin_zeroKelvin(self):
		result = conversions.convertFahrenheitToKelvin(-459.67)
		self.assertEqual(0.00, result)
        def testFahrenheittoKelvin(self):

                for i in range(len(self.fah)):
                        kelvin = conversions.convertFahrenheitToKelvin(
                                self.fah[i])
                        self.assertEqual(self.kel[i],kelvin,msg='{}K != {}K'.format(kelvin,self.kel[i]))
Beispiel #34
0
 def negative_value_testing(self):
     self.assertEqual(convertFahrenheitToKelvin(-200.0), 173.15)
Beispiel #35
0
 def positiveValue_testing(self):
     self.assertEqual(convertFahrenheitToKelvin(300.0), 573.15)
Beispiel #36
0
 def test_zero(self):
     "Test for zero input."
     results = conversions.convertFahrenheitToKelvin(0)
     self.assertEqual(255.372, results)
Beispiel #37
0
 def decimal_value_testing(self):
     self.assertEqual(convertFahrenheitToKelvin(200.22), 373.37)
Beispiel #38
0
 def zeroBasedValue_testing(self):
     self.assertEqual(convertFahrenheitToKelvin(0.0), 273.15)
Beispiel #39
0
	def testFahrenheitToKelvin_largeNumber(self):
		result = conversions.convertFahrenheitToKelvin(7599568.73)
		self.assertEqual(4222238.00, result)
Beispiel #40
0
 def test_pos(self):
     "Test for positive input."
     results = conversions.convertFahrenheitToKelvin(300)
     self.assertEqual(422.039, results)
Beispiel #41
0
 def test_non_whole_num(self):
     "Test for non-whole input."
     results = conversions.convertFahrenheitToKelvin(1.005)
     self.assertEquals(255.931, results)
Beispiel #42
0
 def big_value_testing(self):
     self.assertEqual(convertFahrenheitToKelvin(937538), 937938.15)
Beispiel #43
0
	def testFahrenheitToKelvin_default(self):
		result = conversions.convertFahrenheitToKelvin(80.33)
		self.assertEqual(300.00, result)
Beispiel #44
0
	def testFahrenheitToKelvin_decimalValues(self):
		result = conversions.convertFahrenheitToKelvin(89.96)
		self.assertEqual(305.35, result)
Beispiel #45
0
	def testFahrenheitToKelvin_negativeValues(self):
		result = conversions.convertFahrenheitToKelvin(-514.3)
		self.assertEqual(-30.35, result)
Beispiel #46
0
 def test_neg(self):
     "Test for negative input."
     results = conversions.convertFahrenheitToKelvin(-300)
     self.assertEqual(88.706, results)
Beispiel #47
0
 def test_large(self):
     "Test for large input."
     results = conversions.convertFahrenheitToKelvin(567890)
     self.assertEqual(315749.817, results)