@@ -24,25 +24,25 @@ def mc_parser(mock_protocols, logger):
2424 "MC;LL=-762;LH=544;SL=-402;SH=345;D=DB6D5B54;C=342;L=48;R=32;" , # Funkbus (PID 119) - 48 bits
2525 "119" ,
2626 "2C175F30008F" , # Expected Funkbus hex output (48 bits -> 12 Hex chars)
27- - 32 .0 ,
27+ - 58 .0 ,
2828 ),
2929 (
3030 "MC;LL=100;LH=100;D=11112222;C=500;L=32;R=10;" , # Grothe (PID 108) - 32 bits
3131 "108" ,
3232 "AAAAAAAA" , # Expected Grothe hex output (32 bits -> 8 Hex chars)
33- - 10 .0 ,
33+ - 69 .0 ,
3434 ),
3535 ],
3636)
3737def test_mc_parser_valid_message (mc_parser , mock_protocols , line , expected_protocol , expected_payload , expected_rssi ):
3838 """Test valid MC messages."""
3939 frame = RawFrame (line = line )
4040 demodulated = [{"protocol_id" : expected_protocol , "payload" : expected_payload }]
41- mock_protocols .demodulate .return_value = demodulated
41+ mock_protocols .demodulate_mc .return_value = demodulated
4242
4343 result = list (mc_parser .parse (frame ))
4444
45- mock_protocols .demodulate .assert_called_once ()
45+ mock_protocols .demodulate_mc .assert_called_once ()
4646 assert len (result ) == 1
4747 assert result [0 ].protocol_id == expected_protocol
4848 assert result [0 ].payload == expected_payload
@@ -52,15 +52,15 @@ def test_mc_parser_valid_message(mc_parser, mock_protocols, line, expected_proto
5252@pytest .mark .parametrize (
5353 "line, log_message, expects_demodulate_call, raises_exception" ,
5454 [
55- ("MC;LL=-762;LH=544;D=DB6;C=342;L=12;R=bar;" , "Could not parse RSSI value: bar" , True , False ),
55+ ("MC;LL=-762;LH=544;D=DB6;C=342;L=12;R=bar;" , "Could not parse RSSI value: bar" , False , True ),
5656 (
5757 "MC;LL=-653;LH=679;SL=-310;SH=351;C=332;L=21;R=20;" ,
58- "Ignoring MC message without data (D )" ,
58+ "Ignoring MC message missing required fields (D, C, or L )" ,
5959 False , # No 'D=' part, so demodulate is not called
6060 False ,
6161 ),
6262 ("FOO;LL=1;D=FF;" , "Not an MC message" , False , False ),
63- ("MC;LL=-2738;LH=3121;SL=-1268;SH=1667;D=GGD9FF0E;C=1465;L=32;R=246;" , "Error during MC demodulation for line :" , True , True ),
63+ ("MC;LL=-2738;LH=3121;SL=-1268;SH=1667;D=GGD9FF0E;C=1465;L=32;R=246;" , "Ignoring MC message with non-hexadecimal raw_hex :" , False , True ),
6464 ],
6565)
6666def test_mc_parser_corrupt_messages (mc_parser , mock_protocols , caplog , line , log_message , expects_demodulate_call , raises_exception ):
@@ -88,14 +88,14 @@ def test_mc_parser_corrupt_messages(mc_parser, mock_protocols, caplog, line, log
8888@pytest .mark .parametrize (
8989 "line, expects_demodulate_call" ,
9090 [
91- ("MC;LL=-2883;LH=2982;XX=-1401;SH=1509;D=AF7EFF2E;C=1466;L=31;R=14;" , True ),
92- ("MC;LL=-2895;LH=2976;S=-1401;SH=1685;D=AFBEFFCE;C=1492;L=31;R=23;" , True ),
93- ("MC;LL=-2901;LH=2958{SL=-1412;SH=1509;D=AFBEFFCE;C=1463;L=31;R=17;" , True ),
94- ("MC;LH=-2889;LH=2963;SL=-1420;SH=1514;D=AF377F87;C=1464;L=32;R=11;" , True ),
95- ("MC;LL=-2872:LH=2985;SL=-1401;SH=1527;D=AFFB7F2B;C=1464;L=32;R=10;" , True ),
96- ("MC;LL=-2868;LL=-1416;SH=1525;D=AFBB7F4B;C=1468;L=32;R=16;" , True ),
97- ("MC;LL=-762;LH=544;SL=-402;SH=345;D=DB6D5B54;C=342;L=30;R=32;" , True ), # Too long (sd_protocols responsibility)
98- ("MC;LL=-762;LH=544;SL=-402;SH=345;D=DB6;C=342;L=12;R=32;" , True ), # Too short (sd_protocols responsibility)
91+ ("MC;LL=-2883;LH=2982;XX=-1401;SH=1509;D=AF7EFF2E;C=1466;L=31;R=14;" , False ),
92+ ("MC;LL=-2895;LH=2976;S=-1401;SH=1685;D=AFBEFFCE;C=1492;L=31;R=23;" , False ),
93+ ("MC;LL=-2901;LH=2958{SL=-1412;SH=1509;D=AFBEFFCE;C=1463;L=31;R=17;" , False ),
94+ ("MC;LH=-2889;LH=2963;SL=-1420;SH=1514;D=AF377F87;C=1464;L=32;R=11;" , False ),
95+ ("MC;LL=-2872:LH=2985;SL=-1401;SH=1527;D=AFFB7F2B;C=1464;L=32;R=10;" , False ),
96+ ("MC;LL=-2868;LL=-1416;SH=1525;D=AFBB7F4B;C=1468;L=32;R=16;" , False ),
97+ ("MC;LL=-762;LH=544;SL=-402;SH=345;D=DB6D5B54;C=342;L=30;R=32;" , False ), # Too long (sd_protocols responsibility)
98+ ("MC;LL=-762;LH=544;SL=-402;SH=345;D=DB6;C=342;L=12;R=32;" , False ), # Too short (sd_protocols responsibility)
9999 ],
100100)
101101def test_mc_parser_demodulate_failures (mc_parser , mock_protocols , line , expects_demodulate_call ):
0 commit comments