##// END OF EJS Templates
Fix copy-pasted super() call
Fix copy-pasted super() call

File last commit:

r18238:4ab90e82
r19622:fcd15106
Show More
session.js
182 lines | 5.6 KiB | application/javascript | JavascriptLexer
MinRK
JS: close WebSockets when killing kernels...
r17640
//
// Tests for the Session object
//
casper.notebook_test(function () {
Jessica B. Hamrick
Update session tests
r18211 var that = this;
var get_info = function () {
return that.evaluate(function () {
return JSON.parse(JSON.stringify(IPython.notebook.session._get_model()));
});
};
// test that the kernel is running
Jessica B. Hamrick
Fix kernel and session tests
r18210 this.then(function () {
this.test.assert(this.kernel_running(), 'session: kernel is running');
});
Jessica B. Hamrick
Update session tests
r18211 // test list
Jessica B. Hamrick
Fix kernel and session tests
r18210 this.thenEvaluate(function () {
Jessica B. Hamrick
Update session tests
r18211 IPython._sessions = null;
IPython.notebook.session.list(function (data) {
IPython._sessions = data;
});
});
this.waitFor(function () {
return this.evaluate(function () {
return IPython._sessions !== null;
});
});
this.then(function () {
var num_sessions = this.evaluate(function () {
return IPython._sessions.length;
});
this.test.assertEquals(num_sessions, 1, 'one session running');
MinRK
JS: close WebSockets when killing kernels...
r17640 });
Jessica B. Hamrick
Fix kernel and session tests
r18210
Jessica B. Hamrick
Update session tests
r18211 // test get_info
var session_info = get_info();
this.thenEvaluate(function () {
IPython._session_info = null;
IPython.notebook.session.get_info(function (data) {
IPython._session_info = data;
});
});
MinRK
JS: close WebSockets when killing kernels...
r17640 this.waitFor(function () {
Jessica B. Hamrick
Fix kernel and session tests
r18210 return this.evaluate(function () {
Jessica B. Hamrick
Update session tests
r18211 return IPython._session_info !== null;
MinRK
JS: close WebSockets when killing kernels...
r17640 });
});
Jessica B. Hamrick
Update session tests
r18211 this.then(function () {
var new_session_info = this.evaluate(function () {
return IPython._session_info;
});
this.test.assertEquals(session_info.notebook.name, new_session_info.notebook.name, 'session: notebook name correct');
this.test.assertEquals(session_info.notebook.path, new_session_info.notebook.path, 'session: notebook path correct');
this.test.assertEquals(session_info.kernel.name, new_session_info.kernel.name, 'session: kernel name correct');
this.test.assertEquals(session_info.kernel.id, new_session_info.kernel.id, 'session: kernel id correct');
});
// test rename_notebook
//
// TODO: the PATCH request isn't supported by phantom, so this test always
// fails, see https://github.com/ariya/phantomjs/issues/11384
// when this is fixed we can properly run this test
//
// this.thenEvaluate(function () {
// IPython._renamed = false;
// IPython.notebook.session.rename_notebook(
// "foo",
// "bar",
// function (data) {
// IPython._renamed = true;
// }
// );
// });
// this.waitFor(function () {
// return this.evaluate(function () {
// return IPython._renamed;
// });
// });
// this.then(function () {
// var info = get_info();
// this.test.assertEquals(info.notebook.name, "foo", "notebook was renamed");
// this.test.assertEquals(info.notebook.path, "bar", "notebook path was changed");
// });
MinRK
JS: close WebSockets when killing kernels...
r17640
Jessica B. Hamrick
Update session tests
r18211 // test delete
this.thenEvaluate(function () {
IPython.notebook.session.delete();
});
Jessica B. Hamrick
Better way to wait inbetween tests
r18232 this.waitFor(this.kernel_disconnected);
MinRK
JS: close WebSockets when killing kernels...
r17640 this.then(function () {
Jessica B. Hamrick
Fix kernel and session tests
r18210 this.test.assert(!this.kernel_running(), 'session deletes kernel');
MinRK
JS: close WebSockets when killing kernels...
r17640 });
Jessica B. Hamrick
Update session tests
r18211
Jessica B. Hamrick
Add tests for events
r18223 // check for events when starting the session
this.event_test(
'start_session',
[
Jessica B. Hamrick
Add status_ready.Kernel event and rename status_started to status_created
r18230 'kernel_created.Session',
Jessica B. Hamrick
Rename all status_event to kernel_event
r18238 'kernel_connected.Kernel',
'kernel_starting.Kernel',
'kernel_ready.Kernel'
Jessica B. Hamrick
Add tests for events
r18223 ],
function () {
this.thenEvaluate(function () {
Jessica B. Hamrick
Update session tests
r18211 IPython.notebook.session.start();
});
Jessica B. Hamrick
Add tests for events
r18223 }
);
Jessica B. Hamrick
Better way to wait inbetween tests
r18232 this.wait_for_kernel_ready();
Jessica B. Hamrick
Add tests for events
r18223
// check for events when killing the session
this.event_test(
'delete_session',
Jessica B. Hamrick
Rename all status_event to kernel_event
r18238 ['kernel_killed.Session'],
Jessica B. Hamrick
Add tests for events
r18223 function () {
this.thenEvaluate(function () {
IPython.notebook.session.delete();
});
}
);
// check for events when restarting the session
this.event_test(
'restart_session',
[
Jessica B. Hamrick
Rename all status_event to kernel_event
r18238 'kernel_killed.Session',
Jessica B. Hamrick
Add status_ready.Kernel event and rename status_started to status_created
r18230 'kernel_created.Session',
Jessica B. Hamrick
Rename all status_event to kernel_event
r18238 'kernel_connected.Kernel',
'kernel_starting.Kernel',
'kernel_ready.Kernel'
Jessica B. Hamrick
Add tests for events
r18223 ],
function () {
this.thenEvaluate(function () {
IPython.notebook.session.restart();
});
}
);
Jessica B. Hamrick
Better way to wait inbetween tests
r18232 this.wait_for_kernel_ready();
Jessica B. Hamrick
Add test for kernel_dead.Session
r18227
Jessica B. Hamrick
Handle and test for failed restart in session.js
r18234 // test handling of failed restart
this.event_test(
'failed_restart',
[
Jessica B. Hamrick
Rename all status_event to kernel_event
r18238 'kernel_restarting.Kernel',
'kernel_autorestarting.Kernel',
'kernel_killed.Session',
Jessica B. Hamrick
Handle and test for failed restart in session.js
r18234 'kernel_dead.Kernel',
],
function () {
this.thenEvaluate(function () {
var cell = IPython.notebook.get_cell(0);
cell.set_text("import os\n" +
"from IPython.kernel.connect import get_connection_file\n" +
"with open(get_connection_file(), 'w') as f:\n" +
" f.write('garbage')\n" +
"os._exit(1)");
cell.execute();
});
},
// need an extra-long timeout, because it needs to try
// restarting the kernel 5 times!
20000
);
Jessica B. Hamrick
Add test for kernel_dead.Session
r18227 // check for events when starting a nonexistant kernel
this.event_test(
'bad_start_session',
[
Jessica B. Hamrick
Rename all status_event to kernel_event
r18238 'kernel_killed.Session',
Jessica B. Hamrick
Add test for kernel_dead.Session
r18227 'kernel_dead.Session'
],
function () {
this.thenEvaluate(function () {
IPython.notebook.session.restart({kernel_name: 'foo'});
});
}
);
MinRK
JS: close WebSockets when killing kernels...
r17640 });