mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-23 12:58:18 -05:00
Cover llmindex in system status
This commit is contained in:
parent
b6975a6405
commit
b53a69e31a
@ -310,3 +310,69 @@ class TestSystemStatus(APITestCase):
|
|||||||
"ERROR",
|
"ERROR",
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(response.data["tasks"]["sanity_check_error"])
|
self.assertIsNotNone(response.data["tasks"]["sanity_check_error"])
|
||||||
|
|
||||||
|
def test_system_status_ai_disabled(self):
|
||||||
|
"""
|
||||||
|
GIVEN:
|
||||||
|
- The AI feature is disabled
|
||||||
|
WHEN:
|
||||||
|
- The user requests the system status
|
||||||
|
THEN:
|
||||||
|
- The response contains the correct AI status
|
||||||
|
"""
|
||||||
|
with override_settings(AI_ENABLED=False):
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
response = self.client.get(self.ENDPOINT)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
self.assertEqual(response.data["tasks"]["llmindex_status"], "DISABLED")
|
||||||
|
self.assertIsNone(response.data["tasks"]["llmindex_error"])
|
||||||
|
|
||||||
|
def test_system_status_ai_enabled(self):
|
||||||
|
"""
|
||||||
|
GIVEN:
|
||||||
|
- The AI index feature is enabled, but no tasks are found
|
||||||
|
- The AI index feature is enabled and a task is found
|
||||||
|
WHEN:
|
||||||
|
- The user requests the system status
|
||||||
|
THEN:
|
||||||
|
- The response contains the correct AI status
|
||||||
|
"""
|
||||||
|
with override_settings(AI_ENABLED=True, LLM_EMBEDDING_BACKEND="openai"):
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
|
||||||
|
# No tasks found
|
||||||
|
response = self.client.get(self.ENDPOINT)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
self.assertEqual(response.data["tasks"]["llmindex_status"], "WARNING")
|
||||||
|
|
||||||
|
PaperlessTask.objects.create(
|
||||||
|
type=PaperlessTask.TaskType.SCHEDULED_TASK,
|
||||||
|
status=states.SUCCESS,
|
||||||
|
task_name=PaperlessTask.TaskName.LLMINDEX_UPDATE,
|
||||||
|
)
|
||||||
|
response = self.client.get(self.ENDPOINT)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
self.assertEqual(response.data["tasks"]["llmindex_status"], "OK")
|
||||||
|
self.assertIsNone(response.data["tasks"]["llmindex_error"])
|
||||||
|
|
||||||
|
def test_system_status_ai_error(self):
|
||||||
|
"""
|
||||||
|
GIVEN:
|
||||||
|
- The AI index feature is enabled and a task is found with an error
|
||||||
|
WHEN:
|
||||||
|
- The user requests the system status
|
||||||
|
THEN:
|
||||||
|
- The response contains the correct AI status
|
||||||
|
"""
|
||||||
|
with override_settings(AI_ENABLED=True, LLM_EMBEDDING_BACKEND="openai"):
|
||||||
|
PaperlessTask.objects.create(
|
||||||
|
type=PaperlessTask.TaskType.SCHEDULED_TASK,
|
||||||
|
status=states.FAILURE,
|
||||||
|
task_name=PaperlessTask.TaskName.LLMINDEX_UPDATE,
|
||||||
|
result="AI index update failed",
|
||||||
|
)
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
response = self.client.get(self.ENDPOINT)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
self.assertEqual(response.data["tasks"]["llmindex_status"], "ERROR")
|
||||||
|
self.assertIsNotNone(response.data["tasks"]["llmindex_error"])
|
||||||
|
@ -2903,7 +2903,7 @@ class SystemStatusView(PassUserMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
ai_config = AIConfig()
|
ai_config = AIConfig()
|
||||||
if not ai_config.llm_index_enabled:
|
if not ai_config.llm_index_enabled():
|
||||||
llmindex_status = "DISABLED"
|
llmindex_status = "DISABLED"
|
||||||
llmindex_error = None
|
llmindex_error = None
|
||||||
llmindex_last_modified = None
|
llmindex_last_modified = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user