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:
@@ -25,12 +25,20 @@ sys.path.insert(0, str(api_dir))
|
||||
|
||||
from app import app
|
||||
|
||||
_INSTALLED = {'id': 'files', 'installed': True}
|
||||
|
||||
|
||||
class TestFileUsersEndpoints(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()
|
||||
|
||||
# ── GET /api/files/users ────────────────────────────────────────────────
|
||||
|
||||
@@ -94,6 +102,12 @@ class TestFileListEndpoint(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()
|
||||
|
||||
# ── GET /api/files/list/<username> ─────────────────────────────────────
|
||||
|
||||
@@ -134,6 +148,12 @@ class TestFileFolderDeleteEndpoint(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()
|
||||
|
||||
# ── DELETE /api/files/folders/<username>/<path> ────────────────────────
|
||||
|
||||
@@ -186,6 +206,12 @@ class TestFileDownloadDeleteEndpoints(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()
|
||||
|
||||
# ── GET /api/files/download/<username>/<path> ──────────────────────────
|
||||
|
||||
@@ -223,6 +249,12 @@ class TestFileCreateFolderEndpoint(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()
|
||||
|
||||
# ── POST /api/files/folders ────────────────────────────────────────────
|
||||
|
||||
@@ -259,6 +291,12 @@ class TestFileUploadEndpoint(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()
|
||||
|
||||
# ── POST /api/files/upload/<username> ──────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user