From f7cb377636e64cae73f958ee98e3ad394f92a83f Mon Sep 17 00:00:00 2001 From: Colin Murtaugh Date: Tue, 14 Feb 2023 11:35:02 -0500 Subject: [PATCH 1/8] Added iframe support to DeepLinkResource --- pylti1p3/deep_link_resource.py | 11 +++++++++++ tests/test_deep_link.py | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pylti1p3/deep_link_resource.py b/pylti1p3/deep_link_resource.py index 131606f..e3c2103 100644 --- a/pylti1p3/deep_link_resource.py +++ b/pylti1p3/deep_link_resource.py @@ -8,6 +8,7 @@ class DeepLinkResource: _url: t.Optional[str] = None _lineitem: t.Optional[LineItem] = None _custom_params: t.Mapping[str, str] = {} + _iframe: t.Mapping[str, int] = {} _target: str = "iframe" _icon_url: t.Optional[str] = None @@ -60,6 +61,13 @@ def set_icon_url(self, value: str) -> "DeepLinkResource": self._icon_url = value return self + def get_iframe(self) -> t.Mapping[str, int]: + return self._iframe + + def set_iframe(self, value: t.Mapping[str, int]): + self._iframe = value + return self + def to_dict(self) -> t.Dict[str, object]: res: t.Dict[str, object] = { "type": self._type, @@ -93,4 +101,7 @@ def to_dict(self) -> t.Dict[str, object]: if self._icon_url: res["icon"] = {"url": self._icon_url} + if self._iframe: + res["iframe"] = self._iframe + return res diff --git a/tests/test_deep_link.py b/tests/test_deep_link.py index d9a3083..37361fe 100644 --- a/tests/test_deep_link.py +++ b/tests/test_deep_link.py @@ -160,13 +160,14 @@ def test_deep_link_launch_success(self): resource = DeepLinkResource() resource.set_url("http://lti.django.test/launch/").set_custom_params( {"custom_param": "custom_value"} - ).set_title("Test title!") + ).set_title("Test title!").set_iframe({"width": 800, "height": 400}) deep_link_return_url = message_launch_data.get( "https://purl.imsglobal.org/spec/lti-dl/claim/deep_linking_settings" ).get("deep_link_return_url") html = validated_message_launch.get_deep_link().output_response_form([resource]) + print(html) self.assertTrue( html.startswith( f'