From fba58f3bdd1ff5f5d22adf95d035239f1d453cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Bastian=20P=C3=B6ttner?= Date: Sun, 18 Feb 2018 22:03:20 +0100 Subject: [PATCH] Increase testcoverage by testing two more date detection cases --- src/paperless_tesseract/tests/test_date.py | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/paperless_tesseract/tests/test_date.py b/src/paperless_tesseract/tests/test_date.py index ee7f6970f..8d973d672 100644 --- a/src/paperless_tesseract/tests/test_date.py +++ b/src/paperless_tesseract/tests/test_date.py @@ -115,6 +115,42 @@ class TestDate(TestCase): datetime.datetime(2019, 3, 1, 0, 0, tzinfo=tz.tzutc()) ) + @mock.patch( + "paperless_tesseract.parsers.RasterisedDocumentParser.SCRATCH", + SAMPLE_FILES + ) + def test_date_format_8(self): + input_file = os.path.join(self.SAMPLE_FILES, "") + document = RasterisedDocumentParser(input_file) + document._text = ("lorem ipsum\n" + "Wohnort\n" + "3100\n" + "IBAN\n" + "AT87 4534\n" + "1234\n" + "1234 5678\n" + "BIC\n" + "lorem ipsum\n" + "März 2020") + self.assertEqual(document.get_date(), + datetime.datetime(2020, 3, 1, 0, 0, + tzinfo=tz.tzutc())) + + @mock.patch( + "paperless_tesseract.parsers.RasterisedDocumentParser.SCRATCH", + SAMPLE_FILES + ) + def test_date_format_9(self): + input_file = os.path.join(self.SAMPLE_FILES, "") + document = RasterisedDocumentParser(input_file) + document._text = ("lorem ipsum\n" + "27. Nullmonth 2020\n" + "März 2020\n" + "lorem ipsum") + self.assertEqual(document.get_date(), + datetime.datetime(2020, 3, 1, 0, 0, + tzinfo=tz.tzutc())) + @mock.patch( "paperless_tesseract.parsers.RasterisedDocumentParser.SCRATCH", SAMPLE_FILES