From 41d4c54d1043662026cfaf4d411d1017d8da82ed 2014-01-12 22:43:15 From: MinRK <benjaminrk@gmail.com> Date: 2014-01-12 22:43:15 Subject: [PATCH] test append_output with invalid data --- diff --git a/IPython/html/tests/casperjs/test_cases/safe_append_output.js b/IPython/html/tests/casperjs/test_cases/safe_append_output.js new file mode 100644 index 0000000..1217740 --- /dev/null +++ b/IPython/html/tests/casperjs/test_cases/safe_append_output.js @@ -0,0 +1,32 @@ +// +// Test validation in append_output +// +// Invalid output data is stripped and logged. +// + +casper.notebook_test(function () { + // this.printLog(); + var messages = []; + this.on('remote.message', function (msg) { + messages.push(msg); + }); + + this.evaluate(function () { + var cell = IPython.notebook.get_cell(0); + cell.set_text( "dp = get_ipython().display_pub\n" + + "dp.publish('test', {'text/plain' : '5', 'image/png' : 5})" + ); + cell.execute(); + }); + + this.wait_for_output(0); + this.on('remote.message', function () {}); + + this.then(function () { + var output = this.get_output_cell(0); + this.test.assert(messages.length > 0, "Captured log message"); + this.test.assertEquals(messages[messages.length-1], "Invalid type for image/png 5", "Logged Invalid type message"); + this.test.assertEquals(output['image/png'], undefined, "Non-string png data was stripped"); + this.test.assertEquals(output['text/plain'], '5', "text data is fine"); + }); +});