Skip to content

Commit db3b9a4

Browse files
committed
fix(spp_approval,spp_dci_client): add auto=True to system approval and fix test log ordering
Pass auto=True to _do_approve in _action_approve_system so automated approvals show "(auto)" in activity feedback and skip submitter notification, matching the intent of system-initiated approvals. Fix reversed log assertions in test_401_retry_creates_two_log_entries: due to try-finally semantics with recursive calls, the inner retry's finally creates the success log first (lower ID), so with order="id desc" logs[0] is the 401 entry and logs[1] is the success entry.
1 parent ea02944 commit db3b9a4

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

spp_approval/models/approval_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def _action_approve_system(self, comment=None):
356356
record.approval_state,
357357
)
358358
continue
359-
record.sudo()._do_approve(comment=comment)
359+
record.sudo()._do_approve(comment=comment, auto=True)
360360
_logger.info(
361361
"System auto-approved %s %s: %s",
362362
record._name,

spp_dci_client/tests/test_outgoing_log_integration.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,19 @@ def test_401_retry_creates_two_log_entries(self, mock_client_class):
392392
)
393393
self.assertEqual(len(logs), 2, "Should have two log entries (401 + retry)")
394394

395-
# Most recent should be the retry success
396-
self.assertEqual(logs[0].status, "success")
397-
self.assertEqual(logs[0].response_status_code, 200)
398-
399-
# Earlier should be the 401 error
400-
self.assertEqual(logs[1].status, "http_error")
401-
self.assertEqual(logs[1].response_status_code, 401)
402-
self.assertIn("retrying", logs[1].error_detail.lower())
395+
# With order="id desc", logs[0] has the highest ID (created last).
396+
# Due to try-finally semantics, the recursive retry's finally runs first
397+
# (lower ID = success), then the outer call's finally runs (higher ID = 401).
398+
# So logs[0] (highest ID) is the 401 entry, logs[1] (lower ID) is the success.
399+
self.assertEqual(logs[0].status, "http_error")
400+
self.assertEqual(logs[0].response_status_code, 401)
401+
self.assertIn("retrying", logs[0].error_detail.lower())
403402
# M-1 fix: 401 response body should be captured
404-
self.assertTrue(logs[1].response_summary)
403+
self.assertTrue(logs[0].response_summary)
404+
405+
# Earlier log (lower ID) is the retry success
406+
self.assertEqual(logs[1].status, "success")
407+
self.assertEqual(logs[1].response_status_code, 200)
405408

406409
@patch("httpx.Client")
407410
def test_log_failure_does_not_block_request(self, mock_client_class):

0 commit comments

Comments
 (0)