126 lines
4.5 KiB
Python
126 lines
4.5 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2025 Patrick Motsch
|
|
# All rights reserved.
|
|
"""
|
|
Test script: verify all Service Center modules and migrated services can be imported.
|
|
Run: pytest gateway/tests/unit/serviceCenter/test_service_center_imports.py -v
|
|
"""
|
|
|
|
import pytest
|
|
|
|
|
|
# ========== Foundation ==========
|
|
|
|
def test_import_service_center_init():
|
|
"""Service center main package imports."""
|
|
from modules.serviceCenter import (
|
|
getService,
|
|
preWarm,
|
|
registerServiceObjects,
|
|
can_access_service,
|
|
ServiceCenterContext,
|
|
CORE_SERVICES,
|
|
IMPORTABLE_SERVICES,
|
|
SERVICE_RBAC_OBJECTS,
|
|
)
|
|
assert getService is not None
|
|
assert preWarm is not None
|
|
assert registerServiceObjects is not None
|
|
assert can_access_service is not None
|
|
|
|
|
|
def test_import_service_center_context():
|
|
"""Service center context module."""
|
|
from modules.serviceCenter.context import ServiceCenterContext
|
|
assert ServiceCenterContext is not None
|
|
|
|
|
|
def test_import_service_center_registry():
|
|
"""Service center registry with CORE and IMPORTABLE services."""
|
|
from modules.serviceCenter.registry import CORE_SERVICES, IMPORTABLE_SERVICES, SERVICE_RBAC_OBJECTS
|
|
assert "utils" in CORE_SERVICES
|
|
assert "security" in CORE_SERVICES
|
|
assert "streaming" in CORE_SERVICES
|
|
assert "web" in IMPORTABLE_SERVICES
|
|
assert "ticket" in IMPORTABLE_SERVICES
|
|
assert len(SERVICE_RBAC_OBJECTS) > 0
|
|
|
|
|
|
def test_import_service_center_resolver():
|
|
"""Service center resolver module."""
|
|
from modules.serviceCenter.resolver import resolve, get_resolution_cache, clear_cache
|
|
assert resolve is not None
|
|
assert get_resolution_cache is not None
|
|
assert clear_cache is not None
|
|
|
|
|
|
# ========== Core services ==========
|
|
|
|
def test_import_core_utils_service():
|
|
"""Core UtilsService can be imported."""
|
|
from modules.serviceCenter.core.serviceUtils.mainServiceUtils import UtilsService
|
|
assert UtilsService is not None
|
|
|
|
|
|
def test_import_core_security_service():
|
|
"""Core SecurityService can be imported."""
|
|
from modules.serviceCenter.core.serviceSecurity.mainServiceSecurity import SecurityService
|
|
assert SecurityService is not None
|
|
|
|
|
|
def test_import_core_streaming_service():
|
|
"""Core StreamingService can be imported."""
|
|
from modules.serviceCenter.core.serviceStreaming.mainServiceStreaming import StreamingService
|
|
assert StreamingService is not None
|
|
|
|
|
|
# ========== Importable services ==========
|
|
|
|
def test_import_service_ticket():
|
|
"""Importable TicketService can be imported."""
|
|
from modules.serviceCenter.services.serviceTicket.mainServiceTicket import TicketService
|
|
assert TicketService is not None
|
|
|
|
|
|
def test_import_service_web():
|
|
"""Importable WebService can be imported."""
|
|
from modules.serviceCenter.services.serviceWeb.mainServiceWeb import WebService
|
|
assert WebService is not None
|
|
|
|
|
|
def test_import_service_sharepoint():
|
|
"""Importable SharepointService can be imported."""
|
|
from modules.serviceCenter.services.serviceSharepoint.mainServiceSharepoint import SharepointService
|
|
assert SharepointService is not None
|
|
|
|
|
|
def test_import_service_chat():
|
|
"""Importable ChatService can be imported."""
|
|
from modules.serviceCenter.services.serviceChat.mainServiceChat import ChatService
|
|
assert ChatService is not None
|
|
|
|
|
|
def test_import_service_extraction():
|
|
"""Importable ExtractionService can be imported."""
|
|
from modules.serviceCenter.services.serviceExtraction.mainServiceExtraction import ExtractionService
|
|
assert ExtractionService is not None
|
|
|
|
|
|
# ========== Optional: services that may still live in legacy hub ==========
|
|
|
|
@pytest.mark.parametrize("module_path,class_name", [
|
|
("modules.serviceCenter.services.serviceMessaging.mainServiceMessaging", "MessagingService"),
|
|
("modules.serviceCenter.services.serviceBilling.mainServiceBilling", "BillingService"),
|
|
("modules.serviceCenter.services.serviceGeneration.mainServiceGeneration", "GenerationService"),
|
|
("modules.serviceCenter.services.serviceAi.mainServiceAi", "AiService"),
|
|
("modules.serviceCenter.services.serviceNeutralization.mainServiceNeutralization", "NeutralizationService"),
|
|
])
|
|
def test_import_optional_services(module_path, class_name):
|
|
"""Services listed in registry - may fail if not yet migrated to serviceCenter."""
|
|
import importlib
|
|
try:
|
|
mod = importlib.import_module(module_path)
|
|
cls = getattr(mod, class_name)
|
|
assert cls is not None
|
|
except (ImportError, ModuleNotFoundError, AttributeError):
|
|
pytest.skip(f"Service {class_name} not yet migrated to serviceCenter")
|