Open
Conversation
Fixes #4
…late services - Implement integration tests for force_service.py covering CRUD operations, lance management, miniature assignment, active force invariants, and import/export functionality. - Add unit tests for force_service.py focusing on basic CRUD operations, edge cases, and error handling. - Create integration tests for lance_template_service.py including CRUD operations, pattern matching, and import/export scenarios. - Develop unit tests for lance_template_service.py emphasizing CRUD operations, pattern matching, and error handling during imports.
…fill next available ID
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive faction support to the miniature inventory system, including UI filtering, database schema updates, and an extensive test suite covering the service layer.
Key Changes:
- Added faction field to miniature model with database migration support
- Implemented faction filtering in miniature list view with distinct faction query
- Created comprehensive test infrastructure with 55 new tests split between unit and integration
- Added intelligent unique ID gap-filling algorithm for miniature creation
- Enhanced session management with eager loading patterns to prevent detached instance errors
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/models/miniature.py | Added nullable faction field (String 64) to miniature model |
| app/services/miniature_service.py | Added get_next_unique_id() function, faction filtering, and get_distinct_factions() |
| app/blueprints/miniatures.py | Integrated faction dropdown with custom input, passed factions to templates |
| app/blueprints/forces.py | Preserved faction filter parameters when redirecting after miniature operations |
| app/templates/miniatures/list.html | Added faction filter button group and preserved faction in all URL parameters |
| app/templates/miniatures/add.html | Added faction dropdown with custom input, prefilled next_id, default status to "New" |
| app/templates/miniatures/edit.html | Added faction dropdown with custom input capability |
| app/services/force_service.py | Added thread safety documentation, standardized error messages, included faction in exports |
| app/services/lance_template_service.py | Fixed export timestamp field name, added eager loading before expunge |
| tests/conftest.py | Created comprehensive fixture infrastructure with clear_seed_data, dynamic series generation |
| tests/test_miniatures.py | Added 8 new tests for unique_id gap-filling and faction saving |
| tests/test_force_service_unit.py | Created 19 unit tests for force operations |
| tests/test_force_service_integration.py | Created 16 integration tests with realistic data |
| tests/test_lance_template_service_unit.py | Created 9 unit tests for template operations |
| tests/test_lance_template_service_integration.py | Created 11 integration tests for pattern matching |
| tests/TEST_RESULTS.md | Documented test results, known issues, and fixes applied |
| pyproject.toml | Bumped version to 1.0.1, added pytest plugins and configuration |
| Docs/TESTING.md | Created comprehensive testing guide with examples |
| .github/workflows/tests.yml | Added CI/CD workflow with unit, integration, and parallel test jobs |
Comments suppressed due to low confidence (1)
app/services/force_service.py:1
- The result dictionary key 'imported_count' is inconsistent with the actual key returned by import_force_from_json(), which uses 'imported_miniatures'. This will cause a KeyError at runtime.
"""Force management service for MechBay.
Co-authored-by: Copilot <175728472+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.
Add the faction settings, update tests. closes #4