Fix classifier test, use Path

This commit is contained in:
shamoon 2024-12-25 10:00:20 -08:00 committed by Sebastian Steinbeißer
parent 02386d6513
commit 4993bcf6ab
No known key found for this signature in database
GPG Key ID: E8200F0F0380C0E0
2 changed files with 21 additions and 19 deletions

View File

@ -233,7 +233,11 @@ class TestSystemStatus(APITestCase):
self.assertEqual(response.data["tasks"]["classifier_status"], "WARNING")
self.assertIsNotNone(response.data["tasks"]["classifier_error"])
def test_system_status_classifier_error(self):
@mock.patch(
"documents.classifier.load_classifier",
side_effect=ClassifierModelCorruptError(),
)
def test_system_status_classifier_error(self, mock_load_classifier):
"""
GIVEN:
- The classifier does exist but is corrupt
@ -250,8 +254,6 @@ class TestSystemStatus(APITestCase):
) as does_exist,
override_settings(MODEL_FILE=Path(does_exist.name)),
):
with mock.patch("documents.classifier.load_classifier") as mock_load:
mock_load.side_effect = ClassifierModelCorruptError()
Document.objects.create(
title="Test Document",
)

View File

@ -2159,7 +2159,7 @@ class SystemStatusView(PassUserMixin):
matching_algorithm=Tag.MATCH_AUTO,
).exists()
)
and not os.path.isfile(settings.MODEL_FILE)
and not settings.MODEL_FILE.exists()
):
# if classifier file doesn't exist just classify as a warning
classifier_error = "Classifier file does not exist (yet). Re-training may be pending."