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

        print('test_convertKelvinToCelsius_when_exception_raised')

        # :given
        kelvin = 'someString'

        # :when
        with self.assertRaises(TypeError):
            conversions.convertKelvinToCelsius(self, kelvin)
Beispiel #3
0
 def test_convertKelvinToCelsius(self):
     self.assertEqual(conversions.convertKelvinToCelsius(150), -123.15)
     print("Test is Successful! 150K = -123.15C")
     self.assertEqual(conversions.convertKelvinToCelsius(270), -3.15)
     print("Test is Successful! 270K = -3.15C")
     self.assertEqual(conversions.convertKelvinToCelsius(400), 126.85)
     print("Test is Successful! 400K = 126.85C")
     self.assertEqual(conversions.convertKelvinToCelsius(600), 326.85)
     print("Test is Successful! 600K = 326.85C")
     self.assertEqual(conversions.convertKelvinToCelsius(90), -183.15)
     print("Test is Successful! 90K = -183.15C")
 def test_convertKelvinToCelsius(self):
     self.assertEqual(conversions.convertKelvinToCelsius(150), -123.15)
     print("Test passed! 150K is equal to -123.15C")
     self.assertEqual(conversions.convertKelvinToCelsius(270), -3.15)
     print("Test passed! 270K is equal to -3.15C")
     self.assertEqual(conversions.convertKelvinToCelsius(400), 126.85)
     print("Test passed! 400K is equal to 126.85C")
     self.assertEqual(conversions.convertKelvinToCelsius(600), 326.85)
     print("Test passed! 600K is equal to 326.85C")
     self.assertEqual(conversions.convertKelvinToCelsius(90), -183.15)
     print("Test passed! 90K is equal to -183.15C")
 def test_K2C_good_values(self):
     print(TestConversions.test_K2C_good_values.__name__)
     print('Good Tests: 0.0 to -273.15')
     result = conversions.convertKelvinToCelsius(0.0)
     self.assertEqual(result, -273.15)
     print('Good Tests: -10.0 to -283.15')
     result = conversions.convertKelvinToCelsius(-10.0)
     self.assertEqual(result, -283.15)
     print('Good Tests: 300.0 to 26.850000000000023')
     result = conversions.convertKelvinToCelsius(300.0)
     self.assertEqual(result, 26.850000000000023)
Beispiel #6
0
 def testConversionKelvinToCelsius(self):
     for celsius, fahrenheit, kelvin in conversionInfo.conversiontable:
         print(
             'Validating {} degrees Kelvin converts to {} degrees Celsius'.
             format(kelvin, celsius))
         result = conversions.convertKelvinToCelsius(kelvin)
         self.assertEqual(celsius, round(result, 2))
Beispiel #7
0
 def test_kelvinToCelsius(self):
     for x in self.test_temp:
         celsius = x - 273.15
         self.assertEqual(conversions.convertKelvinToCelsius(x),
                          celsius)  #compare equal
         print('Temperature conversion kelvin to celsius is %s K is %s C' %
               (x, round(celsius, 2)))
 def test_kelvin_celsius_table(self):
     """if true will give known result with known input, if false will give known give in backwards order"""
     for kelvin, celsius in self.k_to_c_known_values:
         result = conversions.convertKelvinToCelsius(kelvin)
         self.assertEqual(celsius, result)
     for kelvin, celsius in self.k_to_c_known_values:
         result = conversions.convertCelsiusToKelvin(celsius)
         self.assertEqual(kelvin, result)
Beispiel #9
0
	def testKelvintoCelsius(self):
		"""kelvin/celsius values should match"""
		for i in range(len(self.kelvin)):
			testedCelsius = conversions.convertKelvinToCelsius(
				self.kelvin[i])
			self.assertEqual(self.celsius[i],testedCelsius,msg=
				'{}C != {}C'.format(
					testedCelsius,self.celsius[i]))
Beispiel #10
0
 def test_convertKelvinToCelsius(self):
     """
     convertFahrenheitToCelsius should give known results
     with known input
     """
     for celsius, fahrenheit, kelvin in self.known_values:
         result = round(conversions.convertKelvinToCelsius(kelvin), 2)
         self.assertEqual(celsius, result)
