Skip to content

Commit a7b122f

Browse files
committed
Add more kernel message buffer tests.
1 parent 4a05b1f commit a7b122f

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

notebook/tests/notebook/buffering.js

+32-12
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
// Test buffering for execution requests.
33
//
44
casper.notebook_test(function () {
5-
this.evaluate(function () {
5+
this.then(function() {
6+
// make sure there are at least three cells for the tests below.
7+
this.append_cell();
8+
this.append_cell();
9+
this.append_cell();
10+
})
11+
12+
this.thenEvaluate(function () {
13+
IPython.notebook.kernel.stop_channels();
614
var cell = IPython.notebook.get_cell(0);
715
cell.set_text('a=10; print(a)');
8-
IPython.notebook.kernel.stop_channels();
916
IPython.notebook.execute_cells([0]);
1017
IPython.notebook.kernel.reconnect(1);
1118
});
@@ -14,23 +21,36 @@ casper.notebook_test(function () {
1421

1522
this.then(function () {
1623
var result = this.get_output_cell(0);
17-
this.test.assertEquals(result.text, '10\n', 'kernels buffer execution requests if connection is down');
24+
this.test.assertEquals(result.text, '10\n', 'kernels buffer messages if connection is down');
1825
});
19-
26+
2027
this.thenEvaluate(function () {
2128
var cell = IPython.notebook.get_cell(0);
22-
cell.set_text('a=11; print(a)');
23-
cell.kernel = null;
24-
IPython.notebook.kernel = null;
29+
var cellplus = IPython.notebook.get_cell(1);
30+
var cellprint = IPython.notebook.get_cell(2);
31+
cell.set_text('k=1');
32+
cellplus.set_text('k+=1');
33+
cellprint.set_text('k*=2')
34+
35+
IPython.notebook.kernel.stop_channels();
36+
37+
// Repeated execution of cell queued up in the kernel executes
38+
// each execution request in order.
2539
IPython.notebook.execute_cells([0]);
26-
IPython.notebook._session_started();
40+
IPython.notebook.execute_cells([2]);
41+
IPython.notebook.execute_cells([1]);
42+
IPython.notebook.execute_cells([1]);
43+
IPython.notebook.execute_cells([1]);
44+
cellprint.set_text('print(k)')
45+
IPython.notebook.execute_cells([2]);
46+
47+
IPython.notebook.kernel.reconnect(1);
2748
});
2849

29-
this.wait_for_output(0);
50+
this.wait_for_output(2);
3051

3152
this.then(function () {
32-
var result = this.get_output_cell(0);
33-
this.test.assertEquals(result.text, '11\n', 'notebooks buffer cell execution requests if kernel is not set');
53+
var result = this.get_output_cell(2);
54+
this.test.assertEquals(result.text, '5\n', 'kernels send buffered messages in order');
3455
});
35-
3656
});

0 commit comments

Comments
 (0)