Ejemplo n.º 1
0
def test_parse_gps_datetime_longtime() -> None:
    gprmc_fields = "121931.00,A,4801.86153,N,01056.69289,E,53.587,8.64,270520,,,A"
    nmea = protocol.NMEA("", "", "GPRMC", gprmc_fields.split(","))

    # WHEN
    dt = gpstime.parse_gps_datetime(nmea)

    # THEN
    assert dt == datetime(2020, 5, 27, 12, 19, 31)
Ejemplo n.º 2
0
def test_parse_gps_datetime_bad_sentence() -> None:
    # GIVEN
    gprmc_fields = "225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3"
    nmea = protocol.NMEA("", "", "XXXXX", gprmc_fields.split(","))

    # WHEN
    dt = gpstime.parse_gps_datetime(nmea)

    # THEN
    assert dt is None
Ejemplo n.º 3
0
def test_parse_gps_datetime_correct() -> None:
    # GIVEN
    gprmc_fields = "225446,A,4916.45,N,12311.12,W,000.5,054.7,191103,020.3"
    nmea = protocol.NMEA("", "", "GPRMC", gprmc_fields.split(","))

    # WHEN
    dt = gpstime.parse_gps_datetime(nmea)

    # THEN
    assert dt == datetime(2003, 11, 19, 22, 54, 46)
Ejemplo n.º 4
0
def test_parse_gps_datetime_notime() -> None:
    # GIVEN
    gprmc_fields = ",,,,,,,,,"
    nmea = protocol.NMEA("", "", "GPRMC", gprmc_fields.split(","))

    # WHEN
    dt = gpstime.parse_gps_datetime(nmea)

    # THEN
    assert dt is None