Beispiel #11
0
 def test_convertKelvinToCelsius(self):
     kelvin = 300
     expected = 26.85
     actual = conversions.convertKelvinToCelsius(kelvin)
     self.assertAlmostEqual(expected,
                            actual,
                            places=2,
                            msg=msg.format("Kelvin", "Celsius"))
Beispiel #12
0
 def testKtoC(self):
     """tests that convertKelvinToCelsius returns the correct values"""
     print 'tests that convertKelvinToCelsius returns the correct values'
     for integer, numeral in self.ktocvalues:
         result = conversions.convertKelvinToCelsius(integer)
         self.assertEqual(numeral,
                          result,
                          msg='Incorrect result, calculation error')
Beispiel #13
0
    def test_convertKelvinToCelsius(self):
        kelvin = 300
        expected = 26.85
        actual = conversions.convertKelvinToCelsius(kelvin)

        self.assertAlmostEqual(expected,
                               actual,
                               places=2,
                               msg="Kelvin to Celsius conversion failed")
 def testConvertKelvinToCelsius(self):
     for val in self.valid_conversions:
         from_val = val[2]
         expected_val = val[0]
         returned_val = conv.convertKelvinToCelsius(from_val)
         self.assertEqual(
             returned_val,
             expected_val,
             msg=('{} Celsius is not equal to expected value of {} Celsius.'
                  ).format(returned_val, expected_val))
 def testKelvinToCelsius(self):
     for val in self.knownvals:
         k = val[2]
         c = val[0]
         expect = conversions.convertKelvinToCelsius(k)
         self.assertEqual(expect,
                          c,
                          msg=('{} degrees C '
                               'is not equal to {}'
                               ' degrees C.').format(k, c))
Beispiel #16
0
 def testKelvinToCelsius(self):
     """Unit test for converting degress Kelvin to degrees Celsius."""
     for deg in self.degrees:
         kel = deg[2]
         cel = deg[1]
         expect = conversions.convertKelvinToCelsius(kel)
         self.assertEqual(expect,
                          cel,
                          msg=('{} degrees Kelvin '
                               'is not equal to {}'
                               ' degrees Celsius.').format(kel, cel))
Beispiel #17
0
 def testKelvinToCelsius(self):
     """Tests that the convertKelvinToCelsius function returns the
     correct value.
     """
     for val in self.knownvals:
         k = val[2]
         c = val[0]
         expect = conversions.convertKelvinToCelsius(k)
         self.assertEqual(expect, c, msg=('{} degrees C '
                                          'is not equal to {}'
                                          ' degrees C.').format(k, c))
Beispiel #18
0
    def test_convertKelvinToCelsius_when_fraction(self):

        print('test_convertKelvinToCelsius_when_fraction')
        # :given
        kelvin = 33.21

        # :when
        expected = -239.94
        actual = conversions.convertKelvinToCelsius(self, kelvin)

        # :then
        self.assertEqual(expected, actual)
Beispiel #19
0
    def test_convertKelvinToCelsius_when_celsius_is_positive(self):

        print('test_convertKelvinToCelsius_when_celsius_is_positive')

        # :given
        kelvin = 32

        # :when
        expected = -241.15
        actual = conversions.convertKelvinToCelsius(self, kelvin)

        # :then
        self.assertEqual(expected, actual)
Beispiel #20
0
 def test_convertKelvinToCelsius(self):
     cases = {
         -40: -313.15,
         0: -273.15,
         50: -223.15,
         100: -173.15,
         123: -150.15,
     }
     for input, output in cases.iteritems():
         print "input (K):", input, "expected output (C):", output
         self.assertAlmostEqual(convertKelvinToCelsius(input), output, 2)
         self.assertAlmostEqual(convert("kelvin", "celsius", input), output,
                                2)
Beispiel #21
0
 def testConvertKelvinToCelsius(self):
     print(
         "\n\n\nNow testing the conversion from Kelvin to Celsius using the function convertKelvinToCelsius() from conversions.py:\n"
     )
     for i in range(0, len(self.knownValues)):
         conversion = conversions.convertKelvinToCelsius(
             self.knownValues[i][2])
         celsius = self.knownValues[i][0]
         self.assertEqual(celsius, conversion)
         print(
             "     Now testing whether {:.4f}{}K is equal to {:.4f}{}C; After testing, {:.4f}{}K is in fact {:.4f}{}C; This conversion has passed the test."
             .format(self.knownValues[i][2], deg, celsius, deg,
                     self.knownValues[i][2], deg, conversion, deg))
Beispiel #22
0
 def testConvertKelvinToCelsius(self):
     """Tests that convertKelvinToCelsius returns the expected value."""
     for val in self.known_values:
         from_val = val[2]
         expected_val = val[0]
         returned_val = c.convertKelvinToCelsius(from_val)
         self.assertEqual(returned_val,
                         expected_val,
                         msg=(
                                 '{}º Celsius is not equal to expected value'
                                 ' of {}º Celsius.') \
                                     .format(returned_val, expected_val)
                             )
Beispiel #23
0
 def testConvertKelvinToCelsius(self):
     """  Tests Conversion between Kelvin to Celius
     Args:
        None
     Returns:
         Assertion
     """
     print("\nTesting conversion from Kelvin to Celsius. \n")
     for kelvin, celsius in self.knownValuesKelvinToCels:
         print(('Testing {} convertion should be equal to {}').format(
             kelvin, celsius))
         result = conversions.convertKelvinToCelsius(kelvin)
         print(('The result of the conversion: {}\n').format(result))
         self.assertEqual(celsius, result)
Beispiel #24
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 #26
0
 def test_neg(self):
     "Test for negative input."
     results = conversions.convertKelvinToCelsius(-300)
     self.assertEqual(-573.15, results)
Beispiel #27
0
 def test_non_whole_num(self):
     "Test for non-whole input."
     results = conversions.convertKelvinToCelsius(1.005)
     self.assertEquals(-272.145, results)
Beispiel #28
0
 def test_large(self):
     "Test for large input."
     results = conversions.convertKelvinToCelsius(567890)
     self.assertEqual(567616.85, results)
Beispiel #29
0
 def testConvertKelvinToCelsius(self):
     for celsius, kelvin, fahr in self.knownValuesCKF:
         print 'checking convertKelvinToCelsius', kelvin
         result = conv.convertKelvinToCelsius(kelvin)
         self.assertEqual(celsius, result)
Beispiel #30
0
	def testConvertKelvinToCelsius_zeroCelsius(self):
		result = conversions.convertKelvinToCelsius(273.15)
		self.assertEqual(0.00, result)
Beispiel #31
0
	def testConvertKelvinToCelsius_decimalValues(self):
		result = conversions.convertKelvinToCelsius(273.17)
		self.assertEqual(0.02, result)
Beispiel #32
0
 def testConvertKelvinToCelsius(self):
     result = conversions.convertKelvinToCelsius(200.0)
     self.assertEqual(result, -73.15)
Beispiel #33
0
 def testKtoCValues(self):
     """convertKelvinToCelsius should return the correct C value"""
     for k, c in self.knownValuesKtoC:
         result = conversions.convertKelvinToCelsius(k)
         self.assertEqual(c, result)
Beispiel #34
0
 def test_pos(self):
     "Test for positive input."
     results = conversions.convertKelvinToCelsius(300)
     self.assertEqual(26.85, results)
Beispiel #35
0
 def test_positive(self):
     results = conversions.convertKelvinToCelsius(500)
     self.assertEqual(226.85, results)
Beispiel #36
0
	def testConvertKelvinToCelsius_negativeValues(self):
		result = conversions.convertKelvinToCelsius(-6.85)
		self.assertEqual(-280.00, result)
Beispiel #37
0
	def testConvertKelvinToCelsius_largeNumber(self):
		result = conversions.convertKelvinToCelsius(2345943.15)
		self.assertEqual(2345670, result)
Beispiel #38
0
 def test_zero(self):
     "Test for zero input."
     results = conversions.convertKelvinToCelsius(0)
     self.assertEqual(-273.15, results)
Beispiel #39
0
 def testCorrectResult(self):
     for kel, cel in self.knownValues:
         result = conversions.convertKelvinToCelsius(kel)
         self.assertEqual(cel, result)
Beispiel #40
0
	def testConvertKelvinToCelsius_default(self):
		result = conversions.convertKelvinToCelsius(573.15)
		self.assertEqual(300.00, result)
Beispiel #41
0
 def test_large(self):
     results = conversions.convertKelvinToCelsius(512453)
     self.assertEqual(512179.85, results)