]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Add missing storage path placeholders 2651/head
authorshamoon <4887959+shamoon@users.noreply.github.com>
Sun, 12 Feb 2023 09:53:07 +0000 (01:53 -0800)
committershamoon <4887959+shamoon@users.noreply.github.com>
Sun, 12 Feb 2023 10:01:44 +0000 (02:01 -0800)
src/documents/serialisers.py
src/documents/tests/test_api.py

index a86e590ae6e08b2287cab117e540f41384d903ae..8282e46d6020684138da2ee795338bb4f80eb637 100644 (file)
@@ -599,11 +599,17 @@ class StoragePathSerializer(MatchingModelSerializer):
                 document_type="document_type",
                 created="created",
                 created_year="created_year",
+                created_year_short="created_year_short",
                 created_month="created_month",
+                created_month_name="created_month_name",
+                created_month_name_short="created_month_name_short",
                 created_day="created_day",
                 added="added",
                 added_year="added_year",
+                added_year_short="added_year_short",
                 added_month="added_month",
+                added_month_name="added_month_name",
+                added_month_name_short="added_month_name_short",
                 added_day="added_day",
                 asn="asn",
                 tags="tags",
index 1bef9e7aae3f8add98de005c2d47a7a80bdc3218..38ab46b91eb8a2d9d0f6abd02ef7c510d2be8e42 100644 (file)
@@ -3199,6 +3199,30 @@ class TestApiStoragePaths(DirectoriesMixin, APITestCase):
         self.assertEqual(response.status_code, 400)
         self.assertEqual(StoragePath.objects.count(), 1)
 
+    def test_api_storage_path_placeholders(self):
+        """
+        GIVEN:
+            - API request to create a storage path with placeholders
+            - Storage path is valid
+        WHEN:
+            - API is called
+        THEN:
+            - Correct HTTP response
+            - New storage path is created
+        """
+        response = self.client.post(
+            self.ENDPOINT,
+            json.dumps(
+                {
+                    "name": "Storage path with placeholders",
+                    "path": "{title}/{correspondent}/{document_type}/{created}/{created_year}/{created_year_short}/{created_month}/{created_month_name}/{created_month_name_short}/{created_day}/{added}/{added_year}/{added_year_short}/{added_month}/{added_month_name}/{added_month_name_short}/{added_day}/{asn}/{tags}/{tag_list}/",
+                },
+            ),
+            content_type="application/json",
+        )
+        self.assertEqual(response.status_code, 201)
+        self.assertEqual(StoragePath.objects.count(), 2)
+
 
 class TestTasks(DirectoriesMixin, APITestCase):
     ENDPOINT = "/api/tasks/"