feat: Phase 6 — require_active_service decorator + wizard install wiring
Email/calendar/files routes now return 404 when the service is not installed, using a require_active_service decorator that checks ServiceRegistry. Status endpoints are exempt so health checks always work. SetupManager.complete_setup() now accepts a service_store_manager and installs any wizard-selected services in a background daemon thread after setup completes. Failures are logged but do not fail the wizard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,12 +24,20 @@ sys.path.insert(0, str(api_dir))
|
||||
|
||||
from app import app
|
||||
|
||||
_INSTALLED = {'id': 'calendar', 'installed': True}
|
||||
|
||||
|
||||
class TestGetCalendarUsers(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
self.client = app.test_client()
|
||||
self._sr_patcher = patch('app.service_registry')
|
||||
mock_sr = self._sr_patcher.start()
|
||||
mock_sr.get.return_value = _INSTALLED
|
||||
|
||||
def tearDown(self):
|
||||
self._sr_patcher.stop()
|
||||
|
||||
@patch('app.calendar_manager')
|
||||
def test_get_users_returns_200_with_list(self, mock_cm):
|
||||
@@ -63,6 +71,12 @@ class TestCreateCalendarUser(unittest.TestCase):
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
self.client = app.test_client()
|
||||
self._sr_patcher = patch('app.service_registry')
|
||||
mock_sr = self._sr_patcher.start()
|
||||
mock_sr.get.return_value = _INSTALLED
|
||||
|
||||
def tearDown(self):
|
||||
self._sr_patcher.stop()
|
||||
|
||||
@patch('app.calendar_manager')
|
||||
def test_create_user_returns_200_on_valid_body(self, mock_cm):
|
||||
@@ -133,6 +147,12 @@ class TestDeleteCalendarUser(unittest.TestCase):
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
self.client = app.test_client()
|
||||
self._sr_patcher = patch('app.service_registry')
|
||||
mock_sr = self._sr_patcher.start()
|
||||
mock_sr.get.return_value = _INSTALLED
|
||||
|
||||
def tearDown(self):
|
||||
self._sr_patcher.stop()
|
||||
|
||||
@patch('app.calendar_manager')
|
||||
def test_delete_user_returns_200_on_success(self, mock_cm):
|
||||
@@ -161,6 +181,12 @@ class TestCreateCalendar(unittest.TestCase):
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
self.client = app.test_client()
|
||||
self._sr_patcher = patch('app.service_registry')
|
||||
mock_sr = self._sr_patcher.start()
|
||||
mock_sr.get.return_value = _INSTALLED
|
||||
|
||||
def tearDown(self):
|
||||
self._sr_patcher.stop()
|
||||
|
||||
@patch('app.calendar_manager')
|
||||
def test_create_calendar_returns_200_on_valid_body(self, mock_cm):
|
||||
@@ -228,6 +254,12 @@ class TestAddCalendarEvent(unittest.TestCase):
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
self.client = app.test_client()
|
||||
self._sr_patcher = patch('app.service_registry')
|
||||
mock_sr = self._sr_patcher.start()
|
||||
mock_sr.get.return_value = _INSTALLED
|
||||
|
||||
def tearDown(self):
|
||||
self._sr_patcher.stop()
|
||||
|
||||
@patch('app.calendar_manager')
|
||||
def test_add_event_returns_200_on_valid_body(self, mock_cm):
|
||||
@@ -294,6 +326,12 @@ class TestGetCalendarEvents(unittest.TestCase):
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
self.client = app.test_client()
|
||||
self._sr_patcher = patch('app.service_registry')
|
||||
mock_sr = self._sr_patcher.start()
|
||||
mock_sr.get.return_value = _INSTALLED
|
||||
|
||||
def tearDown(self):
|
||||
self._sr_patcher.stop()
|
||||
|
||||
@patch('app.calendar_manager')
|
||||
def test_get_events_returns_200_with_events(self, mock_cm):
|
||||
@@ -354,6 +392,12 @@ class TestCalendarConnectivity(unittest.TestCase):
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
self.client = app.test_client()
|
||||
self._sr_patcher = patch('app.service_registry')
|
||||
mock_sr = self._sr_patcher.start()
|
||||
mock_sr.get.return_value = _INSTALLED
|
||||
|
||||
def tearDown(self):
|
||||
self._sr_patcher.stop()
|
||||
|
||||
@patch('app.calendar_manager')
|
||||
def test_connectivity_returns_200_with_result(self, mock_cm):
|
||||
|
||||
Reference in New Issue
Block a user