mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
style(pre-commit)
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
共享模块 - 通用工具和常量
|
||||
"""
|
||||
|
||||
from .constants import *
|
||||
from .constants import ContentType, Platform, ReportFormat, TaskStatus
|
||||
from .trace_context import TraceContext
|
||||
|
||||
__all__ = [
|
||||
"TraceContext",
|
||||
# 常量通过 * 导出
|
||||
"Platform",
|
||||
"TaskStatus",
|
||||
"ContentType",
|
||||
"ReportFormat",
|
||||
]
|
||||
|
||||
@@ -11,8 +11,8 @@ astrbot_root = os.path.abspath(os.path.join(plugin_root, "../../../"))
|
||||
if astrbot_root not in sys.path:
|
||||
sys.path.insert(0, astrbot_root)
|
||||
|
||||
from src.core.bot_manager import BotManager
|
||||
from src.infrastructure.platform.factory import PlatformAdapterFactory
|
||||
from src.core.bot_manager import BotManager # noqa: E402
|
||||
from src.infrastructure.platform.factory import PlatformAdapterFactory # noqa: E402
|
||||
|
||||
class TestBotManagerLazyLoad(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ astrbot_root = os.path.abspath(os.path.join(plugin_root, "../../../"))
|
||||
if astrbot_root not in sys.path:
|
||||
sys.path.insert(0, astrbot_root)
|
||||
|
||||
from src.core.bot_manager import BotManager
|
||||
from src.core.bot_manager import BotManager # noqa: E402
|
||||
|
||||
class TestBotManagerMetadata(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
@@ -17,11 +17,8 @@ if astrbot_root not in sys.path:
|
||||
print(f"Added to sys.path: {plugin_root}, {astrbot_root}")
|
||||
|
||||
try:
|
||||
from src.infrastructure.platform.factory import PlatformAdapterFactory
|
||||
from src.infrastructure.platform.base import PlatformAdapter
|
||||
from src.infrastructure.platform.adapters.discord_adapter import DiscordAdapter, DISCORD_CAPABILITIES
|
||||
from src.application.analysis_orchestrator import AnalysisOrchestrator
|
||||
from src.domain.value_objects.unified_message import UnifiedMessage
|
||||
from src.infrastructure.platform.factory import PlatformAdapterFactory # noqa: E402
|
||||
from src.infrastructure.platform.adapters.discord_adapter import DiscordAdapter # noqa: E402
|
||||
except ImportError as e:
|
||||
print(f"Import Error: {e}")
|
||||
print(f"sys.path: {sys.path}")
|
||||
|
||||
@@ -13,7 +13,6 @@ try:
|
||||
AutoScheduler,
|
||||
)
|
||||
from astrbot_plugin_qq_group_daily_analysis.main import QQGroupDailyAnalysis
|
||||
from astrbot.api.event import filter
|
||||
except ImportError as e:
|
||||
print(f"ImportError in Docker: {e}")
|
||||
# Fallback to local paths if testing locally
|
||||
@@ -22,7 +21,6 @@ except ImportError as e:
|
||||
AutoScheduler,
|
||||
)
|
||||
from astrbot_plugin_qq_group_daily_analysis.main import QQGroupDailyAnalysis
|
||||
from astrbot.api.event import filter
|
||||
|
||||
|
||||
class TestPhase3Docker(unittest.IsolatedAsyncioTestCase):
|
||||
@@ -98,13 +96,13 @@ class TestPhase3Docker(unittest.IsolatedAsyncioTestCase):
|
||||
) as MockBotManager,
|
||||
patch(
|
||||
"astrbot_plugin_qq_group_daily_analysis.main.MessageAnalyzer"
|
||||
) as MockMessageAnalyzer,
|
||||
),
|
||||
patch(
|
||||
"astrbot_plugin_qq_group_daily_analysis.main.ReportGenerator"
|
||||
) as MockReportGenerator,
|
||||
),
|
||||
patch(
|
||||
"astrbot_plugin_qq_group_daily_analysis.main.RetryManager"
|
||||
) as MockRetryManager,
|
||||
),
|
||||
patch(
|
||||
"astrbot_plugin_qq_group_daily_analysis.main.AutoScheduler"
|
||||
) as MockAutoScheduler,
|
||||
|
||||
@@ -42,9 +42,9 @@ anthropic.types = anthropic_types
|
||||
|
||||
httpx = mock_package("httpx")
|
||||
|
||||
import asyncio
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock, patch
|
||||
import asyncio # noqa: E402
|
||||
import unittest # noqa: E402
|
||||
from unittest.mock import AsyncMock, patch # noqa: E402
|
||||
|
||||
# Adjust path to include the plugin directory
|
||||
sys.path.append(
|
||||
@@ -55,9 +55,9 @@ sys.path.append(r"c:\Helianthus\astrpro\AstrBot-master")
|
||||
sys.path.append("/AstrBot")
|
||||
sys.path.append("/AstrBot/data/plugins/astrbot_plugin_qq_group_daily_analysis")
|
||||
|
||||
from src.scheduler.auto_scheduler import AutoScheduler
|
||||
from main import QQGroupDailyAnalysis
|
||||
from astrbot.api.event import filter # Import to ensure decorators work
|
||||
from src.scheduler.auto_scheduler import AutoScheduler # noqa: E402
|
||||
from main import QQGroupDailyAnalysis # noqa: E402
|
||||
from astrbot.api.event import filter # noqa: E402, F401
|
||||
|
||||
|
||||
class TestPhase3(unittest.IsolatedAsyncioTestCase):
|
||||
@@ -117,11 +117,11 @@ class TestPhase3(unittest.IsolatedAsyncioTestCase):
|
||||
with (
|
||||
patch("main.ConfigManager") as MockConfigManager,
|
||||
patch("main.BotManager") as MockBotManager,
|
||||
patch("main.MessageAnalyzer") as MockMessageAnalyzer,
|
||||
patch("main.ReportGenerator") as MockReportGenerator,
|
||||
patch("main.MessageAnalyzer"),
|
||||
patch("main.ReportGenerator"),
|
||||
patch("main.RetryManager") as MockRetryManager,
|
||||
patch("main.AutoScheduler") as MockAutoScheduler,
|
||||
patch("main.TraceLogFilter") as MockLogFilter,
|
||||
patch("main.TraceLogFilter"),
|
||||
):
|
||||
# Setup mocks
|
||||
mock_auto_scheduler_instance = MockAutoScheduler.return_value
|
||||
|
||||
Reference in New Issue
Block a user