Skip to content

test: add comprehensive backend test suite (151 tests) - #10

Merged
ZhenhangTung merged 5 commits into
mainfrom
copilot/add-test-cases-core-logic
Feb 25, 2026
Merged

test: add comprehensive backend test suite (151 tests)#10
ZhenhangTung merged 5 commits into
mainfrom
copilot/add-test-cases-core-logic

Conversation

Copilot AI commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Adds test coverage for all core backend logic across accounts, design_system, and MCP modules.

Test infrastructure

  • config/test_settings.py — SQLite in-memory, locmem cache, InMemoryStorage, fast password hasher

Test coverage

  • Accounts (36 tests) — User/UserAPIKey models, serializers (registration, login, password, API key masking), API endpoints (auth flow, JWT tokens, API key CRUD with 10-key limit, user isolation)
  • Design System models (12 tests)get_primary_color() fallback logic, get_initial(), status defaults, image path generation, auto file_size population
  • Schema (9 tests) — Pydantic validation (valid/invalid/out-of-range), convert_to_frontend_format snake→camelCase mapping, Gemini/OpenRouter schema shapes
  • Services (8 tests)generate_css_variables(), generate_tailwind_config(), _merge_results() color/styleRules merging
  • Task helpers (11 tests)_parse_llm_json() with json_repair, _extract_style_from_text() keyword detection (6 styles), merge_design_systems(), merge_color_dicts()
  • Serializers (7 tests) — Base64 image upload (with/without data URL prefix, invalid data), image count validation
  • API views (12 tests) — CRUD, two-user isolation, image upload/delete error paths
  • MCP tool calls (6 tests)call_tool for design system/aesthetic guidance, empty analysis fallback, unknown tool, missing design system

Run

cd backend && uv run python -m pytest --ds=config.test_settings -v
Original prompt

能否为我设计并实现测试用例,保障核心逻辑正确


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add test cases to ensure core logic correctness test: add comprehensive backend test suite (151 tests) Feb 19, 2026
Copilot AI requested a review from ZhenhangTung February 19, 2026 02:30
Copilot AI and others added 4 commits February 25, 2026 14:46
…views

Cover User model, UserAPIKey model, all serializers, and API endpoints
including registration, login, logout, password change, and API key CRUD.

55 tests total: 16 unit tests (mocked), 9 serializer tests (DB), and
30 API integration tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ices, tasks, serializers, views, and MCP

Add 83 tests across two files:
- tests.py: model, schema, service, task helper, serializer, and API tests
- mcp/test_server_calls.py: MCP server call_tool and get_tools tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ZhenhangTung
ZhenhangTung force-pushed the copilot/add-test-cases-core-logic branch from b8630f7 to 4852033 Compare February 25, 2026 07:26
@ZhenhangTung
ZhenhangTung marked this pull request as ready for review February 25, 2026 07:26
@ZhenhangTung
ZhenhangTung merged commit 25ae314 into main Feb 25, 2026
2 checks passed
@ZhenhangTung
ZhenhangTung deleted the copilot/add-test-cases-core-logic branch February 25, 2026 07:30
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.

2 participants