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