Show More
@@ -0,0 +1,43 b'' | |||||
|
1 | ||||
|
2 | // | |||
|
3 | // Tests for the Session object | |||
|
4 | // | |||
|
5 | ||||
|
6 | casper.notebook_test(function () { | |||
|
7 | this.evaluate(function () { | |||
|
8 | var kernel = IPython.notebook.session.kernel; | |||
|
9 | IPython._channels = [ | |||
|
10 | kernel.shell_channel, | |||
|
11 | kernel.iopub_channel, | |||
|
12 | kernel.stdin_channel | |||
|
13 | ]; | |||
|
14 | IPython.notebook.session.delete(); | |||
|
15 | }); | |||
|
16 | ||||
|
17 | this.waitFor(function () { | |||
|
18 | return this.evaluate(function(){ | |||
|
19 | for (var i=0; i < IPython._channels.length; i++) { | |||
|
20 | var ws = IPython._channels[i]; | |||
|
21 | if (ws.readyState !== ws.CLOSED) { | |||
|
22 | return false; | |||
|
23 | } | |||
|
24 | } | |||
|
25 | return true; | |||
|
26 | }); | |||
|
27 | }); | |||
|
28 | ||||
|
29 | this.then(function () { | |||
|
30 | var states = this.evaluate(function() { | |||
|
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 | }); | |||
|
43 | }); |
@@ -394,6 +394,7 b' define([' | |||||
394 | error : utils.log_ajax_error, |
|
394 | error : utils.log_ajax_error, | |
395 | }; |
|
395 | }; | |
396 | $.ajax(utils.url_join_encode(this.kernel_url), settings); |
|
396 | $.ajax(utils.url_join_encode(this.kernel_url), settings); | |
|
397 | this.stop_channels(); | |||
397 | } |
|
398 | } | |
398 | }; |
|
399 | }; | |
399 |
|
400 |
@@ -80,6 +80,7 b' define([' | |||||
80 | error : utils.log_ajax_error, |
|
80 | error : utils.log_ajax_error, | |
81 | }; |
|
81 | }; | |
82 | this.kernel.running = false; |
|
82 | this.kernel.running = false; | |
|
83 | this.kernel.stop_channels(); | |||
83 | var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id); |
|
84 | var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id); | |
84 | $.ajax(url, settings); |
|
85 | $.ajax(url, settings); | |
85 | }; |
|
86 | }; |
@@ -1,12 +1,12 b'' | |||||
1 |
|
1 | |||
2 | // |
|
2 | // | |
3 | // Miscellaneous javascript tests |
|
3 | // Kernel tests | |
4 | // |
|
4 | // | |
5 | casper.notebook_test(function () { |
|
5 | casper.notebook_test(function () { | |
6 | this.evaluate(function () { |
|
6 | this.evaluate(function () { | |
7 | IPython.notebook.kernel.kernel_info( |
|
7 | IPython.notebook.kernel.kernel_info( | |
8 | function(msg){ |
|
8 | function(msg){ | |
9 |
|
|
9 | IPython._kernel_info_response = msg; | |
10 | }) |
|
10 | }) | |
11 | }); |
|
11 | }); | |
12 |
|
12 | |||
@@ -24,5 +24,41 b' casper.notebook_test(function () {' | |||||
24 | this.test.assertTrue( kernel_info_response.msg_type === 'kernel_info_reply', 'Kernel info request return kernel_info_reply'); |
|
24 | 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'); |
|
25 | this.test.assertTrue( kernel_info_response.content !== undefined, 'Kernel_info_reply is not undefined'); | |
26 | }); |
|
26 | }); | |
27 |
|
27 | |||
|
28 | this.thenEvaluate(function () { | |||
|
29 | var kernel = IPython.notebook.session.kernel; | |||
|
30 | IPython._channels = [ | |||
|
31 | kernel.shell_channel, | |||
|
32 | kernel.iopub_channel, | |||
|
33 | kernel.stdin_channel | |||
|
34 | ]; | |||
|
35 | kernel.kill(); | |||
|
36 | }); | |||
|
37 | ||||
|
38 | this.waitFor(function () { | |||
|
39 | return this.evaluate(function(){ | |||
|
40 | for (var i=0; i < IPython._channels.length; i++) { | |||
|
41 | var ws = IPython._channels[i]; | |||
|
42 | if (ws.readyState !== ws.CLOSED) { | |||
|
43 | return false; | |||
|
44 | } | |||
|
45 | } | |||
|
46 | return true; | |||
|
47 | }); | |||
|
48 | }); | |||
|
49 | ||||
|
50 | this.then(function () { | |||
|
51 | var states = this.evaluate(function() { | |||
|
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 | }); | |||
28 | }); |
|
64 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now