Skip to content

test: mock plugin market requests in dashboard tests - #10062

Open
lingyun14beta wants to merge 1 commit into
AstrBotDevs:masterfrom
lingyun14beta:fix/mock-plugin-market-tests
Open

test: mock plugin market requests in dashboard tests#10062
lingyun14beta wants to merge 1 commit into
AstrBotDevs:masterfrom
lingyun14beta:fix/mock-plugin-market-tests

Conversation

@lingyun14beta

@lingyun14beta lingyun14beta commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

fix #10058

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Mock plugin market network calls in dashboard tests to ensure reliable, self-contained test results.

Bug Fixes:

  • Make dashboard plugin tests independent of external plugin market availability by mocking market requests with deterministic fixture responses.

Tests:

  • Add assertions that the dashboard plugin market endpoint returns the configured fixture plugin.

tests/test_dashboard.py::test_plugins hit the live plugin marketplace, so its
result depended on whether the runner could reach api.soulter.top. Mock the
aiohttp session used by PluginService so the case runs deterministically
offline, and assert the market payload actually reaches the API response.

Refs AstrBotDevs#10058

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@kilisamemarisaaa kilisamemarisaaa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified at b024f86. The fake session matches the async context-manager/get/json protocol used by both the market fetch and MD5 check, and the fixture-key assertion confirms the endpoint returns the supplied data instead of merely returning HTTP 200.

Independent local validation on Windows:

  • Targeted test_plugins: 1 passed.
  • Repeated with a temporary test-scoped guard rejecting non-loopback socket connect/connect_ex and DNS resolution, with a teardown assertion to catch swallowed attempts: 1 passed, zero recorded external attempts.
  • Same guard against base 7ec39bd: the test fails and records an api.soulter.top attempt, confirming the guard exercises the original problem.
  • Ruff check and format --check for tests/test_dashboard.py: passed.

This validation is specifically for test_plugins, not a claim that the entire test suite is network-independent. No blocking findings in this scoped change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 让测试套件不依赖外网(补齐市场请求的 mock)

2 participants