-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_windshear.py
41 lines (31 loc) · 1.06 KB
/
test_windshear.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
import unittest
from aviation_weather.components.wind import Wind
from aviation_weather.components.windshear import WindShear
from aviation_weather.exceptions import WindShearDecodeError
class TestWindShear(unittest.TestCase):
def _test_valid(self, raw, altitude, wind):
ws = WindShear(raw)
self.assertEqual(raw, ws.raw)
self.assertEqual(altitude, ws.altitude)
self.assertEqual(wind, ws.wind)
def test_valid_1(self):
self._test_valid(
raw="WS010/31022KT",
altitude=1000,
wind=Wind("31022KT")
)
def test_valid_2(self):
self._test_valid(
raw="WS020/18040KT",
altitude=2000,
wind=Wind("18040KT")
)
def _test_invalid(self, raw):
with self.assertRaises(WindShearDecodeError):
WindShear(raw)
def test_invalid_blank(self):
self._test_invalid("")
def test_invalid_altitude(self):
self._test_invalid("WS20/02020KT")
def test_invalid_wind(self):
self._test_invalid("WS100/100")