Show More
@@ -1,48 +1,63 | |||||
1 | // Test opening a rich notebook, saving it, and reopening it again. |
|
1 | // Test opening a rich notebook, saving it, and reopening it again. | |
2 | // |
|
2 | // | |
3 | //toJSON fromJSON toJSON and do a string comparison |
|
3 | //toJSON fromJSON toJSON and do a string comparison | |
4 | casper.notebook_test(function () { |
|
4 | casper.notebook_test(function () { | |
5 | this.evaluate(function () { |
|
5 | this.evaluate(function () { | |
6 | var cell = IPython.notebook.get_cell(0); |
|
6 | var cell = IPython.notebook.get_cell(0); | |
7 | // "we have to make messes to find out who we are" |
|
7 | // "we have to make messes to find out who we are" | |
8 | cell.set_text([ |
|
8 | cell.set_text([ | |
9 | "%%javascript", |
|
9 | "%%javascript", | |
10 |
"IPython.notebook.insert_cell_ |
|
10 | "IPython.notebook.insert_cell_below('code')" | |
11 | ].join('\n') |
|
11 | ].join('\n') | |
12 | ); |
|
12 | ); | |
13 |
|
13 | |||
14 | cell.execute(); |
|
14 | cell.execute(); | |
15 | }); |
|
15 | }); | |
16 |
|
16 | |||
17 | this.wait_for_output(0); |
|
17 | this.wait_for_output(0); | |
18 |
|
18 | |||
19 | this.then(function ( ) { |
|
19 | this.then(function ( ) { | |
20 |
var result = this.get_output_cell( |
|
20 | var result = this.get_output_cell(0); | |
21 | var num_cells = this.get_cells_length(); |
|
21 | var num_cells = this.get_cells_length(); | |
22 | this.test.assertEquals(num_cells, 2, '%%javascript magic works'); |
|
22 | this.test.assertEquals(num_cells, 2, '%%javascript magic works'); | |
23 |
this.test.assertTrue(result.hasOwnProperty('application/javascript'), |
|
23 | this.test.assertTrue(result.hasOwnProperty('application/javascript'), | |
|
24 | 'JS embeded with mime key'); | |||
24 | }); |
|
25 | }); | |
25 |
|
26 | |||
|
27 | //this.thenEvaluate(function() { IPython.notebook.save_notebook(); }); | |||
|
28 | ||||
|
29 | this.then(function ( ) { | |||
|
30 | json = this.evaluate(function() { | |||
|
31 | // the appended cell will initiall be empty | |||
|
32 | var json = IPython.notebook.get_cell(0).output_area.toJSON(); | |||
|
33 | var cell = IPython.notebook.get_cell(1).output_area.fromJSON(json); | |||
|
34 | return json; | |||
|
35 | }); | |||
|
36 | var result = this.get_output_cell(0); | |||
|
37 | var result2 = this.get_output_cell(1); | |||
|
38 | this.test.assertTrue(result.hasOwnProperty('application/javascript'), | |||
|
39 | 'embeded JS keeps mime key after save'); | |||
|
40 | this.test.assertTrue(json[0].hasOwnProperty('javascript'), | |||
|
41 | 'JSON representation uses short keys'); | |||
|
42 | this.test.assertTrue(result2.hasOwnProperty('application/javascript'), | |||
|
43 | 'embeded JS keeps mime key on fromJSON'); | |||
|
44 | ||||
|
45 | }); | |||
26 |
|
46 | |||
27 | //this.thenEvaluate(function () { var cell = IPython.notebook.get_cell(0); |
|
47 | ||
|
48 | //this.thenEvaluate(function () { | |||
|
49 | //var cell = IPython.notebook.get_cell(0); | |||
28 |
|
50 | |||
29 | // // we have to make messes to find out who we are |
|
51 | // // we have to make messes to find out who we are | |
30 | // cell.set_text([ |
|
52 | // cell.set_text([ | |
31 | // "import IPython.html.tests as t", |
|
53 | // "import IPython.html.tests as t", | |
32 | // "t.write_test_notebook('rich_output.ipynb')" |
|
54 | // "t.write_test_notebook('rich_output.ipynb')" | |
33 | // ].join('\n') |
|
55 | // ].join('\n') | |
34 | // ); |
|
56 | // ); | |
35 |
|
57 | |||
36 | // cell.execute(); |
|
58 | // cell.execute(); | |
37 | //}); |
|
59 | //}); | |
38 | // |
|
60 | // | |
39 | //this.wait_for_output(0); |
|
61 | //this.wait_for_output(0); | |
40 |
|
62 | |||
41 | //this.then(function ( ) { |
|
|||
42 | // var result = this.get_output_cell(0); |
|
|||
43 | // var num_cells = this.get_cells_length(); |
|
|||
44 | // this.test.assertEquals(result.text, '10\n', 'opening notebook JSON'); |
|
|||
45 | // this.test.assertEquals(num_cells, 2, ' %%javascript magic works') |
|
|||
46 | //}); |
|
|||
47 |
|
||||
48 | }); |
|
63 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now