Skip to content

Walk/nowakfli/ex2 coverage surfacing#130

Closed
nowakfli wants to merge 24 commits into
github:mainfrom
nowakfli:walk/nowakfli/ex2-coverage-surfacing
Closed

Walk/nowakfli/ex2 coverage surfacing#130
nowakfli wants to merge 24 commits into
github:mainfrom
nowakfli:walk/nowakfli/ex2-coverage-surfacing

Conversation

@nowakfli
Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings May 19, 2026 21:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Python “book app” sample with improved input validation/resilience, adds tests to surface coverage for utils.py and CLI behaviors, and introduces an ai-track-docs/ documentation set to guide verification, toggles, and exercise hygiene.

Changes:

  • Refactors utils.py year parsing into a dedicated helper and adds unit tests for utils and CLI flows.
  • Adds runtime validation + resilience improvements to the Python CLI and persistence layer (structured logs, env toggle, OSError handling, input validation).
  • Adds multiple “track docs” and local scripts/benchmarks to standardize testing, benchmarking, and exercise documentation.

Reviewed changes

Copilot reviewed 22 out of 24 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
samples/book-app-project/utils.py Adds docstrings and extracts year parsing into parse_year() used by get_book_details().
samples/book-app-project/tests/test_utils.py New pytest coverage for parse_year() and get_book_details() input handling.
samples/book-app-project/tests/test_books.py Adds tests for validation errors, CLI add flow behaviors, logging, display toggle, and load error resilience.
samples/book-app-project/run_tests.py Adds a small wrapper script to run pytest from the sample directory.
samples/book-app-project/pyproject.toml Pins pytest to a bounded major range (>=8,<9).
samples/book-app-project/books.py Adds OSError handling in load_books() and validates inputs in add_book().
samples/book-app-project/book_app.py Adds structured logging for handle_add() and an env toggle for displaying the year in list output.
samples/book-app-project/benchmark_list_books.py Adds a micro-benchmark script for BookCollection.list_books().
ai-track-docs/toggles.md Documents the BOOK_APP_SHOW_YEAR toggle and local verification commands.
ai-track-docs/SYSTEM-OVERVIEW.md Adds a repo/system overview focused on the sample apps and test approach.
ai-track-docs/static-analysis.md Documents the current lack of Python lint/static-analysis tooling and suggested checks.
ai-track-docs/security.md Documents secret/cert hygiene and the .gitignore updates for common secret artifacts.
ai-track-docs/resilience.md Documents the load_books() resilience improvement and how to verify it via tests.
ai-track-docs/pr-hygiene.md Adds PR review/evidence/rollback guidance for the Crawl track exercises.
ai-track-docs/perf-baseline.md Captures a baseline benchmark process and example results for list_books().
ai-track-docs/logging.md Documents the structured logging path for the CLI add flow and verification steps.
ai-track-docs/extending-utils.md Provides guidance/examples for extending utils.py and testing input helpers.
ai-track-docs/dependencies.md Documents dependency policy and current gaps for the Python sample.
ai-track-docs/build-test.md Adds consolidated build/test commands and a baseline verification section.
ai-track-docs/BACKLOG-EX12.md Captures follow-up backlog items (dependency separation, broader structured logs, etc.).
ai-track-docs/architecture.mmd Adds a Mermaid diagram describing repo components and relationships.
.gitignore Expands ignore rules for secret/cert artifacts and adjusts a blog-related ignore entry.
.copilot-track/crawl/README.md Adds Crawl track guidance (branch naming, evidence expectations, workflow).

Comment thread ai-track-docs/toggles.md
Comment on lines +19 to +23
```bash
cd samples/book-app-project
$env:BOOK_APP_SHOW_YEAR="1"
python book_app.py list
```
Comment on lines +45 to +49
### Run Tests with Coverage Report
```bash
cd samples/book-app-project
pytest tests/ --cov=. --cov-report=term-missing
```
Comment on lines +67 to +68
git clone https://github.com/<your-username>/copilot-cli-for-beginners-mnf.git
cd copilot-cli-for-beginners-mnf/samples/book-app-project
Comment on lines +116 to +117
- Input functions return validated data to the main application logic</content>
<parameter name="filePath">c:\crawl-walk-run\copilot-cli-for-beginners-mnf\ai-track-docs\extending-utils.md No newline at end of file
Comment on lines +24 to +47
**Python Book App Structure:**
```
samples/book-app-project/
├── book_app.py # Main CLI handler (menu, user I/O)
├── books.py # BookCollection class + persistence (data.json)
├── utils.py # UI helpers (print_menu, get_user_choice, format output)
├── data.json # Persistent storage (book list)
└── tests/
└── test_books.py # Unit tests for BookCollection
```

**Key Components:**
- `BookCollection` — in-memory list with JSON persistence
- `Book` — dataclass representing a single book
- CLI handlers — user input/output management

## Test Approach

**Framework:** pytest (Python 3.10+)

**Test Coverage:**
- `samples/book-app-project/tests/test_books.py` — unit tests for `BookCollection`
- Uses monkeypatch fixture to isolate tests with temp data files
- Covers: add, list, find, mark-as-read, invalid operations
@DanWahlin
Copy link
Copy Markdown
Collaborator

Thank you, but this isn’t something we’re looking to as to the course right now so going to close this PR.

@DanWahlin DanWahlin closed this May 20, 2026
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.

3 participants