TASK-001: Setup FastAPI project structure
This commit is contained in:
1
tests/unit/__init__.py
Normal file
1
tests/unit/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Unit tests package."""
|
||||
18
tests/unit/test_config.py
Normal file
18
tests/unit/test_config.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""Unit tests for core configuration."""
|
||||
|
||||
import pytest
|
||||
from app.core.config import Settings
|
||||
|
||||
|
||||
def test_settings_default_values():
|
||||
"""Test default settings values."""
|
||||
settings = Settings()
|
||||
assert settings.APP_NAME == "Instagram Clone"
|
||||
assert settings.APP_VERSION == "0.1.0"
|
||||
assert settings.DEBUG is False
|
||||
|
||||
|
||||
def test_settings_database_url_default():
|
||||
"""Test default database URL."""
|
||||
settings = Settings()
|
||||
assert "sqlite" in settings.DATABASE_URL
|
||||
17
tests/unit/test_database.py
Normal file
17
tests/unit/test_database.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""Unit tests for database module."""
|
||||
|
||||
import pytest
|
||||
from app.db.database import Base, get_db
|
||||
|
||||
|
||||
def test_base_declarative():
|
||||
"""Test Base is a DeclarativeBase."""
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
assert issubclass(Base, DeclarativeBase)
|
||||
|
||||
|
||||
def test_get_db_yields_session(db_session):
|
||||
"""Test get_db dependency yields database session."""
|
||||
gen = get_db()
|
||||
db = next(gen)
|
||||
assert db is not None
|
||||
19
tests/unit/test_main.py
Normal file
19
tests/unit/test_main.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Unit tests for main application endpoints."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_root_endpoint(client):
|
||||
"""Test root endpoint returns welcome message."""
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "message" in data
|
||||
assert "version" in data
|
||||
|
||||
|
||||
def test_health_check_endpoint(client):
|
||||
"""Test health check endpoint."""
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"status": "healthy"}
|
||||
Reference in New Issue
Block a user