chartbastan/backend/tests/test_directory_structure.py
2026-02-01 09:31:38 +01:00

90 lines
3.6 KiB
Python

"""Tests pour valider la structure du répertoire backend."""
import os
from pathlib import Path
def test_backend_directory_exists():
"""Teste que le répertoire backend existe."""
backend_path = Path(__file__).parent.parent
assert backend_path.exists(), "Le répertoire backend doit exister"
assert backend_path.is_dir(), "Le backend doit être un répertoire"
def test_app_directory_exists():
"""Teste que le répertoire app existe."""
app_path = Path(__file__).parent.parent / "app"
assert app_path.exists(), "Le répertoire app doit exister"
assert app_path.is_dir(), "L'app doit être un répertoire"
def test_app_init_exists():
"""Teste que le fichier __init__.py existe dans app."""
init_path = Path(__file__).parent.parent / "app" / "__init__.py"
assert init_path.exists(), "Le fichier app/__init__.py doit exister"
assert init_path.is_file(), "L'__init__.py doit être un fichier"
def test_models_directory_exists():
"""Teste que le répertoire models existe."""
models_path = Path(__file__).parent.parent / "app" / "models"
assert models_path.exists(), "Le répertoire models doit exister"
assert models_path.is_dir(), "Les models doivent être un répertoire"
def test_schemas_directory_exists():
"""Teste que le répertoire schemas existe."""
schemas_path = Path(__file__).parent.parent / "app" / "schemas"
assert schemas_path.exists(), "Le répertoire schemas doit exister"
assert schemas_path.is_dir(), "Les schemas doivent être un répertoire"
def test_api_directory_exists():
"""Teste que le répertoire api existe."""
api_path = Path(__file__).parent.parent / "app" / "api"
assert api_path.exists(), "Le répertoire api doit exister"
assert api_path.is_dir(), "L'api doit être un répertoire"
def test_models_init_exists():
"""Teste que le fichier __init__.py existe dans models."""
init_path = Path(__file__).parent.parent / "app" / "models" / "__init__.py"
assert init_path.exists(), "Le fichier models/__init__.py doit exister"
assert init_path.is_file(), "L'__init__.py des models doit être un fichier"
def test_schemas_init_exists():
"""Teste que le fichier __init__.py existe dans schemas."""
init_path = Path(__file__).parent.parent / "app" / "schemas" / "__init__.py"
assert init_path.exists(), "Le fichier schemas/__init__.py doit exister"
assert init_path.is_file(), "L'__init__.py des schemas doit être un fichier"
def test_api_init_exists():
"""Teste que le fichier __init__.py existe dans api."""
init_path = Path(__file__).parent.parent / "app" / "api" / "__init__.py"
assert init_path.exists(), "Le fichier api/__init__.py doit exister"
assert init_path.is_file(), "L'__init__.py de l'api doit être un fichier"
def test_main_py_exists():
"""Teste que le fichier main.py existe."""
main_path = Path(__file__).parent.parent / "app" / "main.py"
assert main_path.exists(), "Le fichier app/main.py doit exister"
assert main_path.is_file(), "Le main.py doit être un fichier"
def test_database_py_exists():
"""Teste que le fichier database.py existe."""
db_path = Path(__file__).parent.parent / "app" / "database.py"
assert db_path.exists(), "Le fichier app/database.py doit exister"
assert db_path.is_file(), "Le database.py doit être un fichier"
def test_fastapi_app_importable():
"""Teste que l'application FastAPI peut être importée."""
try:
from app.main import app
assert app is not None, "L'application FastAPI doit être importable"
except ImportError as e:
raise AssertionError(f"Impossible d'importer l'application FastAPI: {e}")