]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Moves the asserts to be closer together 942/head
authorTrenton Holmes <holmes.trenton@gmail.com>
Sat, 14 May 2022 15:20:55 +0000 (08:20 -0700)
committerTrenton Holmes <holmes.trenton@gmail.com>
Sat, 14 May 2022 15:20:55 +0000 (08:20 -0700)
src/documents/tests/test_document_model.py

index c456a4bb77a969c590fdbe69115f597abab1416e..57455fb8fe167e69ffa58ea6b671b3dbe0dbb14d 100644 (file)
@@ -77,7 +77,24 @@ class TestDocument(TestCase):
 
         utc_create_date = local_create_date.astimezone(zoneinfo.ZoneInfo("UTC"))
 
+        doc = Document(
+            mime_type="application/pdf",
+            title="test",
+            created=utc_create_date,
+        )
+
+        # Ensure the create date would cause an off by 1 if not properly created above
         self.assertEqual(utc_create_date.date().day, 24)
+        self.assertEqual(doc.get_public_filename(), "2020-12-25 test.pdf")
+
+        local_create_date = timezone.datetime(
+            2020,
+            1,
+            1,
+            tzinfo=zoneinfo.ZoneInfo("Europe/Berlin"),
+        )
+
+        utc_create_date = local_create_date.astimezone(zoneinfo.ZoneInfo("UTC"))
 
         doc = Document(
             mime_type="application/pdf",
@@ -85,7 +102,9 @@ class TestDocument(TestCase):
             created=utc_create_date,
         )
 
-        self.assertEqual(doc.get_public_filename(), "2020-12-25 test.pdf")
+        # Ensure the create date would cause an off by 1 in the year if not properly created above
+        self.assertEqual(utc_create_date.date().year, 2019)
+        self.assertEqual(doc.get_public_filename(), "2020-01-01 test.pdf")
 
     def test_file_name_jpg(self):