Complete architectural refactoring from simple MVC to Clean Architecture/DDD pattern: Domain Layer: - Add entities (Post, BaseEntity) with business logic - Add value objects (Title, Content, Slug) with validation - Add repository interfaces (PostRepository) - Add domain exceptions Application Layer: - Add use cases (CreatePost, GetPost, UpdatePost, DeletePost, ListPosts, PublishPost) - Add DTOs for data transfer - Add TransactionManager interface Infrastructure Layer: - Add SQLAlchemy models and async database connection - Add SQLAlchemyPostRepository implementation - Add Dishka DI container with providers - Add error handlers and middleware Presentation Layer: - Add FastAPI routes with Dishka integration - Add Pydantic schemas - Add dependency injection using FromDishka[T] Other Changes: - Remove old flat structure (api/, common/, core/, modules/) - Add hatchling build system for package scripts - Add blog CLI command - Update AGENTS.md with new architecture docs - All 48 tests passing, mypy clean, ruff clean
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Tests for infrastructure config."""
|
|
|
|
from app.infrastructure.config import Settings
|
|
|
|
|
|
class TestSettings:
|
|
def test_default_values(self) -> None:
|
|
"""Test default settings values by creating settings without env file."""
|
|
# Create settings with no env file to test defaults
|
|
s = Settings(_env_file=None)
|
|
assert s.app_name == "Blog API"
|
|
assert s.debug is False
|
|
assert s.host == "0.0.0.0"
|
|
assert s.port == 8000
|
|
assert s.database_url == "sqlite:///./blog.db"
|
|
assert s.database_echo is False
|
|
|
|
def test_custom_values(self) -> None:
|
|
"""Test custom settings values."""
|
|
s = Settings(
|
|
app_name="Test API",
|
|
debug=True,
|
|
host="localhost",
|
|
port=9000,
|
|
database_url="postgresql://test",
|
|
secret_key="test-secret",
|
|
)
|
|
assert s.app_name == "Test API"
|
|
assert s.debug is True
|
|
assert s.host == "localhost"
|
|
assert s.port == 9000
|
|
assert s.database_url == "postgresql://test"
|
|
assert s.secret_key == "test-secret"
|
|
|
|
def test_model_config(self) -> None:
|
|
"""Test settings model config."""
|
|
assert "env_file" in Settings.model_config
|