feat(books): add stats, export, year validation, and partial author search#2
Open
xavierxmorris wants to merge 5 commits into
Open
feat(books): add stats, export, year validation, and partial author search#2xavierxmorris wants to merge 5 commits into
xavierxmorris wants to merge 5 commits into
Conversation
Covers all BookCollection methods with edge cases: - Book dataclass creation and equality - load_books (empty, missing, corrupted JSON, valid data) - save_books (round-trip persistence) - add_book (happy path, multiple, boundary inputs) - list_books (empty, populated, reference identity) - find_book_by_title (exact, case-insensitive, not found) - mark_as_read (happy path, only-target, persistence) - remove_book (happy path, only-target, persistence) - find_by_author (exact, case-insensitive, multi-match) - Integration workflows (full CRUD, persistence round-trip) 49 tests, all passing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Duplicate book handling (add, find, remove behavior) - Partial title removal (exact match only, no substring) - Empty collection searches (all methods graceful) - File permission errors during save - Concurrent access with threading 24 tests, all passing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Year validation: - add_book() rejects year <= 0 or > current year + 1 - parse_year() validates range with clear error messages - Raises InvalidBookDataError for invalid years Partial author search: - find_by_author() now uses substring matching (in) instead of exact (==) - Searching 'Herbert' now finds 'Frank Herbert' Tests: - 18 new year validation tests (test_year_validation.py) - 21 new partial author match tests (test_find_by_author_partial.py) - Updated 4 existing test files for new behavior - 297 total tests passing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add statistics functions (total, read/unread count, read percentage, year range, books per author, average year, formatted report) and export utilities (CSV string, CSV file, JSON file, dict conversion). Includes comprehensive test suites: 43 tests for stats, 19 for export, and year-range search tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Adds year validation, partial author search, collection statistics, and export utilities to the book-app-project sample — along with comprehensive test coverage.
Changes
Features
add_book()now rejects years outside 1–next year;parse_year()in utils validates at the UI layerfind_by_author()now uses substring matching (case-insensitive)find_by_year_range()method onBookCollectionstats.py) — 8 pure functions:total_books,read_count,unread_count,read_percentage,year_range,books_per_author,average_year,format_stats_reportexport.py) — CSV and JSON export:books_to_csv_string,export_books_to_csv,books_to_dicts,export_books_to_jsonTests
test_year_validation.py— domain and UI year validation (19 tests)test_find_by_author_partial.py— partial/case-insensitive author search (21 tests)test_find_by_year_range.py— year-range search coveragetest_stats.py— full stats module coverage (43 tests)test_export.py— full export module coverage (19 tests)test_books_all.py,test_books_comprehensive.py,test_find_by_author.py,test_get_book_details.py) for new behaviorDocumentation
.github/copilot-instructions.mdwith architecture section, build commands, and known-pattern suppression listHow to Test