From ae2b30296205f9897efe7602e661d1883fda1c07 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Sat, 6 Apr 2024 16:26:48 -0700 Subject: [PATCH] Fix: Rotation fails due to celery chord (#6306) Use Celery immutable signature so it does not take the result of the header task --- src/documents/bulk_edit.py | 2 +- src/documents/tests/test_bulk_edit.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/documents/bulk_edit.py b/src/documents/bulk_edit.py index 6b676733d..362c28e20 100644 --- a/src/documents/bulk_edit.py +++ b/src/documents/bulk_edit.py @@ -195,7 +195,7 @@ def rotate(doc_ids: list[int], degrees: int): logger.exception(f"Error rotating document {doc.id}: {e}") if len(affected_docs) > 0: - bulk_update_task = bulk_update_documents.s(document_ids=affected_docs) + bulk_update_task = bulk_update_documents.si(document_ids=affected_docs) chord(header=rotate_tasks, body=bulk_update_task).delay() return "OK" diff --git a/src/documents/tests/test_bulk_edit.py b/src/documents/tests/test_bulk_edit.py index aca492649..7de943921 100644 --- a/src/documents/tests/test_bulk_edit.py +++ b/src/documents/tests/test_bulk_edit.py @@ -463,7 +463,7 @@ class TestPDFActions(DirectoriesMixin, TestCase): mock_consume_file.assert_not_called() - @mock.patch("documents.tasks.bulk_update_documents.s") + @mock.patch("documents.tasks.bulk_update_documents.si") @mock.patch("documents.tasks.update_document_archive_file.s") @mock.patch("celery.chord.delay") def test_rotate(self, mock_chord, mock_update_document, mock_update_documents): @@ -482,7 +482,7 @@ class TestPDFActions(DirectoriesMixin, TestCase): mock_chord.assert_called_once() self.assertEqual(result, "OK") - @mock.patch("documents.tasks.bulk_update_documents.s") + @mock.patch("documents.tasks.bulk_update_documents.si") @mock.patch("documents.tasks.update_document_archive_file.s") @mock.patch("pikepdf.Pdf.save") def test_rotate_with_error( @@ -510,7 +510,7 @@ class TestPDFActions(DirectoriesMixin, TestCase): self.assertIn(expected_str, error_str) mock_update_archive_file.assert_not_called() - @mock.patch("documents.tasks.bulk_update_documents.s") + @mock.patch("documents.tasks.bulk_update_documents.si") @mock.patch("documents.tasks.update_document_archive_file.s") @mock.patch("celery.chord.delay") def test_rotate_non_pdf(