feat(api): implement notebook management CRUD endpoints
Implement Sprint 1: Notebook Management CRUD
- Add NotebookService with full CRUD operations
- Add POST /api/v1/notebooks (create notebook)
- Add GET /api/v1/notebooks (list with pagination)
- Add GET /api/v1/notebooks/{id} (get by ID)
- Add PATCH /api/v1/notebooks/{id} (partial update)
- Add DELETE /api/v1/notebooks/{id} (delete)
- Add Pydantic models for requests/responses
- Add custom exceptions (ValidationError, NotFoundError, NotebookLMError)
- Add comprehensive unit tests (31 tests, 97% coverage)
- Add API integration tests (26 tests)
- Fix router prefix duplication
- Fix JSON serialization in error responses
BREAKING CHANGE: None
This commit is contained in:
51
tests/unit/test_api/test_main.py
Normal file
51
tests/unit/test_api/test_main.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Tests for API main module."""
|
||||
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from notebooklm_agent.api.main import app, create_application
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestCreateApplication:
|
||||
"""Test suite for create_application function."""
|
||||
|
||||
def test_returns_fastapi_instance(self):
|
||||
"""Should return FastAPI application instance."""
|
||||
# Act
|
||||
application = create_application()
|
||||
|
||||
# Assert
|
||||
assert isinstance(application, FastAPI)
|
||||
assert application.title == "NotebookLM Agent API"
|
||||
assert application.version == "0.1.0"
|
||||
|
||||
def test_includes_health_router(self):
|
||||
"""Should include health check router."""
|
||||
# Act
|
||||
application = create_application()
|
||||
|
||||
# Assert
|
||||
routes = [route.path for route in application.routes]
|
||||
assert any("/health" in route for route in routes)
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestRootEndpoint:
|
||||
"""Test suite for root endpoint."""
|
||||
|
||||
def test_root_returns_api_info(self):
|
||||
"""Should return API information."""
|
||||
# Arrange
|
||||
client = TestClient(app)
|
||||
|
||||
# Act
|
||||
response = client.get("/")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["name"] == "NotebookLM Agent API"
|
||||
assert data["version"] == "0.1.0"
|
||||
assert "/docs" in data["documentation"]
|
||||
Reference in New Issue
Block a user