From 5fdc0084f20090fbe3b239d6ec47eda22942992c Mon Sep 17 00:00:00 2001 From: AmirW Date: Mon, 15 May 2023 19:59:40 +0330 Subject: [PATCH 1/4] fix resolve_rendition, instantiating ImageRenditionObjectType by hand?! this fixes #318 --- grapple/types/images.py | 13 +------------ tests/test_grapple.py | 2 ++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/grapple/types/images.py b/grapple/types/images.py index 8b9ebf46..665059bf 100644 --- a/grapple/types/images.py +++ b/grapple/types/images.py @@ -110,21 +110,10 @@ def resolve_rendition(self, info, **kwargs): # Only allowed the defined filters (thus renditions) if rendition_allowed(filters): try: - img = self.get_rendition(filters) + return self.get_rendition(filters) except SourceImageIOError: return - rendition_type = get_rendition_type() - - return rendition_type( - id=img.id, - url=get_media_item_url(img), - width=img.width, - height=img.height, - file=img.file, - image=self, - ) - def resolve_src_set(self, info, sizes, format=None, **kwargs): """ Generate src set of renditions. diff --git a/tests/test_grapple.py b/tests/test_grapple.py index 263f8688..69df7db6 100644 --- a/tests/test_grapple.py +++ b/tests/test_grapple.py @@ -1035,6 +1035,7 @@ def test_renditions(self): image(id: %d) { rendition(width: 100) { url + customRenditionProperty } } } @@ -1044,6 +1045,7 @@ def test_renditions(self): executed = self.client.execute(query) self.assertIn("width-100", executed["data"]["image"]["rendition"]["url"]) + self.assertIn("Rendition Model!", executed["data"]["image"]["rendition"]["customRenditionProperty"]) @override_settings(GRAPPLE={"ALLOWED_IMAGE_FILTERS": ["width-200"]}) def test_renditions_with_allowed_image_filters_restrictions(self): From 28d8beaa961f0cfd7dcde51a68667fa51ae69658 Mon Sep 17 00:00:00 2001 From: AmirW Date: Tue, 16 May 2023 20:27:30 +0330 Subject: [PATCH 2/4] mark test_query_rendition_url_field as skip until #329 is merged --- tests/test_grapple.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_grapple.py b/tests/test_grapple.py index 69df7db6..f8a9c79b 100644 --- a/tests/test_grapple.py +++ b/tests/test_grapple.py @@ -1005,6 +1005,7 @@ def test_query_url_field(self): executed["data"]["images"][0]["url"], executed["data"]["images"][0]["src"] ) + @unittest.skip def test_query_rendition_url_field(self): query = """ { From 8a68803435af593138134dfdd6854af7da935bf7 Mon Sep 17 00:00:00 2001 From: AmirW Date: Wed, 17 May 2023 09:23:55 +0330 Subject: [PATCH 3/4] fix black-pre-commit --- tests/test_grapple.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_grapple.py b/tests/test_grapple.py index f8a9c79b..eed218fd 100644 --- a/tests/test_grapple.py +++ b/tests/test_grapple.py @@ -1046,7 +1046,10 @@ def test_renditions(self): executed = self.client.execute(query) self.assertIn("width-100", executed["data"]["image"]["rendition"]["url"]) - self.assertIn("Rendition Model!", executed["data"]["image"]["rendition"]["customRenditionProperty"]) + self.assertIn( + "Rendition Model!", + executed["data"]["image"]["rendition"]["customRenditionProperty"], + ) @override_settings(GRAPPLE={"ALLOWED_IMAGE_FILTERS": ["width-200"]}) def test_renditions_with_allowed_image_filters_restrictions(self): From 651f44957e10f8680d3539b84b3254a1b09cb96f Mon Sep 17 00:00:00 2001 From: AmirW Date: Wed, 17 May 2023 17:38:25 +0330 Subject: [PATCH 4/4] add description to @unittest.skip --- tests/test_grapple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_grapple.py b/tests/test_grapple.py index eed218fd..f9fd00c8 100644 --- a/tests/test_grapple.py +++ b/tests/test_grapple.py @@ -1005,7 +1005,7 @@ def test_query_url_field(self): executed["data"]["images"][0]["url"], executed["data"]["images"][0]["src"] ) - @unittest.skip + @unittest.skip("Important!passing this test depends on mering #329") def test_query_rendition_url_field(self): query = """ {