Beispiel #1
0
 def _test_forecast_ete(self, report: base.Forecast):
     """Performs an end-to-end test of all report JSON files"""
     for ref, icao, issued in get_data(__file__, report.__class__.__name__.lower()):
         station = report(icao)
         self.assertIsNone(station.last_updated)
         self.assertIsNone(station.issued)
         self.assertTrue(station.parse(ref["data"]["raw"]))
         self.assertIsInstance(station.last_updated, datetime)
         self.assertEqual(station.issued, issued)
         # Clear timestamp due to parse_date limitations
         self.assertEqual(asdict(station.data), ref["data"])
Beispiel #2
0
 def test_pirep_ete(self):
     """Performs an end-to-end test of all PIREP JSON files"""
     for ref, icao, issued in get_data(__file__, "pirep"):
         station = pirep.Pireps(icao)
         self.assertIsNone(station.last_updated)
         self.assertIsNone(station.issued)
         reports = [report["data"]["raw"] for report in ref["reports"]]
         self.assertTrue(station.parse(reports, issued=issued))
         self.assertIsInstance(station.last_updated, datetime)
         self.assertEqual(station.issued, issued)
         for parsed, report in zip(station.data, ref["reports"]):
             self.assertEqual(asdict(parsed), report["data"])
Beispiel #3
0
 def test_taf_ete(self):
     """Performs an end-to-end test of all TAF JSON files"""
     for ref, icao, issued in get_data(__file__, "taf"):
         station = taf.Taf(icao)
         self.assertIsNone(station.last_updated)
         self.assertIsNone(station.issued)
         self.assertTrue(station.parse(ref["data"]["raw"], issued=issued))
         self.assertIsInstance(station.last_updated, datetime)
         self.assertEqual(station.issued, issued)
         self.assertEqual(asdict(station.data), ref["data"])
         self.assertEqual(asdict(station.translations), ref["translations"])
         self.assertEqual(station.summary, ref["summary"])
         self.assertEqual(station.speech, ref["speech"])
Beispiel #4
0
 def _test_gfs_ete(self, report: "Forecast"):
     """
     Performs an end-to-end test of all report JSON files
     """
     for path in get_data(__file__, report.__class__.__name__.lower()):
         path = Path(path)
         ref = json.load(path.open(), object_hook=datetime_parser)
         station = report(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
         self.assertEqual(asdict(station.data), ref["data"])
Beispiel #5
0
 def test_metar_ete(self):
     """Performs an end-to-end test of all METAR JSON files"""
     for ref, icao, issued in get_data(__file__, "metar"):
         station = metar.Metar(icao)
         raw = ref["data"]["raw"]
         self.assertEqual(station.sanitize(raw), ref["data"]["sanitized"])
         self.assertIsNone(station.last_updated)
         self.assertIsNone(station.issued)
         self.assertTrue(station.parse(raw, issued=issued))
         self.assertIsInstance(station.last_updated, datetime)
         self.assertEqual(station.issued, issued)
         self.assertEqual(asdict(station.data), ref["data"])
         self.assertEqual(asdict(station.translations), ref["translations"])
         self.assertEqual(station.summary, ref["summary"])
         self.assertEqual(station.speech, ref["speech"])
Beispiel #6
0
 def test_pirep_ete(self):
     """
     Performs an end-to-end test of all PIREP JSON files
     """
     for path in get_data(__file__, "pirep"):
         path = Path(path)
         ref = json.load(path.open())
         station = pirep.Pireps(path.stem)
         self.assertIsNone(station.last_updated)
         reports = [report["data"]["raw"] for report in ref["reports"]]
         self.assertTrue(station.update(reports))
         self.assertIsInstance(station.last_updated, datetime)
         for i, report in enumerate(ref["reports"]):
             # Clear timestamp due to parse_date limitations
             station.data[i].time = None
             self.assertEqual(asdict(station.data[i]), report["data"])
Beispiel #7
0
 def test_metar_ete(self):
     """
     Performs an end-to-end test of all METAR JSON files
     """
     for path in get_data(__file__, "metar"):
         path = Path(path)
         ref = json.load(path.open())
         station = metar.Metar(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
         station.data.time = None
         self.assertEqual(asdict(station.data), ref["data"])
         self.assertEqual(asdict(station.translations), ref["translations"])
         self.assertEqual(station.summary, ref["summary"])
         self.assertEqual(station.speech, ref["speech"])
Beispiel #8
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 get_data(__file__, "taf"):
         ref = json.load(path.open())
         station = taf.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", "transition_start"):
             setattr(nodt, key, None)
         for i in range(len(nodt.forecast)):
             for key in ("start_time", "end_time", "transition_start"):
                 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"]))