Skip to content

Commit

Permalink
Merge pull request #4847 from Carreau/js-kernel-info
Browse files Browse the repository at this point in the history
add js kernel_info request
  • Loading branch information
minrk committed Jan 24, 2014
2 parents b823a5a + 2833e9d commit d13647d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
18 changes: 18 additions & 0 deletions IPython/html/static/services/kernels/js/kernel.js
Expand Up @@ -242,6 +242,24 @@ var IPython = (function (IPython) {
return msg.header.msg_id;
};

/**
* Get kernel info
*
* @param callback {function}
* @method object_info
*
* When calling this method, pass a callback function that expects one argument.
* The callback will be passed the complete `kernel_info_reply` message documented
* [here](http://ipython.org/ipython-doc/dev/development/messaging.html#kernel-info)
*/
Kernel.prototype.kernel_info = function (callback) {
var callbacks;
if (callback) {
callbacks = { shell : { reply : callback } };
}
return this.send_shell_message("kernel_info_request", {}, callbacks);
};

/**
* Get info on an object
*
Expand Down
28 changes: 28 additions & 0 deletions IPython/html/tests/casperjs/test_cases/kernel_test.js
@@ -0,0 +1,28 @@

//
// Miscellaneous javascript tests
//
casper.notebook_test(function () {
this.evaluate(function () {
IPython.notebook.kernel.kernel_info(
function(msg){
IPython._kernel_info_response = msg;
})
});

this.waitFor(
function () {
return this.evaluate(function(){
return IPython._kernel_info_response;
});
});

this.then(function () {
var kernel_info_response = this.evaluate(function(){
return IPython._kernel_info_response;
});
this.test.assertTrue( kernel_info_response.msg_type === 'kernel_info_reply', 'Kernel info request return kernel_info_reply');
this.test.assertTrue( kernel_info_response.content !== undefined, 'Kernel_info_reply is not undefined');
});

});

0 comments on commit d13647d

Please sign in to comment.