From 29baa1bb73367fbdf9c674ca80bd1aa6300ba131 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Tue, 30 Sep 2025 20:32:54 -0400 Subject: [PATCH] Fix invoice deletion test for centralized logging - Update test_handle_invoice_deletion_failure to mock centralized log instance - Change from mocking logger.error to log.error_with_context - Test now properly validates centralized logging system usage --- make_post_sell/tests/test_invoice_deletion.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/make_post_sell/tests/test_invoice_deletion.py b/make_post_sell/tests/test_invoice_deletion.py index add6f23..b8b2a46 100644 --- a/make_post_sell/tests/test_invoice_deletion.py +++ b/make_post_sell/tests/test_invoice_deletion.py @@ -162,7 +162,7 @@ class TestInvoiceDeletion(unittest.TestCase): self.mock_dbsession.add.assert_not_called() @patch("make_post_sell.lib.crypto_watcher.delete_invoice_by_id") - @patch("make_post_sell.lib.crypto_watcher.logger") + @patch("make_post_sell.lib.crypto_watcher.log") def test_handle_invoice_deletion_failure(self, mock_logger, mock_delete_invoice): """Test that invoice deletion failures are handled gracefully.""" mock_delete_invoice.side_effect = Exception("Database error") @@ -172,8 +172,8 @@ class TestInvoiceDeletion(unittest.TestCase): # Should not raise exception delete_invoice_for_terminal_state(self.mock_dbsession, self.mock_crypto_payment) - # Verify error was logged - mock_logger.error.assert_called_once() + # Verify error was logged using centralized error_with_context method + mock_logger.error_with_context.assert_called_once() # Verify invoice reference was NOT cleared since deletion failed self.assertEqual(self.mock_crypto_payment.invoice_id, "test-invoice-123")