def test_gps_nmea_repeat():
    gps = GPSSensor('/dev/ttyAMA0')
    gps.value_type = GPSValueType.NMEA

    gps.raw_nmea = '$GNGGA,020604.001,4739.228833333,N,12207.031866667,W,1,3,,164.7,M,-17.1,M,,*67'
    gps.repeat = True

    for _ in range(0, 20):
        line = gps.read_line()
        if line == '':
            time.sleep(1)
            line = gps.read_line()

        assert line == '$GNGGA,020604.001,4739.228833333,N,12207.031866667,W,1,3,,164.7,M,-17.1,M,,*67'
def test_gps_gpx_repeat():
    gps = GPSSensor('/dev/ttyAMA0')
    gps.value_type = GPSValueType.GPX

    with open('./src/tests/route.gpx', 'r') as gpx_file:
        gps.gpx_file_contents = gpx_file.read()

    gps.repeat = True

    for _ in range(0, 20):
        line = gps.read_line()
        if line == '':
            time.sleep(1)
            line = gps.read_line()

        current_utc = datetime.datetime.utcnow()
        assert line == add_checksum_to_expected(
            f'$GPGGA,{current_utc.hour:02d}{current_utc.minute:02d}{current_utc.second:02}.00,4744.0886,N,12215.42,W,1,3,,0,M,0,M,,*'
        )

        line = gps.read_line()
        if line == '':
            time.sleep(1)
            line = gps.read_line()

        current_utc = datetime.datetime.utcnow()
        assert line == add_checksum_to_expected(
            f'$GPGGA,{current_utc.hour:02d}{current_utc.minute:02d}{current_utc.second:02}.00,4744.0886,N,12215.4206,W,1,3,,0,M,0,M,,*'
        )

        line = gps.read_line()
        if line == '':
            time.sleep(1)
            line = gps.read_line()

        current_utc = datetime.datetime.utcnow()
        assert line == add_checksum_to_expected(
            f'$GPGGA,{current_utc.hour:02d}{current_utc.minute:02d}{current_utc.second:02}.00,4744.0856,N,12215.4092,W,1,3,,0,M,0,M,,*'
        )