Walk/nowakfli/ex2 coverage surfacing#130
Closed
nowakfli wants to merge 24 commits into
Closed
Conversation
GHCP — Crawl: Ex0 bootstrap
GHCP — Crawl: Ex1 repo-orientation
…eline GHCP — Crawl: Ex2 build-test-baseline
GHCP — Crawl: Ex3 tiny-refactor
…sync GHCP — Crawl: Ex4 documentation-sync
Contributor
There was a problem hiding this comment.
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.pyyear 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,
OSErrorhandling, 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 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 |
Collaborator
|
Thank you, but this isn’t something we’re looking to as to the course right now so going to close this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.