From 7e0aa7136aed44d7cf200c5a816a372c282acc4a Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Tue, 15 Dec 2020 13:26:01 +0100 Subject: [PATCH] more tests --- src/paperless_text/tests/samples/test.txt | 1 + src/paperless_text/tests/test_parser.py | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/paperless_text/tests/samples/test.txt create mode 100644 src/paperless_text/tests/test_parser.py diff --git a/src/paperless_text/tests/samples/test.txt b/src/paperless_text/tests/samples/test.txt new file mode 100644 index 000000000..6de7b8c69 --- /dev/null +++ b/src/paperless_text/tests/samples/test.txt @@ -0,0 +1 @@ +This is a test file. diff --git a/src/paperless_text/tests/test_parser.py b/src/paperless_text/tests/test_parser.py new file mode 100644 index 000000000..413aa91cf --- /dev/null +++ b/src/paperless_text/tests/test_parser.py @@ -0,0 +1,26 @@ +import os + +from django.test import TestCase + +from documents.tests.utils import DirectoriesMixin +from paperless_text.parsers import TextDocumentParser + + +class TestTextParser(DirectoriesMixin, TestCase): + + def test_thumbnail(self): + + parser = TextDocumentParser(None) + + # just make sure that it does not crash + f = parser.get_thumbnail(os.path.join(os.path.dirname(__file__), "samples", "test.txt"), "text/plain") + self.assertTrue(os.path.isfile(f)) + + def test_parse(self): + + parser = TextDocumentParser(None) + + parser.parse(os.path.join(os.path.dirname(__file__), "samples", "test.txt"), "text/plain") + + self.assertEqual(parser.get_text(), "This is a test file.\n") + self.assertIsNone(parser.get_archive_path())