Skip to content

Commit

Permalink
Create an instance each of both snippet types
Browse files Browse the repository at this point in the history
  • Loading branch information
mgax committed Sep 24, 2024
1 parent 4cb019a commit 40a16ac
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/test_grapple.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.db import connection
from django.test import RequestFactory, TestCase, override_settings
from graphene.test import Client
from testapp.factories import AdvertFactory, BlogPageFactory
from testapp.factories import AdvertFactory, BlogPageFactory, PersonFactory
from testapp.models import GlobalSocialMediaSettings, HomePage, SocialMediaSettings
from wagtail.documents import get_document_model
from wagtail.models import Page, Site
Expand Down Expand Up @@ -1587,8 +1587,14 @@ def setUp(self):
super().setUp()
self.factory = RequestFactory()
self.advert = AdvertFactory()
self.person = PersonFactory()

def test_snippets(self):
"""
Query for snippets of different types, they should all be returned in
the same response.
"""

query = """
{
snippets {
Expand All @@ -1602,11 +1608,16 @@ def test_snippets(self):

self.assertEqual(type(executed["data"]), dict)
self.assertEqual(type(executed["data"]["snippets"]), list)
self.assertEqual(len(executed["data"]["snippets"]), 2)
self.assertEqual(type(executed["data"]["snippets"][0]), dict)

snippets_data = executed["data"]["snippets"]
snippets_data = sorted(
executed["data"]["snippets"], key=lambda s: s["snippetType"]
)
self.assertEqual(snippets_data[0]["snippetType"], "Advert")
self.assertEqual(snippets_data[0]["contentType"], "testapp.Advert")
self.assertEqual(snippets_data[1]["snippetType"], "Person")
self.assertEqual(snippets_data[1]["contentType"], "testapp.Person")

def test_no_snippet_classes_registered(self):
"""
Expand Down

0 comments on commit 40a16ac

Please sign in to comment.