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
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
# BAT-004 Implementation
|
||||
|
||||
- Status: completed
|
||||
- Batch: BAT-004
|
||||
- Profile: batch-lite
|
||||
|
||||
## Plan Summary
|
||||
|
||||
- CLI `pfhub portfolio create`에 `--user <username>` 필수 옵션 추가
|
||||
- BAT-003에서 도입한 `_with_service_and_repo` 헬퍼 재사용
|
||||
- `repository.get_user_by_username(user)` 호출 → None이면 ValueError → exit code 1
|
||||
- `service.create_portfolio(payload, owner_user_id=owner.id)` 실제 user UUID 전달
|
||||
- README 예제 라인 갱신
|
||||
- 기존 테스트 3개 수정 + 신규 3개 추가
|
||||
|
||||
## Changed Files
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `app/cli/commands/portfolio.py` | `create_portfolio` 함수에 `--user` 옵션 추가, `_with_service` → `_with_service_and_repo` 교체, username→UUID 조회 후 `owner_user_id` 전달 |
|
||||
| `tests/test_cli.py` | `test_cli_create_buy_and_delete_flow`, `test_cli_write_command_prompts_before_create`, `test_cli_write_command_can_abort` 수정; AC 1~3 커버 신규 3개 케이스 추가 |
|
||||
| `README.md` | `pfhub portfolio create` → `pfhub portfolio create ... --user <username>` 갱신 |
|
||||
|
||||
## Execution Log
|
||||
|
||||
### 구현 결정 사항
|
||||
|
||||
- `--user` 옵션: `typer.Option(None, "--user", ...)` + 수동 None 체크로 exit code 1 보장 (BAT-003과 동일 패턴)
|
||||
- `_confirm` 호출 전에 None 체크를 배치하여 owner 미지정 시 확인 프롬프트 없이 즉시 종료
|
||||
- callback 내 username → user_id 조회: `repository.get_user_by_username(user)` → None이면 `ValueError`
|
||||
- `service.create_portfolio(payload, owner_user_id=owner.id)`: `portfolio_service.py` 시그니처 변경 불필요 (기존 키워드 인자 그대로 활용)
|
||||
|
||||
### 기존 테스트 수정
|
||||
|
||||
- `test_cli_create_buy_and_delete_flow`: alice user 생성 + `--user alice` 추가, `owner_user_id` 검증 BUY 전에 배치 (delete 후 `_portfolio`가 None이 되므로)
|
||||
- `test_cli_write_command_prompts_before_create`: alice user 생성 + `--user alice` 추가
|
||||
- `test_cli_write_command_can_abort`: alice user 생성 + `--user alice` 추가
|
||||
|
||||
## Validation
|
||||
|
||||
```
|
||||
pytest tests/test_cli.py -k "test_cli_portfolio_create or test_cli_create or test_cli_write_command" -v
|
||||
```
|
||||
|
||||
```
|
||||
6 passed
|
||||
```
|
||||
|
||||
```
|
||||
pytest tests/test_cli.py -v
|
||||
```
|
||||
|
||||
```
|
||||
44 passed in 1.37s (전체 회귀, 기존 테스트 전원 통과)
|
||||
```
|
||||
|
||||
## Remaining Risks
|
||||
|
||||
- 없음
|
||||
Reference in New Issue
Block a user