From bd7690643209c808bf61738eebe2ef02eb278cb8 Mon Sep 17 00:00:00 2001 From: Tahiru Abdullai Date: Fri, 22 Nov 2024 10:17:05 +0000 Subject: [PATCH] fixed tests and changed content validator type to dict --- src/api/handlers/custom_pages.py | 4 ++-- src/api/store/custom_pages.py | 2 +- .../tests/integration/test_custom_pages.py | 23 ++++--------------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/api/handlers/custom_pages.py b/src/api/handlers/custom_pages.py index 321411a17..1d6bde837 100644 --- a/src/api/handlers/custom_pages.py +++ b/src/api/handlers/custom_pages.py @@ -31,7 +31,7 @@ def create_community_custom_page(self, request): self.validator.expect("title", str, is_required=True) self.validator.expect("community_id", str, is_required=True) - self.validator.expect("content", list, is_required=False) + self.validator.expect("content", dict, is_required=False) self.validator.expect("audience", "str_list", is_required=False) self.validator.expect("sharing_type", str, is_required=False) @@ -51,7 +51,7 @@ def update_community_custom_page(self, request): self.validator.expect("id", str, is_required=False) self.validator.expect("title", str, is_required=False) - self.validator.expect("content", list, is_required=False) + self.validator.expect("content", dict, is_required=False) self.validator.expect("audience", "str_list", is_required=False) self.validator.expect("sharing_type", str, is_required=False) self.validator.expect("community_id", str, is_required=False) diff --git a/src/api/store/custom_pages.py b/src/api/store/custom_pages.py index a7eb299ee..9d5ee8cbb 100644 --- a/src/api/store/custom_pages.py +++ b/src/api/store/custom_pages.py @@ -256,7 +256,7 @@ def get_custom_pages_for_user_portal(self, context: Context, args) -> Tuple[dict page = CustomPage.objects.filter(slug=page_id, is_deleted=False).first() if not page: - return None, CustomMassenergizeError("Invalid id") + return None, CustomMassenergizeError("page not found") if not page.latest_version: return None, CustomMassenergizeError("No version found") diff --git a/src/api/tests/integration/test_custom_pages.py b/src/api/tests/integration/test_custom_pages.py index 6026d40dc..6cb416ccc 100644 --- a/src/api/tests/integration/test_custom_pages.py +++ b/src/api/tests/integration/test_custom_pages.py @@ -438,15 +438,9 @@ def test_get_custom_pages_for_user_portal(self): signinAs(self.client, self.SADMIN) endpoint = "custom.page.getForUser" - args = { - "id": str(self.p2.id), - "slug": self.p2.slug, - } - - print("==ARGS==", args) + args = {"id": str(self.p2.id)} res = self.make_request(endpoint, args) - print("==RES==", res) self.assertTrue(res["success"]) self.assertEqual(res["data"]["id"], str(self.p2.id)) self.assertEqual(res["data"]["slug"], self.p2.slug) @@ -463,26 +457,19 @@ def test_get_custom_pages_for_user_portal(self): self.assertFalse(res["success"]) self.assertEqual(res["error"], "You are Missing a Required Input: Id") - Console.header("Testing get custom pages for user portal: with missing slug") + Console.header("Testing get custom pages for user portal: with no published version") args["id"] = self.p1.id - args.pop("slug") + res = self.make_request(endpoint, args) self.assertFalse(res["success"]) - self.assertEqual(res["error"], "You are Missing a Required Input: Slug") + self.assertEqual(res["error"], 'No version found') Console.header("Testing get custom pages for user portal: with invalid id") args["id"] = "invalid-id" - args["slug"] = self.p1.slug res = self.make_request(endpoint, args) self.assertFalse(res["success"]) - self.assertEqual(res["error"], "['“invalid-id” is not a valid UUID.']") + self.assertEqual(res["error"], "page not found") - Console.header("Testing get custom pages for user portal: with invalid slug") - args["id"] = self.p1.id - args["slug"] = "invalid-slug" - res = self.make_request(endpoint, args) - self.assertFalse(res["success"]) - self.assertEqual(res["error"], "CustomPage matching query does not exist.") def test_copy_custom_page(self): Console.header("Testing copy custom page: as super admin")