Skip to content

Commit

Permalink
fixed tests and changed content validator type to dict
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullai-t committed Nov 22, 2024
1 parent 5d28907 commit bd76906
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/api/handlers/custom_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/api/store/custom_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
23 changes: 5 additions & 18 deletions src/api/tests/integration/test_custom_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit bd76906

Please sign in to comment.