mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge branch 'dev' into feature-bulk-edit
This commit is contained in:
		| @@ -1,6 +1,5 @@ | ||||
| import magic | ||||
| from django.utils.text import slugify | ||||
| from pathvalidate import validate_filename, ValidationError | ||||
| from rest_framework import serializers | ||||
| from rest_framework.fields import SerializerMethodField | ||||
|  | ||||
| @@ -207,12 +206,6 @@ class PostDocumentSerializer(serializers.Serializer): | ||||
|     ) | ||||
|  | ||||
|     def validate_document(self, document): | ||||
|  | ||||
|         try: | ||||
|             validate_filename(document.name) | ||||
|         except ValidationError: | ||||
|             raise serializers.ValidationError("Invalid filename.") | ||||
|  | ||||
|         document_data = document.file.read() | ||||
|         mime_type = magic.from_buffer(document_data, mime=True) | ||||
|  | ||||
|   | ||||
| @@ -403,16 +403,6 @@ class TestDocumentApi(DirectoriesMixin, APITestCase): | ||||
|         self.assertEqual(response.status_code, 400) | ||||
|         m.assert_not_called() | ||||
|  | ||||
|     @mock.patch("documents.views.async_task") | ||||
|     @mock.patch("documents.serialisers.validate_filename") | ||||
|     def test_upload_invalid_filename(self, validate_filename, async_task): | ||||
|         validate_filename.side_effect = ValidationError() | ||||
|         with open(os.path.join(os.path.dirname(__file__), "samples", "simple.pdf"), "rb") as f: | ||||
|             response = self.client.post("/api/documents/post_document/", {"document": f}) | ||||
|         self.assertEqual(response.status_code, 400) | ||||
|  | ||||
|         async_task.assert_not_called() | ||||
|  | ||||
|     @mock.patch("documents.views.async_task") | ||||
|     def test_upload_with_title(self, async_task): | ||||
|         with open(os.path.join(os.path.dirname(__file__), "samples", "simple.pdf"), "rb") as f: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler