mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	Make tests pass
This commit is contained in:
		
							parent
							
								
									4065d14fab
								
							
						
					
					
						commit
						ad07eec3e1
					
				@ -87,6 +87,21 @@ class FileInfo(object):
 | 
			
		||||
        return FileInfo(
 | 
			
		||||
            title=m.group(1), tags=(), suffix=get_suffix(m.group(2)))
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def title(self):
 | 
			
		||||
        return self._title
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def correspondent(self):
 | 
			
		||||
        return self._correspondent
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def tags(self):
 | 
			
		||||
        return self._tags
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def suffix(self):
 | 
			
		||||
        return self._suffix
 | 
			
		||||
 | 
			
		||||
class SluggedModel(models.Model):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,11 @@
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
 | 
			
		||||
from ..consumer import Consumer
 | 
			
		||||
from ..models import FileInfo
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestAttachment(TestCase):
 | 
			
		||||
 | 
			
		||||
    TAGS = ("tag1", "tag2", "tag3")
 | 
			
		||||
    CONSUMER = Consumer()
 | 
			
		||||
    SUFFIXES = (
 | 
			
		||||
        "pdf", "png", "jpg", "jpeg", "gif",
 | 
			
		||||
        "PDF", "PNG", "JPG", "JPEG", "GIF",
 | 
			
		||||
@ -16,14 +15,14 @@ class TestAttachment(TestCase):
 | 
			
		||||
    def _test_guess_attributes_from_name(self, path, sender, title, tags):
 | 
			
		||||
        for suffix in self.SUFFIXES:
 | 
			
		||||
            f = path.format(suffix)
 | 
			
		||||
            results = self.CONSUMER._guess_attributes_from_name(f)
 | 
			
		||||
            self.assertEqual(results[0].name, sender, f)
 | 
			
		||||
            self.assertEqual(results[1], title, f)
 | 
			
		||||
            self.assertEqual(tuple([t.slug for t in results[2]]), tags, f)
 | 
			
		||||
            file_info = FileInfo.from_path(f)
 | 
			
		||||
            self.assertEqual(file_info.correspondent.name, sender, f)
 | 
			
		||||
            self.assertEqual(file_info.title, title, f)
 | 
			
		||||
            self.assertEqual(tuple([t.slug for t in file_info.tags]), tags, f)
 | 
			
		||||
            if suffix.lower() == "jpeg":
 | 
			
		||||
                self.assertEqual(results[3], "jpg", f)
 | 
			
		||||
                self.assertEqual(file_info.suffix, "jpg", f)
 | 
			
		||||
            else:
 | 
			
		||||
                self.assertEqual(results[3], suffix.lower(), f)
 | 
			
		||||
                self.assertEqual(file_info.suffix, suffix.lower(), f)
 | 
			
		||||
 | 
			
		||||
    def test_guess_attributes_from_name0(self):
 | 
			
		||||
        self._test_guess_attributes_from_name(
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user