mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
81311dd32f
New test files: - test_edge_cases.py: Edge cases, error handling, validation (60+ tests) - test_web_routes.py: Web pages and HTML endpoints (40+ tests) - conftest.py: Shared fixtures and configuration - README.md: Test documentation and usage guide Test coverage includes: - API endpoints (all endpoints) - Edge cases and error handling - Book abbreviations and normalization - Search functionality - Content validation - Web page routes - HTML structure and metadata - Navigation and accessibility - Performance with large datasets - Boundary conditions Fixtures (shared via conftest.py): - client: TestClient for requests - sample_verses: Common verse references - sample_books: Sample book names - book_abbreviations: Abbreviation mappings - bible_facts: Known Bible facts Updated test_api.py to use shared fixtures from conftest.py. Run with: uv run pytest tests/ -v 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
84 lines
2.2 KiB
Python
84 lines
2.2 KiB
Python
"""
|
|
Shared pytest configuration and fixtures
|
|
"""
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
from kjvstudy_org.server import app
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def client():
|
|
"""
|
|
Create test client fixture with session scope for reuse across tests.
|
|
FastAPI's TestClient is safe to reuse.
|
|
"""
|
|
return TestClient(app)
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def sample_verses():
|
|
"""Sample verse references for testing"""
|
|
return {
|
|
"john_3_16": {"book": "John", "chapter": 3, "verse": 16},
|
|
"genesis_1_1": {"book": "Genesis", "chapter": 1, "verse": 1},
|
|
"psalms_23": {"book": "Psalms", "chapter": 23, "start": 1, "end": 6},
|
|
"matthew_5_14": {"book": "Matthew", "chapter": 5, "verse": 14},
|
|
"romans_8_28": {"book": "Romans", "chapter": 8, "verse": 28},
|
|
}
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def sample_books():
|
|
"""Sample book names for testing"""
|
|
return {
|
|
"short_book": "Philemon",
|
|
"long_book": "Genesis",
|
|
"new_testament": "John",
|
|
"old_testament": "Psalms",
|
|
"first_book": "Genesis",
|
|
"last_book": "Revelation",
|
|
}
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def book_abbreviations():
|
|
"""Common book abbreviations mapping"""
|
|
return {
|
|
# Old Testament
|
|
"Gen": "Genesis",
|
|
"Exo": "Exodus",
|
|
"Lev": "Leviticus",
|
|
"Num": "Numbers",
|
|
"Deut": "Deuteronomy",
|
|
"Josh": "Joshua",
|
|
"Ps": "Psalms",
|
|
"Prov": "Proverbs",
|
|
"Isa": "Isaiah",
|
|
"Jer": "Jeremiah",
|
|
"Ezek": "Ezekiel",
|
|
"Dan": "Daniel",
|
|
# New Testament
|
|
"Matt": "Matthew",
|
|
"Rom": "Romans",
|
|
"Gal": "Galatians",
|
|
"Eph": "Ephesians",
|
|
"Phil": "Philippians",
|
|
"Col": "Colossians",
|
|
"Heb": "Hebrews",
|
|
"Jas": "James",
|
|
"Rev": "Revelation",
|
|
}
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def bible_facts():
|
|
"""Known facts about the KJV Bible for validation"""
|
|
return {
|
|
"total_books": 66,
|
|
"total_verses": 31102,
|
|
"old_testament_books": 39,
|
|
"new_testament_books": 27,
|
|
"longest_chapter": {"book": "Psalms", "chapter": 119, "verses": 176},
|
|
"longest_book": {"name": "Psalms", "chapters": 150},
|
|
}
|