mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Merge pull request #4971 from ellisonbg/testjs-fd
Fixing issues with js tests
This commit is contained in:
commit
003c5e8eda
@ -1837,6 +1837,23 @@ var IPython = (function (IPython) {
|
|||||||
$.ajax(url, settings);
|
$.ajax(url, settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Notebook.prototype.delete = function () {
|
||||||
|
var that = this;
|
||||||
|
var settings = {
|
||||||
|
processData : false,
|
||||||
|
cache : false,
|
||||||
|
type : "DELETE",
|
||||||
|
dataType: "json",
|
||||||
|
};
|
||||||
|
var url = utils.url_join_encode(
|
||||||
|
this._baseProjectUrl,
|
||||||
|
'api/notebooks',
|
||||||
|
this.notebook_path,
|
||||||
|
this.notebook_name
|
||||||
|
);
|
||||||
|
$.ajax(url, settings);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Notebook.prototype.rename_success = function (json, status, xhr) {
|
Notebook.prototype.rename_success = function (json, status, xhr) {
|
||||||
this.notebook_name = json.name;
|
this.notebook_name = json.name;
|
||||||
|
@ -18,17 +18,10 @@ casper.open_new_notebook = function () {
|
|||||||
|
|
||||||
this.withPopup('', function () {this.waitForSelector('.CodeMirror-code');});
|
this.withPopup('', function () {this.waitForSelector('.CodeMirror-code');});
|
||||||
this.then(function () {
|
this.then(function () {
|
||||||
// XXX: Kind of odd, the next line works for one test, but not when
|
|
||||||
// running multiple tests back-to-back, so we will just point the main
|
|
||||||
// casper browser to the same URL as the popup we just grabbed.
|
|
||||||
|
|
||||||
//this.page = this.popups[0];
|
|
||||||
this.open(this.popups[0].url);
|
this.open(this.popups[0].url);
|
||||||
});
|
});
|
||||||
|
|
||||||
// initially, the cells aren't created, so wait for them to appear
|
// Make sure the kernel has started
|
||||||
this.waitForSelector('.CodeMirror-code');
|
|
||||||
// and make sure the kernel has started
|
|
||||||
this.waitFor( this.kernel_running );
|
this.waitFor( this.kernel_running );
|
||||||
// track the IPython busy/idle state
|
// track the IPython busy/idle state
|
||||||
this.thenEvaluate(function () {
|
this.thenEvaluate(function () {
|
||||||
@ -41,7 +34,7 @@ casper.open_new_notebook = function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// return whether or not the kernel is running
|
// Return whether or not the kernel is running.
|
||||||
casper.kernel_running = function kernel_running() {
|
casper.kernel_running = function kernel_running() {
|
||||||
return this.evaluate(function kernel_running() {
|
return this.evaluate(function kernel_running() {
|
||||||
return IPython.notebook.kernel.running;
|
return IPython.notebook.kernel.running;
|
||||||
@ -53,16 +46,15 @@ casper.shutdown_current_kernel = function () {
|
|||||||
this.thenEvaluate(function() {
|
this.thenEvaluate(function() {
|
||||||
IPython.notebook.kernel.kill();
|
IPython.notebook.kernel.kill();
|
||||||
});
|
});
|
||||||
|
// We close the page right after this so we need to give it time to complete.
|
||||||
|
this.wait(1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Delete created notebook.
|
// Delete created notebook.
|
||||||
casper.delete_current_notebook = function () {
|
casper.delete_current_notebook = function () {
|
||||||
|
// For some unknown reason, this doesn't work?!?
|
||||||
this.thenEvaluate(function() {
|
this.thenEvaluate(function() {
|
||||||
var nbData = $('body').data();
|
IPython.notebook.delete();
|
||||||
var url = nbData.baseProjectUrl + 'notebooks/' + nbData.notebookId;
|
|
||||||
$.ajax(url, {
|
|
||||||
type: 'DELETE',
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,9 +127,7 @@ casper.set_cell_text = function(index, text){
|
|||||||
// Inserts a cell at the bottom of the notebook
|
// Inserts a cell at the bottom of the notebook
|
||||||
// Returns the new cell's index.
|
// Returns the new cell's index.
|
||||||
casper.insert_cell_at_bottom = function(cell_type){
|
casper.insert_cell_at_bottom = function(cell_type){
|
||||||
if (cell_type===undefined) {
|
cell_type = cell_type || 'code';
|
||||||
cell_type = 'code';
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.evaluate(function (cell_type) {
|
return this.evaluate(function (cell_type) {
|
||||||
var cell = IPython.notebook.insert_cell_at_bottom(cell_type);
|
var cell = IPython.notebook.insert_cell_at_bottom(cell_type);
|
||||||
@ -210,16 +200,21 @@ casper.cell_element_function = function(index, selector, function_name, function
|
|||||||
casper.notebook_test = function(test) {
|
casper.notebook_test = function(test) {
|
||||||
this.open_new_notebook();
|
this.open_new_notebook();
|
||||||
this.then(test);
|
this.then(test);
|
||||||
//XXX: we get sporadic error messages when shutting down some of the tests.
|
|
||||||
// Since the entire server will go down at the end of running the test
|
|
||||||
// suite, it's ok for now to not try to shut anything down.
|
|
||||||
this.shutdown_current_kernel();
|
|
||||||
|
|
||||||
//XXX: the implementation of delete_current_notebook is currently broken
|
// Kill the kernel and delete the notebook.
|
||||||
// it's not a big deal, since the notebook directory will be deleted on
|
this.shutdown_current_kernel();
|
||||||
// cleanup, but we should add tests for deleting the notebook separately
|
// This is still broken but shouldn't be a problem for now.
|
||||||
// this.delete_current_notebook();
|
// this.delete_current_notebook();
|
||||||
|
|
||||||
|
// This is required to clean up the page we just finished with. If we don't call this
|
||||||
|
// casperjs will leak file descriptors of all the open WebSockets in that page. We
|
||||||
|
// have to set this.page=null so that next time casper.start runs, it will create a
|
||||||
|
// new page from scratch.
|
||||||
|
this.then(function () {
|
||||||
|
this.page.close();
|
||||||
|
this.page = null;
|
||||||
|
});
|
||||||
|
|
||||||
// Run the browser automation.
|
// Run the browser automation.
|
||||||
this.run(function() {
|
this.run(function() {
|
||||||
this.test.done();
|
this.test.done();
|
||||||
|
@ -167,6 +167,7 @@ class JSController(TestController):
|
|||||||
self.section = section
|
self.section = section
|
||||||
|
|
||||||
self.ipydir = TemporaryDirectory()
|
self.ipydir = TemporaryDirectory()
|
||||||
|
# print(self.ipydir.name)
|
||||||
self.dirs.append(self.ipydir)
|
self.dirs.append(self.ipydir)
|
||||||
self.env['IPYTHONDIR'] = self.ipydir.name
|
self.env['IPYTHONDIR'] = self.ipydir.name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user