homelab_automation/tests/backend/test_core_config.py
Bruno Charest ecefbc8611
Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
Clean up test files and debug artifacts, add node_modules to gitignore, export DashboardManager for testing, and enhance pytest configuration with comprehensive test markers and settings
2025-12-15 08:15:49 -05:00

92 lines
2.5 KiB
Python

"""
Tests pour la configuration de l'application.
Couvre:
- Chargement des settings
- Variables d'environnement
- Valeurs par défaut
"""
import pytest
from unittest.mock import patch
import os
pytestmark = pytest.mark.unit
class TestSettings:
"""Tests pour les Settings."""
def test_default_settings(self):
"""Valeurs par défaut."""
from app.core.config import settings
# settings is the singleton instance
assert settings is not None
assert hasattr(settings, 'ansible_dir')
assert hasattr(settings, 'tasks_logs_dir')
def test_database_url_default(self):
"""URL de base de données par défaut."""
from app.core.config import Settings
settings = Settings()
assert "sqlite" in settings.database_url
def test_jwt_settings(self):
"""Configuration JWT."""
from app.core.config import Settings
settings = Settings()
assert settings.jwt_secret_key is not None
assert settings.jwt_expire_minutes > 0
def test_ansible_dir(self):
"""Répertoire Ansible."""
from app.core.config import Settings
settings = Settings()
assert settings.ansible_dir is not None
def test_tasks_logs_dir(self):
"""Répertoire des logs de tâches."""
from app.core.config import Settings
settings = Settings()
assert settings.tasks_logs_dir is not None
class TestConstants:
"""Tests pour les constantes."""
def test_action_playbook_map(self):
"""Mapping actions -> playbooks."""
from app.core.constants import ACTION_PLAYBOOK_MAP
assert isinstance(ACTION_PLAYBOOK_MAP, dict)
assert len(ACTION_PLAYBOOK_MAP) > 0
def test_action_display_names(self):
"""Noms d'affichage des actions."""
from app.core.constants import ACTION_DISPLAY_NAMES
assert isinstance(ACTION_DISPLAY_NAMES, dict)
def test_valid_env_groups(self):
"""Groupes d'environnement valides."""
from app.core import constants
# Check that constants module has expected attributes
assert hasattr(constants, 'ACTION_PLAYBOOK_MAP')
def test_valid_role_groups(self):
"""Groupes de rôles valides."""
from app.core import constants
# Check that constants module exists and has content
assert hasattr(constants, 'ACTION_DISPLAY_NAMES')