From b343381fea3eab26e334a1b3bba202d715f9ea2e Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 19 Apr 2026 15:44:33 +0200 Subject: test: improve test assertions and edge cases --- tests/cogs/test_web.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/cogs/test_web.py') diff --git a/tests/cogs/test_web.py b/tests/cogs/test_web.py index 53a44e5..e0d2208 100644 --- a/tests/cogs/test_web.py +++ b/tests/cogs/test_web.py @@ -13,7 +13,7 @@ def web_cog(bot): @pytest.mark.asyncio async def test_web_command_success(web_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + mock_response = MagicMock() mock_response.status_code = 200 mock_response.text = ''' @@ -22,7 +22,7 @@ async def test_web_command_success(web_cog, mock_channel, mock_guild, bot): Test Result 2 ''' - + with patch('cogs.web.requests.get', return_value=mock_response) as mock_get: with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await web_cog.web.callback(web_cog, ctx, query="test query") @@ -33,11 +33,11 @@ async def test_web_command_success(web_cog, mock_channel, mock_guild, bot): @pytest.mark.asyncio async def test_web_command_no_results(web_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + mock_response = MagicMock() mock_response.status_code = 200 mock_response.text = '' - + with patch('cogs.web.requests.get', return_value=mock_response): with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await web_cog.web.callback(web_cog, ctx, query="test") @@ -47,11 +47,11 @@ async def test_web_command_no_results(web_cog, mock_channel, mock_guild, bot): @pytest.mark.asyncio async def test_web_command_http_error(web_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + mock_response = MagicMock() mock_response.status_code = 500 - + with patch('cogs.web.requests.get', return_value=mock_response): with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await web_cog.web.callback(web_cog, ctx, query="test") - mock_respond.assert_called_once_with(content="Error: 500", ephemeral=True) \ No newline at end of file + mock_respond.assert_called_once_with(content="Error: 500", ephemeral=True) -- cgit v1.2.3