@@ -1107,7 +1107,7 @@ def _make_http_exception(status: int, code: int = 0) -> discord.HTTPException:
11071107
11081108
11091109class TestSendWithRetry :
1110- """Test _send_with_retry helper for transient Discord errors."""
1110+ """Test send_with_retry helper for transient Discord errors."""
11111111
11121112 @pytest .fixture
11131113 def mock_ctx (self ):
@@ -1121,7 +1121,7 @@ def mock_ctx(self):
11211121 async def test_success_on_first_attempt_no_retry (self , mock_ctx ):
11221122 """Happy path: send_method called once, no notice sent."""
11231123 send = AsyncMock (return_value = "ok" )
1124- result = await bot_utils ._send_with_retry (mock_ctx , send , embed = "x" )
1124+ result = await bot_utils .send_with_retry (mock_ctx , send , embed = "x" )
11251125 assert result == "ok"
11261126 send .assert_awaited_once_with (embed = "x" )
11271127 mock_ctx .send .assert_not_called ()
@@ -1131,7 +1131,7 @@ async def test_retries_on_500_then_succeeds(self, mock_ctx):
11311131 """500 error → retry, second attempt succeeds; one channel notice sent."""
11321132 send = AsyncMock (side_effect = [_make_http_exception (500 ), "ok" ])
11331133 with patch ("src.bot.tools.bot_utils.asyncio.sleep" , new_callable = AsyncMock ):
1134- result = await bot_utils ._send_with_retry (mock_ctx , send , embed = "x" )
1134+ result = await bot_utils .send_with_retry (mock_ctx , send , embed = "x" )
11351135 assert result == "ok"
11361136 assert send .await_count == 2
11371137 # Notice sent exactly once
@@ -1144,7 +1144,7 @@ async def test_retries_on_429_code_40062(self, mock_ctx):
11441144 """429 with code 40062 is treated as transient and retried."""
11451145 send = AsyncMock (side_effect = [_make_http_exception (429 , code = 40062 ), "ok" ])
11461146 with patch ("src.bot.tools.bot_utils.asyncio.sleep" , new_callable = AsyncMock ):
1147- result = await bot_utils ._send_with_retry (mock_ctx , send )
1147+ result = await bot_utils .send_with_retry (mock_ctx , send )
11481148 assert result == "ok"
11491149 assert send .await_count == 2
11501150
@@ -1154,7 +1154,7 @@ async def test_does_not_retry_on_403_forbidden(self, mock_ctx):
11541154 forbidden = discord .Forbidden (MagicMock (status = 403 ), {"message" : "no" , "code" : 50007 })
11551155 send = AsyncMock (side_effect = forbidden )
11561156 with pytest .raises (discord .Forbidden ):
1157- await bot_utils ._send_with_retry (mock_ctx , send )
1157+ await bot_utils .send_with_retry (mock_ctx , send )
11581158 send .assert_awaited_once ()
11591159 mock_ctx .send .assert_not_called ()
11601160
@@ -1163,7 +1163,7 @@ async def test_does_not_retry_on_429_other_code(self, mock_ctx):
11631163 """429 without code 40062 is not retried by this helper."""
11641164 send = AsyncMock (side_effect = _make_http_exception (429 , code = 20016 ))
11651165 with pytest .raises (discord .HTTPException ):
1166- await bot_utils ._send_with_retry (mock_ctx , send )
1166+ await bot_utils .send_with_retry (mock_ctx , send )
11671167 send .assert_awaited_once ()
11681168
11691169 @pytest .mark .asyncio
@@ -1172,7 +1172,7 @@ async def test_exhausts_retries_then_raises(self, mock_ctx):
11721172 send = AsyncMock (side_effect = _make_http_exception (500 ))
11731173 with patch ("src.bot.tools.bot_utils.asyncio.sleep" , new_callable = AsyncMock ):
11741174 with pytest .raises (discord .HTTPException ):
1175- await bot_utils ._send_with_retry (mock_ctx , send , max_attempts = 3 )
1175+ await bot_utils .send_with_retry (mock_ctx , send , max_attempts = 3 )
11761176 assert send .await_count == 3
11771177 # Notice sent at most once even across multiple failed attempts
11781178 assert mock_ctx .send .call_count == 1
@@ -1183,6 +1183,6 @@ async def test_notice_failure_does_not_break_retry(self, mock_ctx):
11831183 mock_ctx .send .side_effect = _make_http_exception (500 )
11841184 send = AsyncMock (side_effect = [_make_http_exception (500 ), "ok" ])
11851185 with patch ("src.bot.tools.bot_utils.asyncio.sleep" , new_callable = AsyncMock ):
1186- result = await bot_utils ._send_with_retry (mock_ctx , send )
1186+ result = await bot_utils .send_with_retry (mock_ctx , send )
11871187 assert result == "ok"
11881188 assert send .await_count == 2
0 commit comments