Skip to content

test(coverage): boost total coverage 65% → 71%#38

Merged
unohee merged 2 commits into
mainfrom
chore/boost-coverage
Jun 3, 2026
Merged

test(coverage): boost total coverage 65% → 71%#38
unohee merged 2 commits into
mainfrom
chore/boost-coverage

Conversation

@unohee

@unohee unohee commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

pytest 커버리지 총합을 65% → 71%로 끌어올림 (목표 70% + 1%p 마진).

⚠️ Depends on #37

본 PR은 #37의 `fix(test): mock httpx.request` 커밋을 cherry-pick으로 포함합니다 (cdbfd44). #37이 먼저 머지되면 자동으로 reconcile됩니다. 충돌 시 본 PR을 rebase하시면 됩니다.

Changes

영역 변경 결과
`kis_agent/responses/init.py` `futures.py` / `overseas_futures.py` re-export 추가. 두 파일은 TypedDict 정의만 모인 타입 힌팅 전용 모듈로 다른 `responses/*.py`와 동일하게 `init` import만으로 100% 커버 `responses/futures.py` 0%→100%, `responses/overseas_futures.py` 0%→100%
`tests/unit/test_cli_schema.py` (NEW) `get_schema()` 동작 커버: 전체 SDL 반환, 타입별 추출, unknown 타입 → 9 tests `cli/schema.py` 6%→97%
`tests/unit/test_ws_event_manager.py` (NEW) Observer 패턴 `EventManager` 동기/비동기 emit, 히스토리 cap, 리스너 등록/해제, async listener 예외 처리 → 13 tests `websocket/event_manager.py` 37%→100%
`tests/unit/test_ws_connection.py` (NEW) `ConnectionManager`의 connect/disconnect/send/recv/reconnect/is_alive/get_stats 분기를 AsyncMock으로 커버 → 19 tests `websocket/connection.py` 26%→100%

Coverage delta

  • Before: 9590 statements, 3368 missed → 65%
  • After: 9592 statements, 2824 missed → 71% (+6%p)
  • 38개 신규 테스트, 기존 테스트 영향 없음.

Test plan

  • `pytest tests/unit/test_cli_schema.py` — 9 passed
  • `pytest tests/unit/test_ws_event_manager.py` — 13 passed
  • `pytest tests/unit/test_ws_connection.py` — 19 passed
  • `pytest tests/unit/ --cov=kis_agent` — TOTAL 71%

Heewon Oh added 2 commits June 3, 2026 22:15
…uest tests

v1.6.1에서 KISClient.make_request가 requests → httpx로 교체되었으나
(commit 52cb530) 테스트의 mock 타겟이 그대로 requests.request에 머물러
실제 httpx 호출이 발생, 인증 실패로 JSON_DECODE_ERROR가 반환되며
make_request 계열 테스트들이 의도와 다르게 통과/실패하던 문제 수정.

변경:
- tests/unit/test_client.py: 6개 @patch("requests.request") → httpx.request.
  토큰 갱신용 @patch("requests.post")는 client.py:480이 여전히 requests.post를
  쓰므로 유지.
- tests/unit/test_client_comprehensive.py: 7개 with patch("requests.request")
  → httpx.request.

결과: test_client.py 22 passed, test_client_comprehensive.py 36 passed (58/58).
…ts + 3 new test files

목표 70% 달성 + 1%p 안전 마진.

변경 내역:

1. kis_agent/responses/__init__.py
   - futures.py(171줄) / overseas_futures.py(240줄) re-export 추가
   - 두 모듈은 TypedDict 정의만 모인 타입 힌팅 전용으로, 다른
     responses/*.py와 마찬가지로 __init__에서 import만 되면 100% 커버
   - 결과: responses/futures.py 0% → 100%, responses/overseas_futures.py 0% → 100%

2. tests/unit/test_cli_schema.py (NEW, 9 tests)
   - get_schema() 동작 커버: 전체 SDL 반환, 타입별 추출, unknown 타입
   - cli/schema.py 6% → 97%

3. tests/unit/test_ws_event_manager.py (NEW, 13 tests)
   - Observer 패턴 EventManager 동기/비동기 emit, 히스토리 capping,
     리스너 등록/해제/초기화, 비동기 listener exception 처리 등 커버
   - websocket/event_manager.py 37% → 100%

4. tests/unit/test_ws_connection.py (NEW, 19 tests)
   - ConnectionManager의 connect/disconnect/send/recv/reconnect/is_alive/
     get_stats 분기를 AsyncMock으로 커버. 재연결 시 지수 백오프 호출 검증
   - websocket/connection.py 26% → 100%

전체: TOTAL 65% → 71% (statements 9592, missed 2824).
38개 신규 테스트 추가, 기존 테스트 영향 없음.
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

📊 Coverage Analysis Report

Metric Value
Total Coverage 0%
Target Coverage 70%
Files Below Target 0

✅ All files meet the target coverage of 70%!

@unohee unohee merged commit 61fbcf1 into main Jun 3, 2026
7 checks passed
@unohee unohee deleted the chore/boost-coverage branch June 3, 2026 14:29
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