Skip to content

fix: align initialization tests with bundled-file-first logic#54

Merged
StatPan merged 2 commits intomasterfrom
fix/test-initialization-bundled-file
Mar 31, 2026
Merged

fix: align initialization tests with bundled-file-first logic#54
StatPan merged 2 commits intomasterfrom
fix/test-initialization-bundled-file

Conversation

@StatPan
Copy link
Copy Markdown
Owner

@StatPan StatPan commented Mar 30, 2026

Summary

  • ensure_master_list의 로직이 캐시 미존재 시 API 다운로드 대신 번들 파일(assemblymcp/specs/all_apis.json) 복사로 변경됐는데, 테스트가 업데이트되지 않아 1건 실패하고 있었음
  • BUNDLED_SPECS_FILE을 모듈 레벨 상수로 추출해 테스트에서 patch 가능하도록 수정
  • 기존 테스트 1개를 2개로 분리:
    • test_ensure_master_list_copies_bundled_if_missing — 번들 파일 복사 경로
    • test_ensure_master_list_downloads_if_bundled_also_missing — API 폴백 경로 (번들 상수 patch)

Test plan

  • pytest tests/test_fixes.py — 5/5 통과 확인
  • pytest tests/ — 67/67 전체 통과 확인

🤖 Generated with Claude Code

`ensure_master_list` was updated to copy the bundled `all_apis.json`
before falling back to an API download, but the existing test still
expected an API call in the no-cache scenario, causing a false failure.

- Extract `BUNDLED_SPECS_FILE` as a module-level constant so tests can
  patch it without touching `Path.__file__`
- Replace `test_ensure_master_list_downloads_if_missing` with two tests:
  - `test_ensure_master_list_copies_bundled_if_missing` — happy path
  - `test_ensure_master_list_downloads_if_bundled_also_missing` — API
    fallback path, patching the bundled file constant

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the initialization logic by introducing a constant for the bundled specifications file path and enhances the test suite to cover both bundled file copying and API download fallback scenarios. The review feedback suggests improving test reliability by performing direct file content comparisons instead of size checks and explicitly specifying UTF-8 encoding when reading files to ensure cross-platform consistency.

Comment thread tests/test_fixes.py Outdated

# Verify file was created from bundled specs
assert master_file.exists()
assert master_file.stat().st_size > 1000
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

파일 크기를 확인하는 것보다, 번들로 제공되는 원본 파일과 내용이 일치하는지 직접 비교하는 것이 더 견고한 테스트 방법입니다. 이렇게 하면 파일이 정확히 복사되었는지 확인할 수 있습니다.

아래와 같이 수정하고, 테스트 파일 상단에 from assemblymcp.initialization import BUNDLED_SPECS_FILE를 추가해주세요.

Suggested change
assert master_file.stat().st_size > 1000
assert master_file.read_text(encoding="utf-8") == BUNDLED_SPECS_FILE.read_text(encoding="utf-8")

Comment thread tests/test_fixes.py Outdated
assert master_file.exists()

# Verify content
with open(master_file) as f:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

ensure_master_list 함수에서 파일을 'utf-8' 인코딩으로 저장하므로, 테스트에서도 동일한 인코딩을 명시하여 읽는 것이 안전합니다. 이렇게 하면 시스템 기본 인코딩에 따라 테스트가 실패하는 경우를 방지할 수 있습니다.

Suggested change
with open(master_file) as f:
with open(master_file, encoding="utf-8") as f:

- Compare copied file content directly against BUNDLED_SPECS_FILE
  instead of checking file size (more robust assertion)
- Specify encoding="utf-8" when opening master_file to avoid
  platform-default encoding issues

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@StatPan StatPan merged commit fd8f3b5 into master Mar 31, 2026
1 of 2 checks passed
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.

1 participant