Skip to content
Snippets Groups Projects
Unverified Commit da140357 authored by sdementen's avatar sdementen Committed by GitHub
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: default avatarGFJ138 <sebastien.dementen@engie.com>
parent 2a567427
Branches
Tags
No related merge requests found
...@@ -22,11 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ...@@ -22,11 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
''' '''
import re
import pytest import pytest
from django.urls import reverse from django.urls import reverse
@pytest.mark.django_db @pytest.mark.django_db
def test_template_tag_use(client): def test_template_tag_use(client):
'Check use of template tag' 'Check use of template tag'
...@@ -39,6 +40,11 @@ def test_template_tag_use(client): ...@@ -39,6 +40,11 @@ def test_template_tag_use(client):
assert response.content assert response.content
assert response.status_code == 200 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 @pytest.mark.django_db
def test_add_to_session(client): def test_add_to_session(client):
'Check use of session variable access helper' 'Check use of session variable access helper'
......
...@@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ...@@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
''' '''
import json
import uuid import uuid
from django.conf import settings from django.conf import settings
...@@ -75,6 +75,10 @@ def store_initial_arguments(request, initial_arguments=None): ...@@ -75,6 +75,10 @@ def store_initial_arguments(request, initial_arguments=None):
if initial_arguments is None: if initial_arguments is None:
return None return None
# convert to dict is json string
if isinstance(initial_arguments, str):
initial_arguments = json.loads(initial_arguments)
# Generate a cache id # Generate a cache id
cache_id = "dpd-initial-args-%s" % str(uuid.uuid4()).replace('-', '') cache_id = "dpd-initial-args-%s" % str(uuid.uuid4()).replace('-', '')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment