fix: align initialization tests with bundled-file-first logic#54
Merged
fix: align initialization tests with bundled-file-first logic#54
Conversation
`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>
There was a problem hiding this comment.
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.
|
|
||
| # Verify file was created from bundled specs | ||
| assert master_file.exists() | ||
| assert master_file.stat().st_size > 1000 |
There was a problem hiding this comment.
파일 크기를 확인하는 것보다, 번들로 제공되는 원본 파일과 내용이 일치하는지 직접 비교하는 것이 더 견고한 테스트 방법입니다. 이렇게 하면 파일이 정확히 복사되었는지 확인할 수 있습니다.
아래와 같이 수정하고, 테스트 파일 상단에 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") |
| assert master_file.exists() | ||
|
|
||
| # Verify content | ||
| with open(master_file) 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ensure_master_list의 로직이 캐시 미존재 시 API 다운로드 대신 번들 파일(assemblymcp/specs/all_apis.json) 복사로 변경됐는데, 테스트가 업데이트되지 않아 1건 실패하고 있었음BUNDLED_SPECS_FILE을 모듈 레벨 상수로 추출해 테스트에서patch가능하도록 수정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