-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_temperature.py
35 lines (25 loc) · 1.05 KB
/
test_temperature.py
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
import unittest
from aviation_weather import Temperature
from aviation_weather.exceptions import TemperatureDecodeError
class TestTemperature(unittest.TestCase):
"""Unit tests for aviation_weather.components.temperature.Temperature"""
def _test_valid(self, raw, temperature, dew_point):
t = Temperature(raw)
self.assertEqual(raw, t.raw)
self.assertEqual(temperature, t.temperature)
self.assertEqual(dew_point, t.dew_point)
def test_valid_positive_positive(self):
self._test_valid("21/12", 21, 12)
def test_valid_positive_negative(self):
self._test_valid("21/M12", 21, -12)
def test_valid_negative_negative(self):
self._test_valid("M01/M04", -1, -4)
def _test_invalid(self, raw):
with self.assertRaises(TemperatureDecodeError):
Temperature(raw)
def test_invalid_no_numbers(self):
self._test_invalid("M/M")
def test_invalid_no_separator(self):
self._test_invalid("1200")
def test_invalid_slashes(self):
self._test_invalid("////")