Phase 6: Tests for database, server, and client modules

- Add tests/test_db.py with 33 tests for Database class:
  - Schema initialization and migrations
  - Local file CRUD operations (scan, list, link)
  - CivitAI model caching (cache_model, tags, versions, files)
  - Query operations (search, get_model, get_triggers)
  - Statistics and context manager

- Extend tests/test_server.py with 27 tests for API endpoints:
  - Gallery endpoints (list, get, meta, edit, delete, stats)
  - Database endpoints (files, models, stats)
  - Gallery class unit tests

- Add tests/test_client.py with 33 tests for TsrClient:
  - Server status operations
  - Gallery image operations (list, get, delete, edit, download)
  - Model management (list, active, switch, loras)
  - Image generation
  - CivitAI download operations
  - Database query operations
  - Error handling and context manager

Total: 191 tests passing with 61% coverage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Adam Ladachowski
2026-02-14 01:54:00 +01:00
parent 7efec1a033
commit e257a029da
4 changed files with 1311 additions and 3 deletions
+3 -3
View File
@@ -27,9 +27,9 @@
- [x] Step 5.3: ~~Create `rocm-docker/tsr-server.service`~~ (skipped)
## Phase 6: Tests
- [ ] Step 6.1: `tests/test_db.py` (database module tests)
- [ ] Step 6.2: `tests/test_server.py` (API endpoint tests)
- [ ] Step 6.3: `tests/test_client.py` (client module tests)
- [x] Step 6.1: `tests/test_db.py` (database module tests)
- [x] Step 6.2: `tests/test_server.py` (API endpoint tests)
- [x] Step 6.3: `tests/test_client.py` (client module tests)
---