mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-18 00:46:25 +00:00
Fix: Catch new warning when loading the classifier (#5395)
This commit is contained in:
Binary file not shown.
BIN
src/documents/tests/data/v1.17.4.model.pickle
Normal file
BIN
src/documents/tests/data/v1.17.4.model.pickle
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
@@ -649,7 +650,7 @@ class TestClassifier(DirectoriesMixin, TestCase):
|
||||
Path(settings.MODEL_FILE).touch()
|
||||
self.assertTrue(os.path.exists(settings.MODEL_FILE))
|
||||
|
||||
load.side_effect = IncompatibleClassifierVersionError()
|
||||
load.side_effect = IncompatibleClassifierVersionError("Dummey Error")
|
||||
self.assertIsNone(load_classifier())
|
||||
self.assertFalse(os.path.exists(settings.MODEL_FILE))
|
||||
|
||||
@@ -661,3 +662,14 @@ class TestClassifier(DirectoriesMixin, TestCase):
|
||||
load.side_effect = OSError()
|
||||
self.assertIsNone(load_classifier())
|
||||
self.assertTrue(os.path.exists(settings.MODEL_FILE))
|
||||
|
||||
def test_load_old_classifier_version(self):
|
||||
shutil.copy(
|
||||
os.path.join(os.path.dirname(__file__), "data", "v1.17.4.model.pickle"),
|
||||
self.dirs.scratch_dir,
|
||||
)
|
||||
with override_settings(
|
||||
MODEL_FILE=self.dirs.scratch_dir / "v1.17.4.model.pickle",
|
||||
):
|
||||
classifier = load_classifier()
|
||||
self.assertIsNone(classifier)
|
||||
|
Reference in New Issue
Block a user