##// END OF EJS Templates
Merge pull request #4971 from ellisonbg/testjs-fd...
Min RK -
r14979:869d7341 merge
parent child Browse files
Show More
@@ -1836,7 +1836,24 b' var IPython = (function (IPython) {'
1836 );
1836 );
1837 $.ajax(url, settings);
1837 $.ajax(url, settings);
1838 };
1838 };
1839
1839
1840 Notebook.prototype.delete = function () {
1841 var that = this;
1842 var settings = {
1843 processData : false,
1844 cache : false,
1845 type : "DELETE",
1846 dataType: "json",
1847 };
1848 var url = utils.url_join_encode(
1849 this._baseProjectUrl,
1850 'api/notebooks',
1851 this.notebook_path,
1852 this.notebook_name
1853 );
1854 $.ajax(url, settings);
1855 };
1856
1840
1857
1841 Notebook.prototype.rename_success = function (json, status, xhr) {
1858 Notebook.prototype.rename_success = function (json, status, xhr) {
1842 this.notebook_name = json.name;
1859 this.notebook_name = json.name;
@@ -18,17 +18,10 b' casper.open_new_notebook = function () {'
18
18
19 this.withPopup('', function () {this.waitForSelector('.CodeMirror-code');});
19 this.withPopup('', function () {this.waitForSelector('.CodeMirror-code');});
20 this.then(function () {
20 this.then(function () {
21 // XXX: Kind of odd, the next line works for one test, but not when
22 // running multiple tests back-to-back, so we will just point the main
23 // casper browser to the same URL as the popup we just grabbed.
24
25 //this.page = this.popups[0];
26 this.open(this.popups[0].url);
21 this.open(this.popups[0].url);
27 });
22 });
28
23
29 // initially, the cells aren't created, so wait for them to appear
24 // Make sure the kernel has started
30 this.waitForSelector('.CodeMirror-code');
31 // and make sure the kernel has started
32 this.waitFor( this.kernel_running );
25 this.waitFor( this.kernel_running );
33 // track the IPython busy/idle state
26 // track the IPython busy/idle state
34 this.thenEvaluate(function () {
27 this.thenEvaluate(function () {
@@ -41,7 +34,7 b' casper.open_new_notebook = function () {'
41 });
34 });
42 };
35 };
43
36
44 // return whether or not the kernel is running
37 // Return whether or not the kernel is running.
45 casper.kernel_running = function kernel_running() {
38 casper.kernel_running = function kernel_running() {
46 return this.evaluate(function kernel_running() {
39 return this.evaluate(function kernel_running() {
47 return IPython.notebook.kernel.running;
40 return IPython.notebook.kernel.running;
@@ -53,16 +46,15 b' casper.shutdown_current_kernel = function () {'
53 this.thenEvaluate(function() {
46 this.thenEvaluate(function() {
54 IPython.notebook.kernel.kill();
47 IPython.notebook.kernel.kill();
55 });
48 });
49 // We close the page right after this so we need to give it time to complete.
50 this.wait(1000);
56 };
51 };
57
52
58 // Delete created notebook.
53 // Delete created notebook.
59 casper.delete_current_notebook = function () {
54 casper.delete_current_notebook = function () {
55 // For some unknown reason, this doesn't work?!?
60 this.thenEvaluate(function() {
56 this.thenEvaluate(function() {
61 var nbData = $('body').data();
57 IPython.notebook.delete();
62 var url = nbData.baseProjectUrl + 'notebooks/' + nbData.notebookId;
63 $.ajax(url, {
64 type: 'DELETE',
65 });
66 });
58 });
67 };
59 };
68
60
@@ -135,9 +127,7 b' casper.set_cell_text = function(index, text){'
135 // Inserts a cell at the bottom of the notebook
127 // Inserts a cell at the bottom of the notebook
136 // Returns the new cell's index.
128 // Returns the new cell's index.
137 casper.insert_cell_at_bottom = function(cell_type){
129 casper.insert_cell_at_bottom = function(cell_type){
138 if (cell_type===undefined) {
130 cell_type = cell_type || 'code';
139 cell_type = 'code';
140 }
141
131
142 return this.evaluate(function (cell_type) {
132 return this.evaluate(function (cell_type) {
143 var cell = IPython.notebook.insert_cell_at_bottom(cell_type);
133 var cell = IPython.notebook.insert_cell_at_bottom(cell_type);
@@ -210,15 +200,20 b' casper.cell_element_function = function(index, selector, function_name, function'
210 casper.notebook_test = function(test) {
200 casper.notebook_test = function(test) {
211 this.open_new_notebook();
201 this.open_new_notebook();
212 this.then(test);
202 this.then(test);
213 //XXX: we get sporadic error messages when shutting down some of the tests.
203
214 // Since the entire server will go down at the end of running the test
204 // Kill the kernel and delete the notebook.
215 // suite, it's ok for now to not try to shut anything down.
216 this.shutdown_current_kernel();
205 this.shutdown_current_kernel();
206 // This is still broken but shouldn't be a problem for now.
207 // this.delete_current_notebook();
217
208
218 //XXX: the implementation of delete_current_notebook is currently broken
209 // This is required to clean up the page we just finished with. If we don't call this
219 // it's not a big deal, since the notebook directory will be deleted on
210 // casperjs will leak file descriptors of all the open WebSockets in that page. We
220 // cleanup, but we should add tests for deleting the notebook separately
211 // have to set this.page=null so that next time casper.start runs, it will create a
221 //this.delete_current_notebook();
212 // new page from scratch.
213 this.then(function () {
214 this.page.close();
215 this.page = null;
216 });
222
217
223 // Run the browser automation.
218 // Run the browser automation.
224 this.run(function() {
219 this.run(function() {
@@ -167,6 +167,7 b' class JSController(TestController):'
167 self.section = section
167 self.section = section
168
168
169 self.ipydir = TemporaryDirectory()
169 self.ipydir = TemporaryDirectory()
170 # print(self.ipydir.name)
170 self.dirs.append(self.ipydir)
171 self.dirs.append(self.ipydir)
171 self.env['IPYTHONDIR'] = self.ipydir.name
172 self.env['IPYTHONDIR'] = self.ipydir.name
172
173
General Comments 0
You need to be logged in to leave comments. Login now