Task 4.3: Verify queue API endpoints use key identifier
- Verified queue API endpoints already use 'serie_id' (key) as primary identifier - Updated test fixtures to use explicit key values (e.g., 'test-series-key') - Added test to verify queue items include serie_id (key) and serie_folder (metadata) - Fixed test_queue_items_have_required_fields to find correct item by ID - Added test_queue_item_uses_key_as_identifier for explicit key verification - Updated instructions.md to mark Task 4.3 as complete All 870 tests pass.
This commit is contained in:
parent
f4dad969bc
commit
f4d14cf17e
@ -102,6 +102,7 @@ For each task completed:
|
|||||||
- [ ] Task marked as complete in instructions.md
|
- [ ] Task marked as complete in instructions.md
|
||||||
- [ ] Infrastructure.md updated
|
- [ ] Infrastructure.md updated
|
||||||
- [ ] Changes committed to git
|
- [ ] Changes committed to git
|
||||||
|
- [ ] Take the next task
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -157,64 +158,13 @@ For each task completed:
|
|||||||
|
|
||||||
## Task Series: Identifier Standardization
|
## Task Series: Identifier Standardization
|
||||||
|
|
||||||
### Phase 1: Core Models and Data Layer
|
|
||||||
|
|
||||||
✅ **All Phase 1 tasks completed and committed to git**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 2: Core Application Layer
|
|
||||||
|
|
||||||
✅ **Task 2.1 completed and committed to git**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 3: Service Layer
|
|
||||||
|
|
||||||
✅ **All Phase 3 tasks completed and committed to git (November 2025)**
|
|
||||||
|
|
||||||
- Task 3.1: Update DownloadService ✅
|
|
||||||
- Task 3.2: Update AnimeService ✅
|
|
||||||
- Task 3.3: Update ProgressService ✅
|
|
||||||
- Task 3.4: Update ScanService ✅ (November 27, 2025)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 4: API Layer
|
### Phase 4: API Layer
|
||||||
|
|
||||||
#### Task 4.1: Update Anime API Endpoints to Use Key ✅ (November 27, 2025)
|
#### Task 4.1: Update Anime API Endpoints to Use Key ✅ (November 27, 2025)
|
||||||
|
|
||||||
#### Task 4.2: Update Download API Endpoints to Use Key ✅ (November 27, 2025)
|
#### Task 4.2: Update Download API Endpoints to Use Key ✅ (November 27, 2025)
|
||||||
|
|
||||||
---
|
#### Task 4.3: Update Queue API Endpoints to Use Key ✅ (November 27, 2025)
|
||||||
|
|
||||||
#### Task 4.3: Update Queue API Endpoints to Use Key
|
|
||||||
|
|
||||||
**File:** [`src/server/api/queue.py`](src/server/api/queue.py)
|
|
||||||
|
|
||||||
**Objective:** Ensure queue API endpoints use `key` for series identification.
|
|
||||||
|
|
||||||
**Steps:**
|
|
||||||
|
|
||||||
1. Open [`src/server/api/queue.py`](src/server/api/queue.py)
|
|
||||||
2. Review all queue-related endpoints
|
|
||||||
3. Update request/response models to use `key` as identifier
|
|
||||||
4. Ensure queue status includes `key` in item data
|
|
||||||
5. Update queue manipulation endpoints to accept `key`
|
|
||||||
6. Update docstrings and OpenAPI documentation
|
|
||||||
|
|
||||||
**Success Criteria:**
|
|
||||||
|
|
||||||
- [ ] All queue endpoints use `key`
|
|
||||||
- [ ] Queue status responses include `key`
|
|
||||||
- [ ] Request models use `key` for identification
|
|
||||||
- [ ] All queue API tests pass
|
|
||||||
|
|
||||||
**Test Command:**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
conda run -n AniWorld python -m pytest tests/api/ -k "queue" -v
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -877,7 +827,7 @@ conda run -n AniWorld python -m pytest tests/integration/test_identifier_consist
|
|||||||
- [ ] Phase 4: API Layer
|
- [ ] Phase 4: API Layer
|
||||||
- [x] Task 4.1: Update Anime API Endpoints ✅ **Completed November 27, 2025**
|
- [x] Task 4.1: Update Anime API Endpoints ✅ **Completed November 27, 2025**
|
||||||
- [x] Task 4.2: Update Download API Endpoints ✅ **Completed November 27, 2025**
|
- [x] Task 4.2: Update Download API Endpoints ✅ **Completed November 27, 2025**
|
||||||
- [ ] Task 4.3: Update Queue API Endpoints
|
- [x] Task 4.3: Update Queue API Endpoints ✅ **Completed November 27, 2025**
|
||||||
- [ ] Task 4.4: Update WebSocket API Endpoints
|
- [ ] Task 4.4: Update WebSocket API Endpoints
|
||||||
- [ ] Task 4.5: Update Pydantic Models
|
- [ ] Task 4.5: Update Pydantic Models
|
||||||
- [ ] Task 4.6: Update Validators
|
- [ ] Task 4.6: Update Validators
|
||||||
|
|||||||
@ -45,10 +45,14 @@ async def auth_headers(client: AsyncClient):
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_download_request():
|
def sample_download_request():
|
||||||
"""Sample download request for testing."""
|
"""Sample download request for testing.
|
||||||
|
|
||||||
|
Note: serie_id is the primary identifier (key) used for all lookups.
|
||||||
|
serie_folder is metadata only used for filesystem operations.
|
||||||
|
"""
|
||||||
return {
|
return {
|
||||||
"serie_id": "test-series",
|
"serie_id": "test-series-key", # Provider key (primary identifier)
|
||||||
"serie_folder": "Test Series (2024)",
|
"serie_folder": "Test Series (2024)", # Filesystem folder (metadata)
|
||||||
"serie_name": "Test Series",
|
"serie_name": "Test Series",
|
||||||
"episodes": [
|
"episodes": [
|
||||||
{"season": 1, "episode": 1},
|
{"season": 1, "episode": 1},
|
||||||
@ -101,6 +105,11 @@ class TestQueueDisplay:
|
|||||||
)
|
)
|
||||||
assert add_response.status_code == 201
|
assert add_response.status_code == 201
|
||||||
|
|
||||||
|
# Get the added item IDs from response
|
||||||
|
add_data = add_response.json()
|
||||||
|
added_ids = add_data.get("added_items", [])
|
||||||
|
assert len(added_ids) > 0, "No items were added"
|
||||||
|
|
||||||
# Get queue status
|
# Get queue status
|
||||||
response = await client.get(
|
response = await client.get(
|
||||||
"/api/queue/status",
|
"/api/queue/status",
|
||||||
@ -113,20 +122,83 @@ class TestQueueDisplay:
|
|||||||
pending = data["status"]["pending_queue"]
|
pending = data["status"]["pending_queue"]
|
||||||
|
|
||||||
assert len(pending) > 0
|
assert len(pending) > 0
|
||||||
item = pending[0]
|
|
||||||
|
# Find the item we just added by ID
|
||||||
|
item = next((i for i in pending if i["id"] in added_ids), None)
|
||||||
|
assert item is not None, f"Could not find added item in queue. Added IDs: {added_ids}"
|
||||||
|
|
||||||
# Verify required fields for display
|
# Verify required fields for display
|
||||||
assert "id" in item
|
assert "id" in item
|
||||||
|
assert "serie_id" in item # Key - primary identifier
|
||||||
|
assert "serie_folder" in item # Metadata for filesystem ops
|
||||||
assert "serie_name" in item
|
assert "serie_name" in item
|
||||||
assert "episode" in item
|
assert "episode" in item
|
||||||
assert "priority" in item
|
assert "priority" in item
|
||||||
assert "added_at" in item
|
assert "added_at" in item
|
||||||
|
|
||||||
|
# Verify serie_id (key) matches what we sent
|
||||||
|
assert item["serie_id"] == sample_download_request["serie_id"]
|
||||||
|
|
||||||
# Verify episode structure
|
# Verify episode structure
|
||||||
episode = item["episode"]
|
episode = item["episode"]
|
||||||
assert "season" in episode
|
assert "season" in episode
|
||||||
assert "episode" in episode
|
assert "episode" in episode
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_queue_item_uses_key_as_identifier(
|
||||||
|
self, client: AsyncClient, auth_headers: dict
|
||||||
|
):
|
||||||
|
"""Test that queue items use serie_id (key) as primary identifier.
|
||||||
|
|
||||||
|
Verifies that:
|
||||||
|
- serie_id is the provider-assigned key (URL-safe identifier)
|
||||||
|
- serie_folder is metadata only (not used for identification)
|
||||||
|
- Both fields are present in queue item responses
|
||||||
|
"""
|
||||||
|
# Add an item with explicit key and folder
|
||||||
|
request = {
|
||||||
|
"serie_id": "my-test-anime-key", # Provider key (primary ID)
|
||||||
|
"serie_folder": "My Test Anime (2024)", # Display name/folder
|
||||||
|
"serie_name": "My Test Anime",
|
||||||
|
"episodes": [{"season": 1, "episode": 1}],
|
||||||
|
"priority": "normal"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_response = await client.post(
|
||||||
|
"/api/queue/add",
|
||||||
|
json=request,
|
||||||
|
headers=auth_headers
|
||||||
|
)
|
||||||
|
assert add_response.status_code == 201
|
||||||
|
|
||||||
|
# Get queue status
|
||||||
|
response = await client.get(
|
||||||
|
"/api/queue/status",
|
||||||
|
headers=auth_headers
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
pending = data["status"]["pending_queue"]
|
||||||
|
|
||||||
|
# Find our item by key
|
||||||
|
matching_items = [
|
||||||
|
item for item in pending
|
||||||
|
if item["serie_id"] == "my-test-anime-key"
|
||||||
|
]
|
||||||
|
assert len(matching_items) >= 1, "Item should be findable by key"
|
||||||
|
|
||||||
|
item = matching_items[0]
|
||||||
|
|
||||||
|
# Verify key is used as identifier
|
||||||
|
assert item["serie_id"] == "my-test-anime-key"
|
||||||
|
|
||||||
|
# Verify folder is preserved as metadata
|
||||||
|
assert item["serie_folder"] == "My Test Anime (2024)"
|
||||||
|
|
||||||
|
# Verify serie_name is also present
|
||||||
|
assert item["serie_name"] == "My Test Anime"
|
||||||
|
|
||||||
|
|
||||||
class TestQueueReordering:
|
class TestQueueReordering:
|
||||||
"""Test queue reordering functionality."""
|
"""Test queue reordering functionality."""
|
||||||
@ -159,9 +231,9 @@ class TestQueueReordering:
|
|||||||
response = await client.post(
|
response = await client.post(
|
||||||
"/api/queue/add",
|
"/api/queue/add",
|
||||||
json={
|
json={
|
||||||
"serie_id": f"test-{i}",
|
"serie_id": f"reorder-test-key-{i}", # Key (primary ID)
|
||||||
"serie_folder": f"Test Series {i} (2024)",
|
"serie_folder": f"Reorder Test {i} (2024)", # Metadata
|
||||||
"serie_name": f"Test Series {i}",
|
"serie_name": f"Reorder Test {i}",
|
||||||
"episodes": [{"season": 1, "episode": i+1}],
|
"episodes": [{"season": 1, "episode": i+1}],
|
||||||
"priority": "normal"
|
"priority": "normal"
|
||||||
},
|
},
|
||||||
@ -414,7 +486,8 @@ class TestBulkOperations:
|
|||||||
add_response = await client.post(
|
add_response = await client.post(
|
||||||
"/api/queue/add",
|
"/api/queue/add",
|
||||||
json={
|
json={
|
||||||
"serie_id": f"bulk-test-{i}",
|
"serie_id": f"bulk-test-key-{i}", # Key (primary ID)
|
||||||
|
"serie_folder": f"Bulk Test {i} (2024)", # Metadata
|
||||||
"serie_name": f"Bulk Test {i}",
|
"serie_name": f"Bulk Test {i}",
|
||||||
"episodes": [{"season": 1, "episode": i+1}],
|
"episodes": [{"season": 1, "episode": i+1}],
|
||||||
"priority": "normal"
|
"priority": "normal"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user