##// END OF EJS Templates
Adapt msgspec v4 pager payloads to msgspec v5 format
Thomas Kluyver -
Show More
@@ -222,6 +222,14 b' class V4toV5(Adapter):'
222 222 user_variables = content.pop('user_variables', {})
223 223 if user_variables:
224 224 user_expressions.update(user_variables)
225
226 # Pager payloads became a mime bundle
227 for payload in content.get('payload', []):
228 if payload.get('source', None) == 'page' and ('text' in payload):
229 if 'data' not in payload:
230 payload['data'] = {}
231 payload['data']['text/plain'] = payload.pop('text')
232
225 233 return msg
226 234
227 235 def complete_request(self, msg):
@@ -86,6 +86,22 b' class V4toV5TestCase(AdapterTest):'
86 86 self.assertEqual(v5c['user_expressions'], {'a' : 'apple', 'b': 'b'})
87 87 self.assertNotIn('user_variables', v5c)
88 88 self.assertEqual(v5c['code'], v4c['code'])
89
90 def test_execute_reply(self):
91 msg = self.msg("execute_reply", {
92 'status': 'ok',
93 'execution_count': 7,
94 'user_variables': {'a': 1},
95 'user_expressions': {'a+a': 2},
96 'payload': [{'source':'page', 'text':'blah'}]
97 })
98 v4, v5 = self.adapt(msg)
99 v5c = v5['content']
100 self.assertNotIn('user_variables', v5c)
101 self.assertEqual(v5c['user_expressions'], {'a': 1, 'a+a': 2})
102 self.assertEqual(v5c['payload'], [{'source': 'page',
103 'data': {'text/plain': 'blah'}}
104 ])
89 105
90 106 def test_complete_request(self):
91 107 msg = self.msg("complete_request", {
General Comments 0
You need to be logged in to leave comments. Login now