Rework core functionality, add CLI and tests
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
## User's Priorities (March 2026)
|
||||
1. ✅ **Fix the domain and data model**
|
||||
2. ✅ **Make sure everything related to the database is good**
|
||||
3. 🚧 **Make a CLI so I can test things manually** (In Progress)
|
||||
4. **Make sure search and other basic functionality is good and can be accessed through CLI**
|
||||
5. **Set up automated tests**
|
||||
6. **Fully rework the GUI**
|
||||
3. ✅ **Make a CLI so I can test things manually**
|
||||
4. ✅ **Make sure search and other basic functionality is good and can be accessed through CLI**
|
||||
5. ✅ **Set up automated tests**
|
||||
6. **Make sure search and other basic functionality is good**
|
||||
7. **Fully rework the GUI**
|
||||
|
||||
*Everything else will come later.*
|
||||
|
||||
@@ -51,44 +52,77 @@ Wishlist(id, user_id, book_id, wishlisted_date)
|
||||
|
||||
---
|
||||
|
||||
## 🚧 IN PROGRESS: CLI Development (Phase 3)
|
||||
## ✅ COMPLETED: CLI Development (Phase 3)
|
||||
|
||||
### CLI Requirements for Manual Testing
|
||||
- [ ] Book CRUD operations (add, edit, delete, list)
|
||||
- [ ] Author/Genre management (auto-create, list)
|
||||
- [ ] Location management (place, bookshelf, shelf)
|
||||
- [ ] Reading tracking (start, finish, rate)
|
||||
- [ ] Search functionality testing
|
||||
- [ ] Data import from old format
|
||||
- [ ] Loaning operations
|
||||
### CLI Implementation ✅ DONE
|
||||
- ✅ **Business logic separation**: Clean `services.py` module independent from web concerns
|
||||
- ✅ **Book CRUD operations**: Create, read, update, delete books with proper validation
|
||||
- ✅ **Author/Genre management**: Auto-create on-demand with many-to-many relationships
|
||||
- ✅ **Location management**: Place, bookshelf, shelf hierarchy with filtering
|
||||
- ✅ **Reading tracking**: Start, finish, drop, rate reading sessions
|
||||
- ✅ **Wishlist operations**: Add, remove, list wishlist items
|
||||
- ✅ **Advanced search**: pyparsing-based query language with field filters and comparison operators
|
||||
- ✅ **ISBN import**: Google Books API integration for book metadata
|
||||
- ✅ **Database utilities**: Status, initialization, seed data commands
|
||||
- ✅ **Output formats**: Human-readable tables and JSON for scripting
|
||||
|
||||
### CLI Commands Planned
|
||||
### Advanced Search Language ✅ IMPLEMENTED
|
||||
```bash
|
||||
hx book add "Title" --authors "Author1,Author2" --genres "Fiction"
|
||||
hx book list --location "my house" --shelf 2
|
||||
hx book search "keyword"
|
||||
hx reading start <book_id>
|
||||
hx reading finish <book_id> --rating 4
|
||||
hx loan <book_id> --to "Alice"
|
||||
# Working CLI commands:
|
||||
hxbooks book add "Title" --owner alice --authors "Author1,Author2" --genres "Fiction"
|
||||
hxbooks book list --place "home" --bookshelf "office" --shelf 2
|
||||
hxbooks book search "author:tolkien genre:fantasy"
|
||||
hxbooks book search "shelf>=5 title:\"Lord of Rings\""
|
||||
hxbooks book search -- "-genre:romance" # Negation
|
||||
hxbooks reading start <book_id> --owner alice
|
||||
hxbooks reading finish <book_id> --rating 4 --comments "Great book!"
|
||||
hxbooks wishlist add <book_id> --owner alice
|
||||
hxbooks book import 9780441172719 --owner alice # ISBN import
|
||||
```
|
||||
|
||||
### Search Query Language Features
|
||||
- **Field-specific searches**: `author:tolkien`, `genre:"science fiction"`
|
||||
- **Comparison operators**: `shelf>=5`, `added>=2025-01-01`, `rating>3`
|
||||
- **Quoted strings**: `title:"The Lord of the Rings"`
|
||||
- **Negation**: `-genre:romance`
|
||||
- **Date comparisons**: `added>=2026-03-01`, `bought<2025-12-31`
|
||||
- **Multiple filters**: `author:herbert genre:scifi owner:alice`
|
||||
|
||||
---
|
||||
|
||||
## ✅ COMPLETED: Automated Testing (Phase 4)
|
||||
|
||||
### Testing Framework ✅ IMPLEMENTED
|
||||
- ✅ **pytest infrastructure**: Database fixtures, isolated test environments
|
||||
- ✅ **CLI command tests**: All 18 commands with happy paths and error scenarios (29+ tests)
|
||||
- ✅ **Advanced search tests**: Parametrized tests for field filters and complex queries
|
||||
- ✅ **Query parser unit tests**: Type conversion, operator logic, edge cases (36 tests)
|
||||
- ✅ **Output format validation**: JSON and table formats for all commands
|
||||
- ✅ **Database integration**: Full CLI → services → database → relationships flow testing
|
||||
- ✅ **Error handling tests**: Invalid inputs, missing data, constraint violations
|
||||
|
||||
### Test Coverage Achieved
|
||||
- **CLI Integration**: Book CRUD, reading tracking, wishlist operations, database utilities
|
||||
- **Search functionality**: String filters, numeric filters, date filters, negation, complex queries
|
||||
- **Parser robustness**: Edge cases, type conversion, fallback behavior, unicode support
|
||||
- **Database validation**: Relationship integrity, user creation, data persistence
|
||||
|
||||
**Decision**: Migration tests deemed unnecessary for this simple personal app
|
||||
**Status**: 65+ tests passing, comprehensive coverage for critical functionality
|
||||
|
||||
---
|
||||
|
||||
## 📋 TODO: Remaining Phases
|
||||
|
||||
### Phase 4: Search & Core Features
|
||||
- [ ] Implement proper FTS with new schema
|
||||
- [ ] Add faceted search (by author, genre, location)
|
||||
- [ ] Create search result serializers
|
||||
- [ ] Add pagination
|
||||
- [ ] Optimize query performance with proper indexes
|
||||
|
||||
### Phase 5: Testing Framework
|
||||
- [ ] Set up pytest with database fixtures
|
||||
- [ ] API endpoint tests
|
||||
- [ ] Search functionality tests
|
||||
- [ ] CLI command tests
|
||||
- [ ] Migration tests
|
||||
### Phase 5: Search & Core Features Enhancement
|
||||
- [ ] Full-text search (FTS) integration with SQLite
|
||||
- [ ] Search result pagination and sorting
|
||||
- [ ] Boolean operators (AND, OR, NOT) in search queries
|
||||
- [ ] Parentheses grouping: `(genre:fantasy OR genre:scifi) AND rating>=4`
|
||||
- [ ] Search performance optimization with proper indexes
|
||||
- [ ] Autocomplete for field values (authors, genres, locations)
|
||||
- [ ] Search result highlighting and snippets
|
||||
- [ ] Saved search management improvements
|
||||
|
||||
### Phase 6: GUI Rework
|
||||
- [ ] Update templates for new data model
|
||||
@@ -118,8 +152,8 @@ hx loan <book_id> --to "Alice"
|
||||
|
||||
---
|
||||
|
||||
*Last updated: March 14, 2026*
|
||||
*Status: Phase 1-2 Complete ✅ | Phase 3 In Progress 🚧*
|
||||
*Last updated: March 16, 2026*
|
||||
*Status: Phases 1-4 Complete ✅ | Ready for Phase 5 🚀*
|
||||
|
||||
### Medium Priority Issues (Priority 3-4: CLI & Search)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user