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
This commit is contained in:
parent
001eedceed
commit
29baa1bb73
1 changed files with 3 additions and 3 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue