mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
Encode feature flags to JSON pessimistically (#8529)
* Encode feature flags to JSON pessimistically * Add unit test * Remove old imports
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""Unit tests for Superset"""
|
||||
import cgi
|
||||
import csv
|
||||
import datetime
|
||||
import doctest
|
||||
@@ -949,6 +950,25 @@ class CoreTests(SupersetTestCase):
|
||||
self.assertDictEqual(deserialized_payload, payload)
|
||||
expand_data.assert_called_once()
|
||||
|
||||
@mock.patch.dict("superset._feature_flags", {"FOO": lambda x: 1}, clear=True)
|
||||
def test_feature_flag_serialization(self):
|
||||
"""
|
||||
Functions in feature flags don't break bootstrap data serialization.
|
||||
"""
|
||||
self.login()
|
||||
|
||||
encoded = json.dumps(
|
||||
{"FOO": lambda x: 1, "super": "set"},
|
||||
default=utils.pessimistic_json_iso_dttm_ser,
|
||||
)
|
||||
html = cgi.escape(encoded).replace("'", "'").replace('"', """)
|
||||
|
||||
data = self.get_resp("/superset/sqllab")
|
||||
self.assertTrue(html in data)
|
||||
|
||||
data = self.get_resp("/superset/welcome")
|
||||
self.assertTrue(html in data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user