55from __future__ import unicode_literals
66
77import json
8- import pickle
98import unittest
109
1110from sqlalchemy .orm .session import make_transient
1211
13- from superset import db
12+ from superset import db , utils
1413from superset .connectors .druid .models import (
1514 DruidColumn , DruidDatasource , DruidMetric ,
1615)
@@ -205,13 +204,22 @@ def test_export_1_dashboard(self):
205204 .format (birth_dash .id )
206205 )
207206 resp = self .client .get (export_dash_url )
208- exported_dashboards = pickle .loads (resp .data )['dashboards' ]
207+ exported_dashboards = json .loads (
208+ resp .data .decode ('utf-8' ),
209+ object_hook = utils .decode_dashboards ,
210+ )['dashboards' ]
209211 self .assert_dash_equals (birth_dash , exported_dashboards [0 ])
210212 self .assertEquals (
211213 birth_dash .id ,
212- json .loads (exported_dashboards [0 ].json_metadata )['remote_id' ])
213-
214- exported_tables = pickle .loads (resp .data )['datasources' ]
214+ json .loads (
215+ exported_dashboards [0 ].json_metadata ,
216+ object_hook = utils .decode_dashboards ,
217+ )['remote_id' ])
218+
219+ exported_tables = json .loads (
220+ resp .data .decode ('utf-8' ),
221+ object_hook = utils .decode_dashboards ,
222+ )['datasources' ]
215223 self .assertEquals (1 , len (exported_tables ))
216224 self .assert_table_equals (
217225 self .get_table_by_name ('birth_names' ), exported_tables [0 ])
@@ -223,8 +231,12 @@ def test_export_2_dashboards(self):
223231 '/dashboardmodelview/export_dashboards_form?id={}&id={}&action=go'
224232 .format (birth_dash .id , world_health_dash .id ))
225233 resp = self .client .get (export_dash_url )
226- exported_dashboards = sorted (pickle .loads (resp .data )['dashboards' ],
227- key = lambda d : d .dashboard_title )
234+ exported_dashboards = sorted (
235+ json .loads (
236+ resp .data .decode ('utf-8' ),
237+ object_hook = utils .decode_dashboards ,
238+ )['dashboards' ],
239+ key = lambda d : d .dashboard_title )
228240 self .assertEquals (2 , len (exported_dashboards ))
229241 self .assert_dash_equals (birth_dash , exported_dashboards [0 ])
230242 self .assertEquals (
@@ -239,7 +251,10 @@ def test_export_2_dashboards(self):
239251 )
240252
241253 exported_tables = sorted (
242- pickle .loads (resp .data )['datasources' ], key = lambda t : t .table_name )
254+ json .loads (
255+ resp .data .decode ('utf-8' ),
256+ object_hook = utils .decode_dashboards )['datasources' ],
257+ key = lambda t : t .table_name )
243258 self .assertEquals (2 , len (exported_tables ))
244259 self .assert_table_equals (
245260 self .get_table_by_name ('birth_names' ), exported_tables [0 ])
0 commit comments