diff --git a/demo/demo/tests/test_dpd_demo.py b/demo/demo/tests/test_dpd_demo.py index 997dba7e086e05138ab3a0e3512a18ae1692d552..52c55db518abd6d7d5e1e340bb17d49e9fe33a47 100644 --- a/demo/demo/tests/test_dpd_demo.py +++ b/demo/demo/tests/test_dpd_demo.py @@ -22,11 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' +import re import pytest - from django.urls import reverse + @pytest.mark.django_db def test_template_tag_use(client): 'Check use of template tag' @@ -39,6 +40,11 @@ def test_template_tag_use(client): assert response.content assert response.status_code == 200 + for src in re.findall('iframe src="(.*?)"', response.content.decode("utf-8")): + response = client.get(src + "_dash-layout") + assert response.status_code == 200, "" + + @pytest.mark.django_db def test_add_to_session(client): 'Check use of session variable access helper' diff --git a/django_plotly_dash/util.py b/django_plotly_dash/util.py index 5246c86cc1cfcfd152c62830ca3a476abda131d2..03fc89d0e4dd034a4ba5d7ca357474f4a40c5931 100644 --- a/django_plotly_dash/util.py +++ b/django_plotly_dash/util.py @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' - +import json import uuid from django.conf import settings @@ -75,6 +75,10 @@ def store_initial_arguments(request, initial_arguments=None): if initial_arguments is None: return None + # convert to dict is json string + if isinstance(initial_arguments, str): + initial_arguments = json.loads(initial_arguments) + # Generate a cache id cache_id = "dpd-initial-args-%s" % str(uuid.uuid4()).replace('-', '')