-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
60 lines (51 loc) · 2.21 KB
/
tests.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
59
60
import unittest
from six import iteritems
import io
import navcanada
class TestMetarParser(unittest.TestCase):
def test_extracts_three_stations(self):
with io.open('test_data/metars_and_tafs.html', 'r', encoding='latin-1') as f:
page = f.read()
result = navcanada.parse_metars_and_tafs(page)
self.assertTrue('CYVR' in result)
self.assertTrue('CYXX' in result)
self.assertTrue('CYCD' in result)
def test_extracts_specis(self):
with io.open('test_data/metars_and_tafs.html', 'r', encoding='latin-1') as f:
page = f.read()
result = navcanada.parse_metars_and_tafs(page)
is_speci = False
for station, data in iteritems(result):
for m in data['METARS']:
if m.count('SPECI'):
is_speci = True
self.assertTrue(is_speci)
def test_extracts_lwiss(self):
with io.open('test_data/metars_and_tafs.html', 'r', encoding='latin-1') as f:
page = f.read()
result = navcanada.parse_metars_and_tafs(page)
is_lwis = False
for station, data in iteritems(result):
for m in data['METARS']:
if m.count('LWIS'):
is_lwis = True
self.assertTrue(is_lwis)
def test_extracts_tafs(self):
with io.open('test_data/metars_and_tafs.html', 'r', encoding='latin-1') as f:
page = f.read()
result = navcanada.parse_metars_and_tafs(page)
for station, data in iteritems(result):
self.assertTrue('TAF' in data)
def test_extract_upper_winds(self):
with io.open('test_data/fds.html', 'r', encoding='latin-1') as f:
page = f.read()
result = navcanada.parse_upper_winds(page)
self.assertTrue('YVR' in result)
def test_extracts_notams(self):
with io.open('test_data/notams.html', 'r', encoding='latin-1') as f:
page = f.read()
result = navcanada.parse_notams(page)
self.assertTrue(len(result) > 10)
self.assertTrue('sequence_id' in result[0])
if __name__ == '__main__':
unittest.main()