mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	document renamer testing
This commit is contained in:
		@@ -110,23 +110,25 @@ class TestRenamer(DirectoriesMixin, TestCase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @override_settings(PAPERLESS_FILENAME_FORMAT="")
 | 
					    @override_settings(PAPERLESS_FILENAME_FORMAT="")
 | 
				
			||||||
    def test_rename(self):
 | 
					    def test_rename(self):
 | 
				
			||||||
        doc = Document.objects.create(title="test", mime_type="application/pdf")
 | 
					        doc = Document.objects.create(title="test", mime_type="image/jpeg")
 | 
				
			||||||
        doc.filename = generate_filename(doc)
 | 
					        doc.filename = generate_filename(doc)
 | 
				
			||||||
 | 
					        doc.archive_filename = generate_filename(doc, archive_filename=True)
 | 
				
			||||||
        doc.save()
 | 
					        doc.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Path(doc.source_path).touch()
 | 
					        Path(doc.source_path).touch()
 | 
				
			||||||
 | 
					        Path(doc.archive_path).touch()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        old_source_path = doc.source_path
 | 
					        with override_settings(PAPERLESS_FILENAME_FORMAT="{correspondent}/{title}"):
 | 
				
			||||||
 | 
					 | 
				
			||||||
        with override_settings(PAPERLESS_FILENAME_FORMAT="{title}"):
 | 
					 | 
				
			||||||
            call_command("document_renamer")
 | 
					            call_command("document_renamer")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        doc2 = Document.objects.get(id=doc.id)
 | 
					        doc2 = Document.objects.get(id=doc.id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.assertEqual(doc2.filename, "test.pdf")
 | 
					        self.assertEqual(doc2.filename, "none/test.jpg")
 | 
				
			||||||
        self.assertFalse(os.path.isfile(old_source_path))
 | 
					        self.assertEqual(doc2.archive_filename, "none/test.pdf")
 | 
				
			||||||
        self.assertFalse(os.path.isfile(doc.source_path))
 | 
					        self.assertFalse(os.path.isfile(doc.source_path))
 | 
				
			||||||
 | 
					        self.assertFalse(os.path.isfile(doc.archive_path))
 | 
				
			||||||
        self.assertTrue(os.path.isfile(doc2.source_path))
 | 
					        self.assertTrue(os.path.isfile(doc2.source_path))
 | 
				
			||||||
 | 
					        self.assertTrue(os.path.isfile(doc2.archive_path))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestCreateClassifier(TestCase):
 | 
					class TestCreateClassifier(TestCase):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user