File: test_utils.py

package info (click to toggle)
python-nuheat 1.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 228 kB
  • sloc: python: 897; sh: 5; makefile: 5
file content (77 lines) | stat: -rw-r--r-- 2,045 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import unittest
import nuheat.util as util


class TestUtils(unittest.TestCase):

    def test_round_half(self):
        tests = [
            [0.0, 0],
            [31.4, 31],
            [31.5, 32],
            [32.4, 32],
            [32.5, 33]
        ]
        for test in tests:
            rounded = util.round_half(test[0])
            self.assertEqual(rounded, test[1])

    def test_fahrenheit_to_celsius(self):
        tests = [
            [32, 0],
            [72, 22],
            [212, 100]
        ]
        for test in tests:
            celsius = util.fahrenheit_to_celsius(test[0])
            self.assertEqual(celsius, test[1])

    def test_celsius_to_fahrenheit(self):
        tests = [
            [32, 0],
            [72, 22],
            [212, 100]
        ]
        for test in tests:
            fahrenheit = util.celsius_to_fahrenheit(test[1])
            self.assertEqual(fahrenheit, test[0])

    def test_fahrenheit_to_nuheat(self):
        tests = [
            [41, 481],  # min
            [72, 2217],
            [157, 6977]  # max
        ]
        for test in tests:
            temp = util.fahrenheit_to_nuheat(test[0])
            self.assertEqual(temp, test[1])

    def test_celsius_to_nuheat(self):
        tests = [
            [5, 481],  # min
            [22, 2217],
            [69, 6921]  # max
        ]
        for test in tests:
            temp = util.celsius_to_nuheat(test[0])
            self.assertEqual(temp, test[1])

    def test_nuheat_to_fahrenheit(self):
        tests = [
            [500, 41],  # min
            [2222, 72],
            [7000, 157]  # max
        ]
        for test in tests:
            fahrenheit = util.nuheat_to_fahrenheit(test[0])
            self.assertEqual(fahrenheit, test[1])

    def test_nuheat_to_celsius(self):
        tests = [
            [500, 5],  # min
            [2222, 22],
            [7000, 69]  # max
        ]
        for test in tests:
            celsius = util.nuheat_to_celsius(test[0])
            self.assertEqual(celsius, test[1])