@@ -332,12 +332,12 @@ def test_transaction_continues_after_heartbeat_to_get_valid_response(
332
332
req = {"req" : "note.add" }
333
333
334
334
# num_heartbeats of heartbeat responses followed by valid response
335
- heartbeat_response = b'{"err":"{heartbeat}"}\r \n '
335
+ heartbeat_response = b'{"err":"{heartbeat}","status":"testing"}\r \n '
336
+ json_responses = [{'err' : '{heartbeat}' , 'status' : 'testing' }] * num_heartbeats + [{'total' : 42 }]
337
+
336
338
valid_response = b'{"total":42}\r \n '
337
339
card ._transact .side_effect = [heartbeat_response ] * num_heartbeats + [valid_response ]
338
340
339
- json_responses = [{'err' : '{heartbeat}' }] * num_heartbeats + [{'total' : 42 }]
340
-
341
341
with patch ('notecard.notecard.json.loads' ) as mock_loads :
342
342
mock_loads .side_effect = json_responses
343
343
if debug_enabled :
@@ -374,11 +374,12 @@ def test_transaction_debug_heartbeat_with_and_without_status(
374
374
with patch ('builtins.print' ) as mock_print :
375
375
result = card .Transaction (req )
376
376
377
- # Verify the status message was printed for first heartbeat
378
- mock_print .assert_any_call ('Response has heartbeat field indicating heartbeat: testing stsafe' )
379
- # Verify the exception was printed for second heartbeat (KeyError: 'status')
380
- printed_calls = [str (call ) for call in mock_print .call_args_list ]
381
- assert any ("KeyError" in call and "'status'" in call for call in printed_calls )
377
+ # Verify the debug message was printed for first heartbeat (has status)
378
+ mock_print .assert_any_call ('[DEBUG] testing stsafe' )
379
+ # For second heartbeat (no status), exception is silently ignored (pass)
380
+ # So we should only see one debug print call
381
+ debug_calls = [call for call in mock_print .call_args_list if '[DEBUG]' in str (call )]
382
+ assert len (debug_calls ) == 1
382
383
assert result == {'total' : 42 }
383
384
384
385
@pytest .mark .parametrize (
0 commit comments