##// END OF EJS Templates
Merge pull request #6545 from takluyver/msgspec-payloads-adapter...
Min RK -
r17997:4ecb8d7b merge
parent child Browse files
Show More
@@ -37,7 +37,6 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):'
37 payload = dict(
37 payload = dict(
38 source='page',
38 source='page',
39 data=data,
39 data=data,
40 text=strng,
41 start=start,
40 start=start,
42 screen_lines=screen_lines,
41 screen_lines=screen_lines,
43 )
42 )
@@ -222,6 +222,14 b' class V4toV5(Adapter):'
222 user_variables = content.pop('user_variables', {})
222 user_variables = content.pop('user_variables', {})
223 if user_variables:
223 if user_variables:
224 user_expressions.update(user_variables)
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 return msg
233 return msg
226
234
227 def complete_request(self, msg):
235 def complete_request(self, msg):
@@ -86,6 +86,22 b' class V4toV5TestCase(AdapterTest):'
86 self.assertEqual(v5c['user_expressions'], {'a' : 'apple', 'b': 'b'})
86 self.assertEqual(v5c['user_expressions'], {'a' : 'apple', 'b': 'b'})
87 self.assertNotIn('user_variables', v5c)
87 self.assertNotIn('user_variables', v5c)
88 self.assertEqual(v5c['code'], v4c['code'])
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 def test_complete_request(self):
106 def test_complete_request(self):
91 msg = self.msg("complete_request", {
107 msg = self.msg("complete_request", {
General Comments 0
You need to be logged in to leave comments. Login now