def test_checksum(): assert GPSSensor._build_checksum( '$GPGGA,005206.768,5227.561,N,01230.806,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '68' assert GPSSensor._build_checksum( 'GPGGA,005207.768,5249.958,N,01308.049,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '6E' assert GPSSensor._build_checksum( '$GPGGA,005208.768,5310.190,N,01409.023,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '6A' assert GPSSensor._build_checksum( '$GPGGA,005209.768,5300.094,N,01450.881,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '63' assert GPSSensor._build_checksum( '$GPGGA,005210.768,5148.313,N,01608.005,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '62' assert GPSSensor._build_checksum( '# $GPGGA,005211.768,5142.192,N,01454.836,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '61' assert GPSSensor._build_checksum( '$GPGGA,005212.768,5135.443,N,01332.439,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '6F' assert GPSSensor._build_checksum( '$GPGGA,005213.768,5153.810,N,01259.150,E,1,12,1.0,0.0,M,0.0,M,,*00' ) == '62'
def add_checksum_to_expected(expected: str) -> str: checksum = GPSSensor._build_checksum(expected) expected += checksum return expected