import pytest pytest.skip("Obsolete test file replaced by component-specific unit tests", allow_module_level=True) from unittest.mock import Mock, patch from f02_1_flight_lifecycle_manager import FlightLifecycleManager @pytest.fixture def mock_deps(): return { "configuration_manager": Mock(), "model_manager": Mock(), "flight_database": Mock(), "satellite_data_manager": Mock() } @pytest.fixture def manager(mock_deps): return FlightLifecycleManager(mock_deps) class TestSystemInitialization: def test_initialize_system_success_flow(self, manager, mock_deps): """Verifies all components are called during a successful initialization.""" mock_deps["configuration_manager"].load_config.return_value = True mock_deps["model_manager"].load_models.return_value = True # Track call order using a parent mock parent = Mock() parent.attach_mock(mock_deps["configuration_manager"].load_config, 'config') parent.attach_mock(mock_deps["model_manager"].load_models, 'models') success = manager.initialize_system() assert success is True # Verify order: config must be loaded before models expected_calls = [('config', ()), ('models', ())] assert parent.mock_calls == expected_calls def test_initialize_system_config_failure(self, manager, mock_deps): """Verifies failure in config loading halts startup and rolls back.""" mock_deps["configuration_manager"].load_config.return_value = False with patch.object(manager, '_rollback_partial_initialization') as mock_rollback: success = manager.initialize_system() assert success is False # Models should not be loaded if config fails mock_deps["model_manager"].load_models.assert_not_called() # Rollback should be triggered mock_rollback.assert_called_once() def test_initialize_system_model_failure(self, manager, mock_deps): """Verifies failure in model loading triggers rollback.""" mock_deps["configuration_manager"].load_config.return_value = True mock_deps["model_manager"].load_models.return_value = False # Force failure with patch.object(manager, '_rollback_partial_initialization') as mock_rollback: success = manager.initialize_system() assert success is False mock_rollback.assert_called_once() def test_initialize_system_graceful_missing_deps(self): """Verifies system handles missing dependencies gracefully (e.g. testing context).""" empty_manager = FlightLifecycleManager({}) # Should log warnings but not crash assert empty_manager.initialize_system() is True