From 6d5cda5d51af1eff3ebebf5053184a7b6dc6feb3 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 13 May 2026 21:03:48 +0800 Subject: [PATCH] fix https://github.com/jxxghp/MoviePilot/issues/5663 --- tests/test_agent_image_support.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_agent_image_support.py b/tests/test_agent_image_support.py index c4297acd..a691df0c 100644 --- a/tests/test_agent_image_support.py +++ b/tests/test_agent_image_support.py @@ -18,6 +18,7 @@ from app.agent.llm import LLMHelper from app.helper.voice import VoiceHelper from app.modules.discord import DiscordModule from app.modules.qqbot import QQBotModule +from app.modules.qqbot.qqbot import QQBot from app.modules.slack import SlackModule from app.modules.telegram.telegram import Telegram from app.modules.telegram import TelegramModule @@ -1028,6 +1029,25 @@ class AgentImageSupportTest(unittest.TestCase): self.assertEqual([image.ref for image in message.images], ["https://example.com/qq-image.png"]) self.assertEqual(message.images[0].mime_type, "image/png") + def test_qq_markdown_image_size_preserves_poster_ratio(self): + with patch.object(QQBot, "_get_image_size", return_value=(1000, 1500)): + content, use_markdown = QQBot._format_message_markdown( + title="poster", + image="https://example.com/poster.jpg", + ) + + self.assertTrue(use_markdown) + self.assertIn("![image #341px #512px](https://example.com/poster.jpg)", content) + + def test_qq_markdown_image_uses_poster_ratio_fallback(self): + with patch.object(QQBot, "_get_image_size", return_value=None): + content, use_markdown = QQBot._format_message_markdown( + image="https://example.com/poster.jpg", + ) + + self.assertTrue(use_markdown) + self.assertEqual(content, "![image #208px #320px](https://example.com/poster.jpg)") + def test_qq_message_parser_accepts_audio_only_attachment(self): module = QQBotModule()