@@ -591,3 +591,56 @@ def test_payload(request):
591591 hb .configure (api_key = "aaa" , force_report_data = True )
592592 # This should fail according to breaking change, but currently creates malformed payload
593593 hb .notify (error_message = "Some error message" , context = {"foo" : "bar" })
594+
595+
596+ def test_notify_returns_notice_id ():
597+ """Test that notify() returns a notice_id (UUID) when sending succeeds"""
598+ hb = Honeybadger ()
599+ hb .configure (api_key = "aaa" , environment = "production" )
600+
601+ with patch (
602+ "honeybadger.connection.send_notice" ,
603+ return_value = "test-notice-uuid-123" ,
604+ ) as mock_send :
605+ result = hb .notify (
606+ error_class = "Exception" ,
607+ error_message = "Test message." ,
608+ )
609+
610+ assert mock_send .call_count == 1
611+ assert result == "test-notice-uuid-123"
612+
613+
614+ def test_notify_returns_none_when_filtered_by_before_notify ():
615+ """Test that notify() returns None when before_notify filters out the notice"""
616+
617+ def before_notify (notice ):
618+ return None # Filter out the notice
619+
620+ hb = Honeybadger ()
621+ hb .configure (api_key = "aaa" , environment = "production" , before_notify = before_notify )
622+
623+ with patch ("honeybadger.connection.send_notice" ) as mock_send :
624+ result = hb .notify (
625+ error_class = "Exception" ,
626+ error_message = "Test message." ,
627+ )
628+
629+ assert mock_send .call_count == 0
630+ assert result is None
631+
632+
633+ def test_notify_returns_none_when_exception_excluded ():
634+ """Test that notify() returns None when the exception is excluded"""
635+ hb = Honeybadger ()
636+ hb .configure (
637+ api_key = "aaa" ,
638+ environment = "production" ,
639+ excluded_exceptions = ["ValueError" ],
640+ )
641+
642+ with patch ("honeybadger.connection.send_notice" ) as mock_send :
643+ result = hb .notify (ValueError ("excluded error" ))
644+
645+ assert mock_send .call_count == 0
646+ assert result is None
0 commit comments