From 0f5e676fd9973bab2d210196a4ddebc521c4ffd0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:42:05 +0000 Subject: [PATCH] fix: use __wrapped__ without self for Celery bind=True tasks in error tests Celery's __wrapped__ attribute strips the self parameter for bind=True tasks. Updated error-case tests to call __wrapped__(file_path, ...) instead of __wrapped__(mock_self, file_path, ...) to avoid 'multiple values' TypeError. Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_upload_to_dropbox.py | 5 +---- tests/test_upload_to_nextcloud.py | 5 +---- tests/test_upload_to_onedrive.py | 10 ++-------- tests/test_upload_to_paperless.py | 15 +++------------ 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/tests/test_upload_to_dropbox.py b/tests/test_upload_to_dropbox.py index da873c9b..58f95963 100644 --- a/tests/test_upload_to_dropbox.py +++ b/tests/test_upload_to_dropbox.py @@ -199,11 +199,8 @@ class TestUploadToDropbox: """Test that missing file raises FileNotFoundError.""" from app.tasks.upload_to_dropbox import upload_to_dropbox - mock_self = MagicMock() - mock_self.request.id = "test-task" - with pytest.raises(FileNotFoundError): - upload_to_dropbox.__wrapped__(mock_self, "/nonexistent/file.pdf", file_id=1) + upload_to_dropbox.__wrapped__("/nonexistent/file.pdf", file_id=1) @patch("app.tasks.upload_to_dropbox.log_task_progress") @patch("app.tasks.upload_to_dropbox.settings") diff --git a/tests/test_upload_to_nextcloud.py b/tests/test_upload_to_nextcloud.py index 050e94c4..21105127 100644 --- a/tests/test_upload_to_nextcloud.py +++ b/tests/test_upload_to_nextcloud.py @@ -20,11 +20,8 @@ class TestUploadToNextcloud: """Test that missing file raises FileNotFoundError.""" from app.tasks.upload_to_nextcloud import upload_to_nextcloud - mock_self = MagicMock() - mock_self.request.id = "test-task" - with pytest.raises(FileNotFoundError): - upload_to_nextcloud.__wrapped__(mock_self, "/nonexistent/file.pdf", file_id=1) + upload_to_nextcloud.__wrapped__("/nonexistent/file.pdf", file_id=1) @patch("app.tasks.upload_to_nextcloud.log_task_progress") @patch("app.tasks.upload_to_nextcloud.settings") diff --git a/tests/test_upload_to_onedrive.py b/tests/test_upload_to_onedrive.py index b67995d6..d9acb459 100644 --- a/tests/test_upload_to_onedrive.py +++ b/tests/test_upload_to_onedrive.py @@ -333,11 +333,8 @@ class TestUploadToOnedrive: """Test that missing file raises FileNotFoundError.""" from app.tasks.upload_to_onedrive import upload_to_onedrive - mock_self = MagicMock() - mock_self.request.id = "test-task" - with pytest.raises(FileNotFoundError): - upload_to_onedrive.__wrapped__(mock_self, "/nonexistent/file.pdf", file_id=1) + upload_to_onedrive.__wrapped__("/nonexistent/file.pdf", file_id=1) @patch("app.tasks.upload_to_onedrive.log_task_progress") @patch("app.tasks.upload_to_onedrive.settings") @@ -350,11 +347,8 @@ class TestUploadToOnedrive: test_file = tmp_path / "test.pdf" test_file.write_bytes(b"test content") - mock_self = MagicMock() - mock_self.request.id = "test-task" - with pytest.raises(ValueError, match="client ID is not configured"): - upload_to_onedrive.__wrapped__(mock_self, str(test_file), file_id=1) + upload_to_onedrive.__wrapped__(str(test_file), file_id=1) @patch("app.tasks.upload_to_onedrive.upload_large_file") @patch("app.tasks.upload_to_onedrive.create_upload_session") diff --git a/tests/test_upload_to_paperless.py b/tests/test_upload_to_paperless.py index aa0c532c..4667ff3c 100644 --- a/tests/test_upload_to_paperless.py +++ b/tests/test_upload_to_paperless.py @@ -394,11 +394,8 @@ class TestUploadToPaperless: @patch("app.tasks.upload_to_paperless.log_task_progress") def test_file_not_found(self, mock_log): """Test that missing file raises FileNotFoundError.""" - mock_self = MagicMock() - mock_self.request.id = "test-task" - with pytest.raises(FileNotFoundError): - upload_to_paperless.__wrapped__(mock_self, "/nonexistent/file.pdf", file_id=1) + upload_to_paperless.__wrapped__("/nonexistent/file.pdf", file_id=1) @patch("app.tasks.upload_to_paperless.set_document_custom_fields") @patch("app.tasks.upload_to_paperless.poll_task_for_document_id") @@ -466,11 +463,8 @@ class TestUploadToPaperless: test_file = tmp_path / "test.pdf" test_file.write_bytes(b"%PDF-1.4 test content") - mock_self = MagicMock() - mock_self.request.id = "test-task" - with pytest.raises(ValueError, match="not fully configured"): - upload_to_paperless.__wrapped__(mock_self, str(test_file), file_id=1) + upload_to_paperless.__wrapped__(str(test_file), file_id=1) @patch("app.tasks.upload_to_paperless.requests.post") @patch("app.tasks.upload_to_paperless.settings") @@ -488,11 +482,8 @@ class TestUploadToPaperless: mock_exc.response = None mock_post.side_effect = mock_exc - mock_self = MagicMock() - mock_self.request.id = "test-task" - with pytest.raises(requests.exceptions.ConnectionError): - upload_to_paperless.__wrapped__(mock_self, str(test_file), file_id=1) + upload_to_paperless.__wrapped__(str(test_file), file_id=1) @patch("app.tasks.upload_to_paperless.set_document_custom_fields") @patch("app.tasks.upload_to_paperless.poll_task_for_document_id")