예제 #1
0
 def test_rule_inherit(self):
     """
     Tests if TAF forecast periods selectively inherit features to calculate flight rules
     """
     report = (
         "CYKF 020738Z 0208/0220 34005KT P6SM FEW015 BKN070 "
         "FM020900 VRB03KT P6SM FEW070 SCT120 "
         "BECMG 0214/0216 12006KT "
         "FM021800 14008KT P6SM BKN025 OVC090"
     )
     expected_rules = ('VFR', 'VFR', 'VFR', 'MVFR',)
     tafobj = Taf(report[:4])
     tafobj.update(report)
     for i, line in enumerate(tafobj.data.forecast):
         self.assertEqual(line.flight_rules, expected_rules[i])
예제 #2
0
 def test_rule_inherit(self):
     """
     Tests if TAF forecast periods selectively inherit features to calculate flight rules
     """
     report = (
         "CYKF 020738Z 0208/0220 34005KT P6SM FEW015 BKN070 "
         "FM020900 VRB03KT P6SM FEW070 SCT120 "
         "BECMG 0214/0216 12006KT "
         "FM021800 14008KT P6SM BKN025 OVC090"
     )
     expected_rules = ('VFR', 'VFR', 'VFR', 'MVFR',)
     tafobj = Taf(report[:4])
     tafobj.update(report)
     for i, line in enumerate(tafobj.data.forecast):
         self.assertEqual(line.flight_rules, expected_rules[i])
예제 #3
0
 def test_prob_tempo(self):
     """
     Non-PROB types should take precident but still fill the probability value
     """
     report = ("EGLL 192253Z 2000/2106 28006KT 9999 BKN035 "
               "PROB30 TEMPO 2004/2009 BKN012 "
               "PROB30 TEMPO 2105/2106 8000 BKN006")
     tafobj = Taf('EGLL')
     tafobj.update(report)
     lines = tafobj.data.forecast
     for line in lines:
         self.assertIsInstance(line.start_time, structs.Timestamp)
         self.assertIsInstance(line.end_time, structs.Timestamp)
     for i in range(1, 3):
         self.assertEqual(lines[i].type, 'TEMPO')
         self.assertEqual(lines[i].probability.value, 30)
예제 #4
0
 def test_prob_tempo(self):
     """
     Non-PROB types should take precident but still fill the probability value
     """
     report = ("EGLL 192253Z 2000/2106 28006KT 9999 BKN035 "
               "PROB30 TEMPO 2004/2009 BKN012 "
               "PROB30 TEMPO 2105/2106 8000 BKN006")
     tafobj = Taf('EGLL')
     tafobj.update(report)
     lines = tafobj.data.forecast
     for line in lines:
         self.assertIsInstance(line.start_time, structs.Timestamp)
         self.assertIsInstance(line.end_time, structs.Timestamp)
     for i in range(1, 3):
         self.assertEqual(lines[i].type, 'TEMPO')
         self.assertEqual(lines[i].probability.value, 30)
예제 #5
0
 def test_taf_ete(self):
     """
     Performs an end-to-end test of all TAF JSON files
     """
     nodate = lambda s: s[s.find('-')+2:]
     for path in glob(os.path.dirname(os.path.realpath(__file__))+'/taf/*.json'):
         ref = json.load(open(path))
         station = Taf(path.split('/')[-1][:4])
         self.assertIsNone(station.last_updated)
         self.assertTrue(station.update(ref['data']['raw']))
         self.assertIsInstance(station.last_updated, datetime)
         # Clear timestamp due to parse_date limitations
         nodt = deepcopy(station.data)
         for key in ('time', 'start_time', 'end_time'):
             setattr(nodt, key, None)
         for i in range(len(nodt.forecast)):
             for key in ('start_time', 'end_time'):
                 setattr(nodt.forecast[i], key, None)
         self.assertEqual(asdict(nodt), ref['data'])
         self.assertEqual(asdict(station.translations), ref['translations'])
         self.assertEqual(station.summary, ref['summary'])
         self.assertEqual(nodate(station.speech), nodate(ref['speech']))
         self.assertEqual(asdict(station.station_info), ref['station_info'])
예제 #6
0
 def test_taf_ete(self):
     """
     Performs an end-to-end test of all TAF JSON files
     """
     nodate = lambda s: s[s.find('-')+2:]
     for path in glob(os.path.dirname(os.path.realpath(__file__))+'/taf/*.json'):
         ref = json.load(open(path))
         station = Taf(path.split('/')[-1][:4])
         self.assertIsNone(station.last_updated)
         self.assertTrue(station.update(ref['data']['raw']))
         self.assertIsInstance(station.last_updated, datetime)
         # Clear timestamp due to parse_date limitations
         nodt = deepcopy(station.data)
         for key in ('time', 'start_time', 'end_time'):
             setattr(nodt, key, None)
         for i in range(len(nodt.forecast)):
             for key in ('start_time', 'end_time'):
                 setattr(nodt.forecast[i], key, None)
         self.assertEqual(asdict(nodt), ref['data'])
         self.assertEqual(asdict(station.translations), ref['translations'])
         self.assertEqual(station.summary, ref['summary'])
         self.assertEqual(nodate(station.speech), nodate(ref['speech']))
         self.assertEqual(asdict(station.station_info), ref['station_info'])
예제 #7
0
 def test_taf_ete(self):
     """
     Performs an end-to-end test of all TAF JSON files
     """
     nodate = lambda s: s[s.find("-") + 2 :]
     for path in Path(__file__).parent.joinpath("taf").glob("*.json"):
         ref = json.load(path.open())
         station = Taf(path.stem)
         self.assertIsNone(station.last_updated)
         self.assertTrue(station.update(ref["data"]["raw"]))
         self.assertIsInstance(station.last_updated, datetime)
         # Clear timestamp due to parse_date limitations
         nodt = deepcopy(station.data)
         for key in ("time", "start_time", "end_time"):
             setattr(nodt, key, None)
         for i in range(len(nodt.forecast)):
             for key in ("start_time", "end_time"):
                 setattr(nodt.forecast[i], key, None)
         self.assertEqual(asdict(nodt), ref["data"])
         self.assertEqual(asdict(station.translations), ref["translations"])
         self.assertEqual(station.summary, ref["summary"])
         self.assertEqual(nodate(station.speech), nodate(ref["speech"]))
         self.assertEqual(asdict(station.station_info), ref["station_info"])