Files
portfolio-hub/docs/batches/bat-004_20260502_portfolio-create-user-required/verification.md
T
genichin a111fdd83f feat(REQ-014): add portfolio-create-user-required requirement and implementation
- Add docs/srs/Interface/req-014_portfolio-create-user-required.md with acceptance criteria
- Create docs/batches/bat-004_20260502_portfolio-create-user-required/ delivery batch
- Enhance app/cli/commands/portfolio.py: validate user_id parameter before portfolio creation
- Add comprehensive CLI tests in tests/test_cli.py for portfolio create validation flows
- Update docs/batches/index.md and docs/srs/index.md with new requirement/batch references
- Update README.md documentation
2026-05-02 13:45:46 +00:00

2.4 KiB

BAT-004 Verification

  • Status: verified
  • Batch: BAT-004
  • Profile: batch-lite

Architecture Impact Check

  • Design Gate (from planning.md): no — DB 스키마 변경 없음, HTTP API 변경 없음
  • Actual Architecture Impact: none confirmed — app/cli/commands/portfolio.py 내 기존 _with_service_and_repo 헬퍼 재사용, Protocol stub/구현체 변경 없음
  • Baseline Document Sync Required: no

Acceptance Mapping

AC 1: --user 없이 실행 → exit code 1 + 오류 메시지

항목 내용
Evidence test_cli_portfolio_create_without_user_exits_error
Verification runner.invoke(app, ["portfolio", "create", "005930:tv", "--symbol", "005930", "--force"]) → exit_code == 1, "--user" in result.stdout
Result ✅ PASSED

AC 2: --user alice → 생성된 포트폴리오의 owner_user_id가 alice UUID로 설정됨

항목 내용
Evidence test_cli_portfolio_create_with_valid_user_sets_owner
Verification alice user 생성 → --user alice --force 실행 → repo._portfolio.owner_user_id == user.id 확인
Result ✅ PASSED

AC 3: 존재하지 않는 username → 오류 메시지 + exit code 1

항목 내용
Evidence test_cli_portfolio_create_with_unknown_user_exits_error
Verification --user nobody → exit_code == 1, "nobody" in result.stdout
Result ✅ PASSED

AC 4: in-memory 모드에서도 동일 동작

항목 내용
Evidence test_cli_portfolio_create_with_valid_user_sets_owner (FakeRepo 사용)
Verification FakeRepo(in-memory) 환경에서 alice UUID가 owner_user_id로 설정됨 확인
Result ✅ PASSED

AC 5: 오류 형식이 기존 CLI와 일관성 유지

항목 내용
Evidence 코드 검토 — BAT-003 list_portfolios 구현과 동일한 패턴 사용
Verification --user 미입력 → ctx.obj.console.print(...) + raise typer.Exit(code=1), 미등록 user → ValueError → execute_command 핸들러 동일 경로
Result ✅ 충족

Test Execution

pytest tests/test_cli.py -v
44 passed in 1.37s

Regression

  • BAT-003 추가 테스트(portfolio list 관련 4개) 전원 PASSED — 회귀 없음
  • 기존 test_cli_create_buy_and_delete_flow, test_cli_write_command_prompts_before_create, test_cli_write_command_can_abort 수정 후 전원 PASSED