##// END OF EJS Templates
Fix kernel and session tests
Jessica B. Hamrick -
Show More
@@ -1,64 +1,45
1
1
2 //
2 //
3 // Kernel tests
3 // Kernel tests
4 //
4 //
5 casper.notebook_test(function () {
5 casper.notebook_test(function () {
6 this.then(function () {
7 this.test.assert(this.kernel_running(), 'kernel: kernel is running');
8 });
9
6 this.evaluate(function () {
10 this.evaluate(function () {
7 IPython.notebook.kernel.kernel_info(
11 IPython.notebook.kernel.kernel_info(
8 function(msg){
12 function(msg){
9 IPython._kernel_info_response = msg;
13 IPython._kernel_info_response = msg;
10 })
14 });
11 });
15 });
12
16
13 this.waitFor(
17 this.waitFor(
14 function () {
18 function () {
15 return this.evaluate(function(){
19 return this.evaluate(function(){
16 return IPython._kernel_info_response;
20 return IPython._kernel_info_response;
17 });
21 });
18 });
22 });
19
23
20 this.then(function () {
24 this.then(function () {
21 var kernel_info_response = this.evaluate(function(){
25 var kernel_info_response = this.evaluate(function(){
22 return IPython._kernel_info_response;
26 return IPython._kernel_info_response;
23 });
27 });
24 this.test.assertTrue( kernel_info_response.msg_type === 'kernel_info_reply', 'Kernel info request return kernel_info_reply');
28 this.test.assertTrue( kernel_info_response.msg_type === 'kernel_info_reply', 'Kernel info request return kernel_info_reply');
25 this.test.assertTrue( kernel_info_response.content !== undefined, 'Kernel_info_reply is not undefined');
29 this.test.assertTrue( kernel_info_response.content !== undefined, 'Kernel_info_reply is not undefined');
26 });
30 });
27
31
28 this.thenEvaluate(function () {
32 this.thenEvaluate(function () {
29 var kernel = IPython.notebook.session.kernel;
33 IPython.notebook.kernel.kill();
30 IPython._channels = [
31 kernel.shell_channel,
32 kernel.iopub_channel,
33 kernel.stdin_channel
34 ];
35 kernel.kill();
36 });
34 });
37
35
38 this.waitFor(function () {
36 this.waitFor(function () {
39 return this.evaluate(function(){
37 return this.evaluate(function () {
40 for (var i=0; i < IPython._channels.length; i++) {
38 return IPython.notebook.kernel.is_fully_disconnected();
41 var ws = IPython._channels[i];
42 if (ws.readyState !== ws.CLOSED) {
43 return false;
44 }
45 }
46 return true;
47 });
39 });
48 });
40 });
49
41
50 this.then(function () {
42 this.then(function () {
51 var states = this.evaluate(function() {
43 this.test.assert(!this.kernel_running(), 'kernel is not running');
52 var states = [];
53 for (var i = 0; i < IPython._channels.length; i++) {
54 states.push(IPython._channels[i].readyState);
55 }
56 return states;
57 });
58
59 for (var i = 0; i < states.length; i++) {
60 this.test.assertEquals(states[i], WebSocket.CLOSED,
61 "Kernel.kill closes websockets[" + i + "]");
62 }
63 });
44 });
64 });
45 });
@@ -1,43 +1,24
1
1
2 //
2 //
3 // Tests for the Session object
3 // Tests for the Session object
4 //
4 //
5
5
6 casper.notebook_test(function () {
6 casper.notebook_test(function () {
7 this.evaluate(function () {
7 this.then(function () {
8 var kernel = IPython.notebook.session.kernel;
8 this.test.assert(this.kernel_running(), 'session: kernel is running');
9 IPython._channels = [
9 });
10 kernel.shell_channel,
10
11 kernel.iopub_channel,
11 this.thenEvaluate(function () {
12 kernel.stdin_channel
13 ];
14 IPython.notebook.session.delete();
12 IPython.notebook.session.delete();
15 });
13 });
16
14
17 this.waitFor(function () {
15 this.waitFor(function () {
18 return this.evaluate(function(){
16 return this.evaluate(function () {
19 for (var i=0; i < IPython._channels.length; i++) {
17 return IPython.notebook.kernel.is_fully_disconnected();
20 var ws = IPython._channels[i];
21 if (ws.readyState !== ws.CLOSED) {
22 return false;
23 }
24 }
25 return true;
26 });
18 });
27 });
19 });
28
20
29 this.then(function () {
21 this.then(function () {
30 var states = this.evaluate(function() {
22 this.test.assert(!this.kernel_running(), 'session deletes kernel');
31 var states = [];
32 for (var i = 0; i < IPython._channels.length; i++) {
33 states.push(IPython._channels[i].readyState);
34 }
35 return states;
36 });
37
38 for (var i = 0; i < states.length; i++) {
39 this.test.assertEquals(states[i], WebSocket.CLOSED,
40 "Session.delete closes websockets[" + i + "]");
41 }
42 });
23 });
43 });
24 });
General Comments 0
You need to be logged in to leave comments. Login now