mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-01 11:19:32 -05:00
minor linting
This commit is contained in:
parent
0428d1f88d
commit
24d394ffcc
@ -243,21 +243,29 @@ class TestSystemStatus(APITestCase):
|
||||
THEN:
|
||||
- The response contains an ERROR classifier status
|
||||
"""
|
||||
does_exist = tempfile.NamedTemporaryFile(
|
||||
dir="/tmp",
|
||||
delete=False,
|
||||
)
|
||||
with override_settings(MODEL_FILE=does_exist):
|
||||
with (
|
||||
tempfile.NamedTemporaryFile(
|
||||
dir="/tmp",
|
||||
delete=False,
|
||||
) as does_exist,
|
||||
override_settings(MODEL_FILE=does_exist),
|
||||
):
|
||||
with mock.patch("documents.classifier.load_classifier") as mock_load:
|
||||
mock_load.side_effect = ClassifierModelCorruptError()
|
||||
Document.objects.create(
|
||||
title="Test Document",
|
||||
)
|
||||
Tag.objects.create(name="Test Tag", matching_algorithm=Tag.MATCH_AUTO)
|
||||
Tag.objects.create(
|
||||
name="Test Tag",
|
||||
matching_algorithm=Tag.MATCH_AUTO,
|
||||
)
|
||||
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"]["classifier_status"], "ERROR")
|
||||
self.assertEqual(
|
||||
response.data["tasks"]["classifier_status"],
|
||||
"ERROR",
|
||||
)
|
||||
self.assertIsNotNone(response.data["tasks"]["classifier_error"])
|
||||
|
||||
def test_system_status_classifier_ok_no_objects(self):
|
||||
|
@ -1499,7 +1499,7 @@ class BulkDownloadView(GenericAPIView):
|
||||
follow_filename_format = serializer.validated_data.get("follow_formatting")
|
||||
|
||||
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
|
||||
temp = tempfile.NamedTemporaryFile(
|
||||
temp = tempfile.NamedTemporaryFile( # noqa: SIM115
|
||||
dir=settings.SCRATCH_DIR,
|
||||
suffix="-compressed-archive",
|
||||
delete=False,
|
||||
@ -1517,6 +1517,7 @@ class BulkDownloadView(GenericAPIView):
|
||||
for document in Document.objects.filter(pk__in=ids):
|
||||
strategy.add_document(document)
|
||||
|
||||
# TODO(stumpylog): Investigate using FileResponse here
|
||||
with open(temp.name, "rb") as f:
|
||||
response = HttpResponse(f, content_type="application/zip")
|
||||
response["Content-Disposition"] = '{}; filename="{}"'.format(
|
||||
|
Loading…
x
Reference in New Issue
Block a user