def speech(self) -> str: """ Report summary designed to be read by a text-to-speech program """ if not self.data: self.update() return speech.taf(self.data, self.units)
def test_taf(self): """ Tests converting a TafData report into a single spoken string """ units = structs.Units(**static.NA_UNITS) empty_line = { k: None for k in structs.TafLineData.__dataclass_fields__.keys() } forecast = [ structs.TafLineData(**{ **empty_line, **line }) for line in ( { "type": "FROM", "start_time": _core.make_timestamp("0410Z"), "end_time": _core.make_timestamp("0414Z"), "visibility": _core.make_number("3"), "wind_direction": _core.make_number("360"), "wind_gust": _core.make_number("20"), "wind_speed": _core.make_number("12"), }, { "type": "PROB", "probability": _core.make_number("45"), "start_time": _core.make_timestamp("0412Z"), "end_time": _core.make_timestamp("0414Z"), "visibility": _core.make_number("M1/4"), }, ) ] taf = structs.TafData( raw=None, remarks=None, station=None, time=None, forecast=forecast, start_time=_core.make_timestamp("0410Z"), end_time=_core.make_timestamp("0414Z"), ) ret = speech.taf(taf, units) spoken = ( f"Starting on {taf.start_time.dt.strftime('%B')} 4th - From 10 to 14 zulu, " "Winds three six zero at 12kt gusting to 20kt. Visibility three miles. " r"From 12 to 14 zulu, there's a 45% chance for Visibility " "less than one quarter of a mile") self.assertIsInstance(ret, str) self.assertEqual(ret, spoken)
def test_taf(self): """ Tests converting a TafData report into a single spoken string """ units = structs.Units(**static.NA_UNITS) empty_line = { k: None for k in structs.TafLineData.__dataclass_fields__.keys() } forecast = [ structs.TafLineData(**{ **empty_line, **line }) for line in ( { 'type': 'FROM', 'start_time': core.make_timestamp('0410Z'), 'end_time': core.make_timestamp('0414Z'), 'visibility': core.make_number('3'), 'wind_direction': core.make_number('360'), 'wind_gust': core.make_number('20'), 'wind_speed': core.make_number('12'), }, { 'type': 'PROB', 'probability': core.make_number('45'), 'start_time': core.make_timestamp('0412Z'), 'end_time': core.make_timestamp('0414Z'), 'visibility': core.make_number('M1/4'), }, ) ] taf = structs.TafData(raw=None, remarks=None, station=None, time=None, forecast=forecast, start_time=core.make_timestamp('0410Z'), end_time=core.make_timestamp('0414Z')) ret = speech.taf(taf, units) spoken = ( f"Starting on {taf.start_time.dt.strftime('%B')} 4th - From 10 to 14 zulu, " "Winds three six zero at 12kt gusting to 20kt. Visibility three miles. " r"From 12 to 14 zulu, there's a 45% chance for Visibility " "less than one quarter of a mile") self.assertIsInstance(ret, str) self.assertEqual(ret, spoken)
def test_taf(self): """ Tests converting a TafData report into a single spoken string """ units = structs.Units(**static.NA_UNITS) empty_line = {k: None for k in structs.TafLineData.__dataclass_fields__.keys()} forecast = [structs.TafLineData(**{**empty_line, **line}) for line in ( { 'type': 'FROM', 'start_time': core.make_timestamp('0410Z'), 'end_time': core.make_timestamp('0414Z'), 'visibility': core.make_number('3'), 'wind_direction': core.make_number('360'), 'wind_gust': core.make_number('20'), 'wind_speed': core.make_number('12'), }, { 'type': 'PROB', 'probability': core.make_number('45'), 'start_time': core.make_timestamp('0412Z'), 'end_time': core.make_timestamp('0414Z'), 'visibility': core.make_number('M1/4'), }, )] taf = structs.TafData( raw=None, remarks=None, station=None, time=None, forecast=forecast, start_time=core.make_timestamp('0410Z'), end_time=core.make_timestamp('0414Z') ) ret = speech.taf(taf, units) spoken = (f"Starting on {taf.start_time.dt.strftime('%B')} 4th - From 10 to 14 zulu, " "Winds three six zero at 12kt gusting to 20kt. Visibility three miles. " r"From 12 to 14 zulu, there's a 45% chance for Visibility " "less than one quarter of a mile") self.assertIsInstance(ret, str) self.assertEqual(ret, spoken)