Exemple #1
0
 def test_parse_altimeter(self):
     """Tests that an atlimiter is correctly parsed into a Number"""
     for text, alt in (
         ("A2992", (29.92, "two nine point nine two")),
         ("2992", (29.92, "two nine point nine two")),
         ("A3000", (30.00, "three zero point zero zero")),
         ("Q1000", (1000, "one zero zero zero")),
         ("Q.1000", (1000, "one zero zero zero")),
         ("Q0998", (998, "zero nine nine eight")),
         ("Q1000/10", (1000, "one zero zero zero")),
         ("QNH3003INS", (30.03, "three zero point zero three")),
     ):
         self.assert_number(metar.parse_altimeter(text), text, *alt)
     for text in (None, "12/10", "RMK", "ABCDE", "15KM", "10SM"):
         self.assertIsNone(metar.parse_altimeter(text))
Exemple #2
0
 def test_taf_line(self):
     """Tests converting TAF line data into into a single spoken string"""
     units = structs.Units(**static.core.NA_UNITS)
     line = {
         "altimeter": parse_altimeter("2992"),
         "clouds": [core.make_cloud("BKN015CB")],
         "end_time": core.make_timestamp("1206"),
         "icing": ["611005"],
         "other": [],
         "start_time": core.make_timestamp("1202"),
         "transition_start": None,
         "turbulence": ["540553"],
         "type": "FROM",
         "visibility": core.make_number("3"),
         "wind_direction": core.make_number("360"),
         "wind_gust": core.make_number("20"),
         "wind_shear": "WS020/07040KT",
         "wind_speed": core.make_number("12"),
         "wx_codes": get_wx_codes(["+RA"])[1],
     }
     line.update({
         k: None
         for k in ("flight_rules", "probability", "raw", "sanitized")
     })
     line = structs.TafLineData(**line)
     spoken = (
         "From 2 to 6 zulu, Winds three six zero at 12kt gusting to 20kt. "
         "Wind shear 2000ft from zero seven zero at 40kt. Visibility three miles. "
         "Altimeter two nine point nine two. Heavy Rain. "
         "Broken layer at 1500ft (Cumulonimbus). "
         "Occasional moderate turbulence in clouds from 5500ft to 8500ft. "
         "Light icing from 10000ft to 15000ft")
     ret = speech.taf_line(line, units)
     self.assertIsInstance(ret, str)
     self.assertEqual(ret, spoken)
Exemple #3
0
 def test_metar(self):
     """
     Tests converting METAR data into into a single spoken string
     """
     units = structs.Units(**static.core.NA_UNITS)
     data = {
         "altimeter":
         parse_altimeter("2992"),
         "clouds": [core.make_cloud("BKN015CB")],
         "dewpoint":
         core.make_number("M01"),
         "other": [],
         "temperature":
         core.make_number("03"),
         "visibility":
         core.make_number("3"),
         "wind_direction":
         core.make_number("360"),
         "wind_gust":
         core.make_number("20"),
         "wind_speed":
         core.make_number("12"),
         "wind_variable_direction": [
             core.make_number("340"),
             core.make_number("020", speak="020"),
         ],
         "wx_codes":
         get_wx_codes(["+RA"])[1],
     }
     data.update({
         k: None
         for k in (
             "raw",
             "remarks",
             "station",
             "time",
             "flight_rules",
             "remarks_info",
             "runway_visibility",
             "sanitized",
         )
     })
     data = structs.MetarData(**data)
     spoken = (
         "Winds three six zero (variable three four zero to zero two zero) "
         "at 12kt gusting to 20kt. Visibility three miles. "
         "Temperature three degrees Celsius. Dew point minus one degree Celsius. "
         "Altimeter two nine point nine two. Heavy Rain. "
         "Broken layer at 1500ft (Cumulonimbus)")
     ret = speech.metar(data, units)
     self.assertIsInstance(ret, str)
     self.assertEqual(ret, spoken)
Exemple #4
0
 def test_altimeter(self):
     """Tests converting altimeter reading into a spoken string"""
     for alt, unit, spoken in (
         ("", "hPa", "unknown"),
         ("1020", "hPa", "one zero two zero"),
         ("0999", "hPa", "zero nine nine nine"),
         ("1012", "hPa", "one zero one two"),
         ("3000", "inHg", "three zero point zero zero"),
         ("2992", "inHg", "two nine point nine two"),
         ("3005", "inHg", "three zero point zero five"),
     ):
         self.assertEqual(speech.altimeter(parse_altimeter(alt), unit),
                          "Altimeter " + spoken)