-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_wind.py
58 lines (41 loc) · 1.7 KB
/
test_wind.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import unittest
from aviation_weather import Wind
from aviation_weather.exceptions import WindDecodeError
class TestWind(unittest.TestCase):
"""Unit tests for aviation_weather.components.wind.Wind"""
def _test_valid(self, raw, direction, speed, gusts, variable):
w = Wind(raw)
self.assertEqual(raw, w.raw)
self.assertEqual(direction, w.direction)
self.assertEqual(speed, w.speed)
self.assertEqual(gusts, w.gusts)
self.assertEqual(variable, w.variable)
def test_valid_simpleKT(self):
self._test_valid("35007KT", 350, 7, None, None)
def test_valid_simpleMPS(self):
self._test_valid("21007MPS", 210, 7, None, None)
def test_valid_strong_winds(self):
self._test_valid("350107KT", 350, 107, None, None)
def test_valid_gusts(self):
self._test_valid("32013G17KT", 320, 13, 17, None)
def test_valid_strong_gusts(self):
self._test_valid("05013G127KT", 50, 13, 127, None)
def test_valid_variable_weak(self):
self._test_valid("VRB01MPS", "VRB", 1, None, None)
def test_valid_variable_strong(self):
self._test_valid("14003KT 110V170", 140, 3, None, (110, 170))
def _test_invalid(self, raw):
with self.assertRaises(WindDecodeError):
Wind(raw)
def test_invalid_empty(self):
self._test_invalid("")
def test_invalid_short(self):
self._test_invalid("1012KT")
def test_invalid_long(self):
self._test_invalid("3210123KT")
def test_invalid_bad_unit(self):
self._test_invalid("21012KN")
def test_invalid_strength(self):
self._test_invalid("VRBMPS")
def test_invalid_no_unit(self):
self._test_invalid("21012G21")