mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	Refines the sanity check header, fixes other test issues
This commit is contained in:
		
							parent
							
								
									0a34a4a7ad
								
							
						
					
					
						commit
						be304e37b4
					
				@ -38,7 +38,10 @@ class SanityCheckMessages:
 | 
			
		||||
            for doc_pk in self._messages:
 | 
			
		||||
                if doc_pk is not None:
 | 
			
		||||
                    doc = all_docs.get(pk=doc_pk)
 | 
			
		||||
                    logger.info(f"Document: {doc.pk}, title: {doc.title}")
 | 
			
		||||
                    logger.info(
 | 
			
		||||
                        f"Detected following issue(s) with document #{doc.pk},"
 | 
			
		||||
                        f" titled {doc.title}",
 | 
			
		||||
                    )
 | 
			
		||||
                for msg in self._messages[doc_pk]:
 | 
			
		||||
                    logger.log(msg["level"], msg["message"])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,7 @@ import tempfile
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from unittest import mock
 | 
			
		||||
 | 
			
		||||
import pytest
 | 
			
		||||
from django.core.management import call_command
 | 
			
		||||
from django.test import override_settings
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
@ -190,7 +191,7 @@ class TestExportImport(DirectoriesMixin, TestCase):
 | 
			
		||||
            self.assertEqual(Document.objects.get(id=self.d4.id).title, "wow_dec")
 | 
			
		||||
            messages = check_sanity()
 | 
			
		||||
            # everything is alright after the test
 | 
			
		||||
            self.assertEqual(len(messages), 0, str([str(m) for m in messages]))
 | 
			
		||||
            self.assertEqual(len(messages), 0)
 | 
			
		||||
 | 
			
		||||
    def test_exporter_with_filename_format(self):
 | 
			
		||||
        shutil.rmtree(os.path.join(self.dirs.media_dir, "documents"))
 | 
			
		||||
 | 
			
		||||
@ -63,9 +63,9 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
 | 
			
		||||
        self.assertTrue(messages.has_error)
 | 
			
		||||
        with self.assertLogs() as capture:
 | 
			
		||||
            messages.log_messages()
 | 
			
		||||
            self.assertRegex(
 | 
			
		||||
            self.assertEqual(
 | 
			
		||||
                capture.records[0].message,
 | 
			
		||||
                f"Document: {doc.pk}, title: {doc.title}",
 | 
			
		||||
                f"Detected following issue(s) with document #{doc.pk}, titled {doc.title}",
 | 
			
		||||
            )
 | 
			
		||||
            self.assertRegex(capture.records[1].message, messageRegex)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -538,7 +538,7 @@ class TestTasks(DirectoriesMixin, TestCase):
 | 
			
		||||
    @mock.patch("documents.tasks.sanity_checker.check_sanity")
 | 
			
		||||
    def test_sanity_check_error(self, m):
 | 
			
		||||
        messages = SanityCheckMessages()
 | 
			
		||||
        messages.error("Some error")
 | 
			
		||||
        messages.error(None, "Some error")
 | 
			
		||||
        m.return_value = messages
 | 
			
		||||
        self.assertRaises(SanityCheckFailedException, tasks.sanity_check)
 | 
			
		||||
        m.assert_called_once()
 | 
			
		||||
@ -546,7 +546,7 @@ class TestTasks(DirectoriesMixin, TestCase):
 | 
			
		||||
    @mock.patch("documents.tasks.sanity_checker.check_sanity")
 | 
			
		||||
    def test_sanity_check_warning(self, m):
 | 
			
		||||
        messages = SanityCheckMessages()
 | 
			
		||||
        messages.warning("Some warning")
 | 
			
		||||
        messages.warning(None, "Some warning")
 | 
			
		||||
        m.return_value = messages
 | 
			
		||||
        self.assertEqual(
 | 
			
		||||
            tasks.sanity_check(),
 | 
			
		||||
@ -557,7 +557,7 @@ class TestTasks(DirectoriesMixin, TestCase):
 | 
			
		||||
    @mock.patch("documents.tasks.sanity_checker.check_sanity")
 | 
			
		||||
    def test_sanity_check_info(self, m):
 | 
			
		||||
        messages = SanityCheckMessages()
 | 
			
		||||
        messages.info("Some info")
 | 
			
		||||
        messages.info(None, "Some info")
 | 
			
		||||
        m.return_value = messages
 | 
			
		||||
        self.assertEqual(
 | 
			
		||||
            tasks.sanity_check(),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user