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,50 @@
|
||||
# BAT-004 Planning
|
||||
|
||||
- Status: confirmed
|
||||
- Batch: BAT-004
|
||||
- Profile: batch-lite
|
||||
|
||||
## Included REQ
|
||||
|
||||
- REQ-014: CLI `portfolio create --user` 필수화 및 소유자 설정
|
||||
|
||||
## Out of Scope
|
||||
|
||||
- HTTP API `POST /portfolios` owner 설정 변경
|
||||
- `owner_user_id` 기본값(`"system"`) 서비스 레이어 변경
|
||||
|
||||
## 구현 순서
|
||||
|
||||
### 1단계: CLI 명령 수정
|
||||
|
||||
- `app/cli/commands/portfolio.py` — `create_portfolio` 명령 수정
|
||||
- `user: str | None = typer.Option(None, "--user", help="Owner username (required).")` 추가
|
||||
- `_with_service_and_repo` 콜백으로 교체
|
||||
- callback 내부:
|
||||
- `user is None` → `console.print(...)` + `raise typer.Exit(code=1)`
|
||||
- `repository.get_user_by_username(user)` → `None`이면 `raise ValueError(...)`
|
||||
- `service.create_portfolio(payload, owner_user_id=owner.id)` 호출
|
||||
|
||||
### 2단계: README 수정
|
||||
|
||||
- `README.md` — `pfhub portfolio create` 예제 라인에 `--user alice` 추가
|
||||
|
||||
### 3단계: 테스트
|
||||
|
||||
- `tests/test_cli.py`
|
||||
- `test_cli_create_buy_and_delete_flow`: `--user alice` 추가, repo에 alice 생성
|
||||
- `test_cli_write_command_prompts_before_create`: 동일 수정
|
||||
- `test_cli_write_command_can_abort`: 동일 수정
|
||||
- `test_cli_portfolio_create_without_user_exits_error` (신규)
|
||||
- `test_cli_portfolio_create_with_valid_user_sets_owner` (신규)
|
||||
- `test_cli_portfolio_create_with_unknown_user_exits_error` (신규)
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Internal: `_with_service_and_repo` (BAT-003 도입, 이미 존재)
|
||||
- External: 없음
|
||||
|
||||
## Design Gate
|
||||
|
||||
- Design Required Before Implementation: no
|
||||
- Reason: 기존 `_with_service_and_repo` 패턴 재사용. 구조/스키마 변경 없음.
|
||||
Reference in New Issue
Block a user