Skip to content

Commit da14035

Browse files
fix #328 by: (#329)
- converting initial_arguments given as json string into a dict in `store_initial_arguments` - add in the test of the template tag a call to the _dash-layout to ensure the initial_arguments are parsed properly Co-authored-by: GFJ138 <sebastien.dementen@engie.com>
1 parent 2a56742 commit da14035

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

demo/demo/tests/test_dpd_demo.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
SOFTWARE.
2323
2424
'''
25+
import re
2526

2627
import pytest
27-
2828
from django.urls import reverse
2929

30+
3031
@pytest.mark.django_db
3132
def test_template_tag_use(client):
3233
'Check use of template tag'
@@ -39,6 +40,11 @@ def test_template_tag_use(client):
3940
assert response.content
4041
assert response.status_code == 200
4142

43+
for src in re.findall('iframe src="(.*?)"', response.content.decode("utf-8")):
44+
response = client.get(src + "_dash-layout")
45+
assert response.status_code == 200, ""
46+
47+
4248
@pytest.mark.django_db
4349
def test_add_to_session(client):
4450
'Check use of session variable access helper'

django_plotly_dash/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
2424
'''
25-
25+
import json
2626
import uuid
2727

2828
from django.conf import settings
@@ -75,6 +75,10 @@ def store_initial_arguments(request, initial_arguments=None):
7575
if initial_arguments is None:
7676
return None
7777

78+
# convert to dict is json string
79+
if isinstance(initial_arguments, str):
80+
initial_arguments = json.loads(initial_arguments)
81+
7882
# Generate a cache id
7983
cache_id = "dpd-initial-args-%s" % str(uuid.uuid4()).replace('-', '')
8084

0 commit comments

Comments
 (0)