feat: improve operation diagnostics and API logging
This commit is contained in:
1 parent
aaea5b6f58
commit
2d743d2220
9 files changed
+272
-47
No files matched your search
@@ -59,6 +59,18 @@ class DeployNoticeTests(unittest.IsolatedAsyncioTestCase):
|
||||
|
||||
|
||||
class UserFacingErrorTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_failure_log_has_traceback_and_operation_id(self):
|
||||
message = AsyncMock()
|
||||
with bot.diagnostic_operation() as operation_id:
|
||||
with self.assertLogs(bot.logger, level="ERROR") as captured:
|
||||
try:
|
||||
raise ValueError("provider failure")
|
||||
except ValueError as exc:
|
||||
await bot.report_error(message, "генерация поста", exc)
|
||||
self.assertIn(f"operation_id={operation_id}", "\n".join(captured.output))
|
||||
self.assertIn("Traceback (most recent call last)", "\n".join(captured.output))
|
||||
self.assertIn("provider failure", "\n".join(captured.output))
|
||||
|
||||
async def test_production_error_is_generic_without_exception_details(self):
|
||||
message = AsyncMock()
|
||||
with patch.object(bot, "DEPLOY_ENV", "production"):
|
||||
|
||||
Reference in new issue
Block a user