diff --git a/src/documents/tests/samples/simple.pdf b/src/documents/tests/samples/simple.pdf deleted file mode 100644 index e450de482..000000000 Binary files a/src/documents/tests/samples/simple.pdf and /dev/null differ diff --git a/src/documents/tests/samples/simple.txt b/src/documents/tests/samples/simple.txt deleted file mode 100644 index 6de7b8c69..000000000 --- a/src/documents/tests/samples/simple.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file. diff --git a/src/documents/tests/test_api_bulk_download.py b/src/documents/tests/test_api_bulk_download.py index b031a5105..0f8dc7afe 100644 --- a/src/documents/tests/test_api_bulk_download.py +++ b/src/documents/tests/test_api_bulk_download.py @@ -53,7 +53,7 @@ class TestBulkDownload(DirectoriesMixin, SampleDirMixin, APITestCase): archive_checksum="D", ) - shutil.copy(self.SAMPLE_DIR / "simple.pdf", self.doc2.source_path) + shutil.copy(self.SIMPLE_PDF, self.doc2.source_path) shutil.copy(self.SAMPLE_DIR / "simple.png", self.doc2b.source_path) shutil.copy(self.SAMPLE_DIR / "simple.jpg", self.doc3.source_path) shutil.copy(self.SAMPLE_DIR / "test_with_bom.pdf", self.doc3.archive_path) diff --git a/src/documents/tests/test_api_documents.py b/src/documents/tests/test_api_documents.py index defba88d3..1ecf0a8b9 100644 --- a/src/documents/tests/test_api_documents.py +++ b/src/documents/tests/test_api_documents.py @@ -56,6 +56,7 @@ from paperless_testing.http import read_streaming_response from paperless_testing.permissions import grant_all_global from paperless_testing.permissions import grant_global from paperless_testing.permissions import grant_object +from paperless_testing.samples import SIMPLE_DIGITAL_PDF class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): @@ -1852,7 +1853,11 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with SimpleUploadedFile( + "simple.pdf", + SIMPLE_DIGITAL_PDF.read_bytes(), + content_type="application/pdf", + ) as f: response = self.client.post( "/api/documents/post_document/", {"document": f}, @@ -1880,7 +1885,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): payload = SimpleUploadedFile( "../../outside.pdf", - (Path(__file__).parent / "samples" / "simple.pdf").read_bytes(), + (SIMPLE_DIGITAL_PDF).read_bytes(), content_type="application/pdf", ) @@ -1909,7 +1914,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - pdf_bytes = (Path(__file__).parent / "samples" / "simple.pdf").read_bytes() + pdf_bytes = (SIMPLE_DIGITAL_PDF).read_bytes() boundary = "paperless-boundary" payload = ( ( @@ -1985,7 +1990,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): def test_upload_insufficient_permissions(self) -> None: self.client.force_authenticate(user=UserFactory(username="testuser2")) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f}, @@ -1998,7 +2003,11 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with SimpleUploadedFile( + "simple.pdf", + SIMPLE_DIGITAL_PDF.read_bytes(), + content_type="application/pdf", + ) as f: response = self.client.post( "/api/documents/post_document/", { @@ -2031,7 +2040,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"documenst": f}, @@ -2057,7 +2066,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "title": "my custom title"}, @@ -2077,7 +2086,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ) c = Correspondent.objects.create(name="test-corres") - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "correspondent": c.id}, @@ -2096,7 +2105,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "correspondent": 3456}, @@ -2111,7 +2120,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ) dt = DocumentType.objects.create(name="invoice") - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "document_type": dt.id}, @@ -2130,7 +2139,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "document_type": 34578}, @@ -2145,7 +2154,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ) sp = StoragePath.objects.create(name="invoices") - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "storage_path": sp.id}, @@ -2164,7 +2173,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "storage_path": 34578}, @@ -2180,7 +2189,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): t1 = Tag.objects.create(name="tag1") t2 = Tag.objects.create(name="tag2") - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "tags": [t2.id, t1.id]}, @@ -2201,7 +2210,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): t1 = Tag.objects.create(name="tag1") t2 = Tag.objects.create(name="tag2") - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "tags": [t2.id, t1.id, 734563]}, @@ -2225,7 +2234,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): 0, tzinfo=zoneinfo.ZoneInfo("America/Los_Angeles"), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "created": created}, @@ -2241,7 +2250,11 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with SimpleUploadedFile( + "simple.pdf", + SIMPLE_DIGITAL_PDF.read_bytes(), + content_type="application/pdf", + ) as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "archive_serial_number": 500}, @@ -2268,7 +2281,11 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): data_type=CustomField.FieldDataType.STRING, ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with SimpleUploadedFile( + "simple.pdf", + SIMPLE_DIGITAL_PDF.read_bytes(), + content_type="application/pdf", + ) as f: response = self.client.post( "/api/documents/post_document/", { @@ -2323,7 +2340,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): w1.actions.add(action1) w1.save() - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", { @@ -2364,7 +2381,11 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): data_type=CustomField.FieldDataType.INT, ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with SimpleUploadedFile( + "simple.pdf", + SIMPLE_DIGITAL_PDF.read_bytes(), + content_type="application/pdf", + ) as f: response = self.client.post( "/api/documents/post_document/", { @@ -2413,7 +2434,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): ] for payload in error_payloads: - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: data = {"document": f, **payload} response = self.client.post( "/api/documents/post_document/", @@ -2471,7 +2492,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): id=str(uuid.uuid4()), ) - with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + with (SIMPLE_DIGITAL_PDF).open("rb") as f: response = self.client.post( "/api/documents/post_document/", {"document": f, "from_webui": True}, @@ -2517,7 +2538,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): / "thumbnails" / "0000001.webp" ) - archive_file: Path = Path(__file__).parent / "samples" / "simple.pdf" + archive_file: Path = SIMPLE_DIGITAL_PDF shutil.copy(source_file, doc.source_path) shutil.copy(archive_file, doc.archive_path) @@ -2550,7 +2571,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): mime_type="application/pdf", ) - shutil.copy(Path(__file__).parent / "samples" / "simple.pdf", doc.source_path) + shutil.copy(SIMPLE_DIGITAL_PDF, doc.source_path) response = self.client.get(f"/api/documents/{doc.pk}/metadata/") self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4288,8 +4309,8 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase): filename="test2.pdf", ) - archive_file = Path(__file__).parent / "samples" / "simple.pdf" - source_file = Path(__file__).parent / "samples" / "simple.pdf" + archive_file = SIMPLE_DIGITAL_PDF + source_file = SIMPLE_DIGITAL_PDF shutil.copy(archive_file, doc.archive_path) shutil.copy(source_file, doc2.source_path) diff --git a/src/documents/tests/test_api_email.py b/src/documents/tests/test_api_email.py index d26f26d85..0d2dbbbde 100644 --- a/src/documents/tests/test_api_email.py +++ b/src/documents/tests/test_api_email.py @@ -377,7 +377,7 @@ class TestEmail(DirectoriesMixin, SampleDirMixin, APITestCase): checksum="3", filename="test3.pdf", ) - shutil.copy(self.SAMPLE_DIR / "simple.pdf", doc3.source_path) + shutil.copy(self.SIMPLE_PDF, doc3.source_path) doc4 = Document.objects.create( title="test1", @@ -386,7 +386,7 @@ class TestEmail(DirectoriesMixin, SampleDirMixin, APITestCase): checksum="4", filename="test4.pdf", ) - shutil.copy(self.SAMPLE_DIR / "simple.pdf", doc4.source_path) + shutil.copy(self.SIMPLE_PDF, doc4.source_path) response = self.client.post( self.ENDPOINT, diff --git a/src/documents/tests/test_barcodes.py b/src/documents/tests/test_barcodes.py index c21f75fbc..b5ed64717 100644 --- a/src/documents/tests/test_barcodes.py +++ b/src/documents/tests/test_barcodes.py @@ -150,7 +150,7 @@ class TestBarcode( - No barcodes detected - No pages to split on """ - test_file = self.SAMPLE_DIR / "simple.pdf" + test_file = self.SIMPLE_PDF with self.get_reader(test_file) as reader: reader.detect() separator_page_numbers = reader.get_separation_pages() @@ -442,7 +442,7 @@ class TestBarcode( THEN: - Nothing happens """ - test_file = self.SAMPLE_DIR / "simple.pdf" + test_file = self.SIMPLE_PDF with self.get_reader(test_file) as reader: try: diff --git a/src/documents/tests/test_consumer.py b/src/documents/tests/test_consumer.py index a4e48379f..4b8150b93 100644 --- a/src/documents/tests/test_consumer.py +++ b/src/documents/tests/test_consumer.py @@ -36,6 +36,7 @@ from paperless_testing.assertions import FileSystemAssertsMixin from paperless_testing.dirs import DirectoriesMixin from paperless_testing.factories import UserFactory from paperless_testing.fakes.progress import FakeProgressManager +from paperless_testing.samples import SIMPLE_DIGITAL_PDF class _BaseNewStyleParser: @@ -1062,7 +1063,7 @@ class TestConsumer( @mock.patch("documents.consumer.get_parser_registry") def test_similar_filenames(self, m) -> None: shutil.copy( - Path(__file__).parent / "samples" / "simple.pdf", + SIMPLE_DIGITAL_PDF, settings.CONSUMPTION_DIR / "simple.pdf", ) shutil.copy( diff --git a/src/documents/tests/test_double_sided.py b/src/documents/tests/test_double_sided.py index 7ea806e93..c35b82486 100644 --- a/src/documents/tests/test_double_sided.py +++ b/src/documents/tests/test_double_sided.py @@ -37,12 +37,15 @@ class TestDoubleSided( self.double_sided_dir.mkdir() self.staging_file = self.dirs.scratch_dir / STAGING_FILE_NAME + def _sample(self, name: str) -> Path: + return self.SIMPLE_PDF if name == "simple.pdf" else self.SAMPLE_DIR / name + def consume_file(self, srcname, dstname: str | Path = "foo.pdf"): """ Starts the consume process and also ensures the destination file does not exist afterwards """ - src = self.SAMPLE_DIR / srcname + src = self._sample(srcname) dst = self.double_sided_dir / dstname dst.parent.mkdir(parents=True, exist_ok=True) shutil.copy(src, dst) @@ -57,7 +60,7 @@ class TestDoubleSided( return msg def create_staging_file(self, src="double-sided-odd.pdf", datetime=None) -> None: - shutil.copy(self.SAMPLE_DIR / src, self.staging_file) + shutil.copy(self._sample(src), self.staging_file) if datetime is None: datetime = dt.datetime.now() os.utime(str(self.staging_file), (datetime.timestamp(),) * 2) diff --git a/src/documents/tests/test_management.py b/src/documents/tests/test_management.py index a5a2e6233..bd3aa4d03 100644 --- a/src/documents/tests/test_management.py +++ b/src/documents/tests/test_management.py @@ -22,8 +22,9 @@ from documents.models import Document from documents.tasks import update_document_content_maybe_archive_file from paperless_testing.assertions import FileSystemAssertsMixin from paperless_testing.dirs import DirectoriesMixin +from paperless_testing.samples import SIMPLE_DIGITAL_PDF -sample_file: Path = Path(__file__).parent / "samples" / "simple.pdf" +sample_file: Path = SIMPLE_DIGITAL_PDF @pytest.mark.management diff --git a/src/documents/tests/test_management_thumbnails.py b/src/documents/tests/test_management_thumbnails.py index 4da0caf5a..595aedc64 100644 --- a/src/documents/tests/test_management_thumbnails.py +++ b/src/documents/tests/test_management_thumbnails.py @@ -11,6 +11,7 @@ from documents.models import Document from documents.parsers import get_default_thumbnail from paperless_testing.assertions import FileSystemAssertsMixin from paperless_testing.dirs import DirectoriesMixin +from paperless_testing.samples import SIMPLE_DIGITAL_PDF @pytest.mark.management @@ -24,7 +25,7 @@ class TestMakeThumbnails(DirectoriesMixin, FileSystemAssertsMixin, TestCase): filename="test.pdf", ) shutil.copy( - Path(__file__).parent / "samples" / "simple.pdf", + SIMPLE_DIGITAL_PDF, self.d1.source_path, ) @@ -36,7 +37,7 @@ class TestMakeThumbnails(DirectoriesMixin, FileSystemAssertsMixin, TestCase): filename="test2.pdf", ) shutil.copy( - Path(__file__).parent / "samples" / "simple.pdf", + SIMPLE_DIGITAL_PDF, self.d2.source_path, ) diff --git a/src/documents/tests/test_workflows.py b/src/documents/tests/test_workflows.py index 3bd9e0775..9f1d3a7b1 100644 --- a/src/documents/tests/test_workflows.py +++ b/src/documents/tests/test_workflows.py @@ -178,7 +178,7 @@ class TestWorkflows( self.assertEqual(action.__str__(), "WorkflowAction 1") test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -290,7 +290,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -409,7 +409,7 @@ class TestWorkflows( w2.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -478,7 +478,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -531,7 +531,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -608,7 +608,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -687,7 +687,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -765,7 +765,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -876,7 +876,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -928,7 +928,7 @@ class TestWorkflows( generated = generate_unique_filename(doc) destination = (settings.ORIGINALS_DIR / generated).resolve() create_source_path_directory(destination) - shutil.copy(self.SAMPLE_DIR / "simple.pdf", destination) + shutil.copy(self.SIMPLE_PDF, destination) Document.objects.filter(pk=doc.pk).update(filename=generated.as_posix()) doc.refresh_from_db() @@ -2023,7 +2023,7 @@ class TestWorkflows( superuser = UserFactory(username="superuser", superuser=True) self.client.force_authenticate(user=superuser) test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) tasks.consume_file( @@ -3009,7 +3009,7 @@ class TestWorkflows( generated = generate_unique_filename(doc) destination = (settings.ORIGINALS_DIR / generated).resolve() create_source_path_directory(destination) - shutil.copy(self.SAMPLE_DIR / "simple.pdf", destination) + shutil.copy(self.SIMPLE_PDF, destination) Document.objects.filter(pk=doc.pk).update(filename=generated.as_posix()) doc.refresh_from_db() doc.tags.set([self.t1, self.t2]) @@ -3073,7 +3073,7 @@ class TestWorkflows( generated = generate_unique_filename(doc) destination = (settings.ORIGINALS_DIR / generated).resolve() create_source_path_directory(destination) - shutil.copy(self.SAMPLE_DIR / "simple.pdf", destination) + shutil.copy(self.SIMPLE_PDF, destination) Document.objects.filter(pk=doc.pk).update(filename=generated.as_posix()) doc.refresh_from_db() doc.tags.set([self.t1]) @@ -3222,7 +3222,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -3346,7 +3346,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -3496,7 +3496,7 @@ class TestWorkflows( workflow.actions.set([assignment_action, email_action]) temp_working_copy = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "working-copy.pdf", ) @@ -3596,7 +3596,7 @@ class TestWorkflows( # move the file test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -3704,7 +3704,7 @@ class TestWorkflows( generated = generate_unique_filename(doc) destination = (settings.ORIGINALS_DIR / generated).resolve() create_source_path_directory(destination) - shutil.copy(self.SAMPLE_DIR / "simple.pdf", destination) + shutil.copy(self.SIMPLE_PDF, destination) Document.objects.filter(pk=doc.pk).update(filename=generated.as_posix()) run_workflows(WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED, doc) @@ -3915,7 +3915,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -4036,7 +4036,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -4387,7 +4387,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -4835,7 +4835,7 @@ class TestWorkflows( w.save() test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) @@ -5027,7 +5027,7 @@ class TestWorkflows( # Create a test file to be consumed test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) test_file_path = Path(test_file) @@ -5091,7 +5091,7 @@ class TestWorkflows( # Create a test file to be consumed test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple2.pdf", ) test_file_path = Path(test_file) @@ -5529,7 +5529,7 @@ class TestDateWorkflowLocalization( ) test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, tmp_path / "simple.pdf", ) @@ -5596,7 +5596,7 @@ class TestRemoteOCRWorkflowAction(DirectoriesMixin, SampleDirMixin, APITestCase) self._make_workflow(WorkflowTrigger.WorkflowTriggerType.CONSUMPTION) test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) overrides = DocumentMetadataOverrides() @@ -5814,7 +5814,7 @@ class TestApplyAISuggestionsWorkflowAction( ) test_file = shutil.copy( - self.SAMPLE_DIR / "simple.pdf", + self.SIMPLE_PDF, self.dirs.scratch_dir / "simple.pdf", ) diff --git a/src/documents/tests/utils.py b/src/documents/tests/utils.py index 63e907855..18769dfc9 100644 --- a/src/documents/tests/utils.py +++ b/src/documents/tests/utils.py @@ -11,6 +11,7 @@ from documents.data_models import ConsumableDocument from documents.data_models import DocumentMetadataOverrides from documents.data_models import DocumentSource from paperless_testing.fakes.progress import FakeProgressManager +from paperless_testing.samples import SIMPLE_DIGITAL_PDF class ConsumeTaskMixin: @@ -53,6 +54,8 @@ class SampleDirMixin: BARCODE_SAMPLE_DIR = SAMPLE_DIR / "barcodes" + SIMPLE_PDF = SIMPLE_DIGITAL_PDF + class GetConsumerMixin: @contextmanager