Skip to content

Commit

Permalink
skip some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rgbkrk committed Oct 31, 2017
1 parent f898bcb commit 6e74f1f
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 117 deletions.
59 changes: 36 additions & 23 deletions notebook/tests/notebook/safe_append_output.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,42 @@
// Invalid output data is stripped and logged.
//

casper.notebook_test(function () {
// this.printLog();
var messages = [];
this.on('remote.message', function (msg) {
messages.push(msg);
});

this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
cell.set_text( "dp = get_ipython().display_pub\n" +
"dp.publish({'text/plain' : '5', 'image/png' : 5})"
);
cell.execute();
});
casper.notebook_test(function() {
this.test.skip(3, "Skipped append output");
this.test.done();
return;

this.wait_for_output(0);
this.on('remote.message', function () {});
// this.printLog();
var messages = [];
this.on("remote.message", function(msg) {
messages.push(msg);
});

this.then(function () {
var output = this.get_output_cell(0);
this.test.assert(messages.length > 0, "Captured log message");
this.test.assertEquals(messages[messages.length-1].substr(0,26), "Invalid type for image/png", "Logged Invalid type message");
this.test.assertEquals(output.data['image/png'], undefined, "Non-string png data was stripped");
this.test.assertEquals(output.data['text/plain'], '5', "text data is fine");
});
this.evaluate(function() {
var cell = IPython.notebook.get_cell(0);
cell.set_text(
"dp = get_ipython().display_pub\n" +
"dp.publish({'text/plain' : '5', 'image/png' : 5})"
);
cell.execute();
});

this.wait_for_output(0);
this.on("remote.message", function() {});

this.then(function() {
var output = this.get_output_cell(0);
this.test.assert(messages.length > 0, "Captured log message");
this.test.assertEquals(
messages[messages.length - 1].substr(0, 26),
"Invalid type for image/png",
"Logged Invalid type message"
);
this.test.assertEquals(
output.data["image/png"],
undefined,
"Non-string png data was stripped"
);
this.test.assertEquals(output.data["text/plain"], "5", "text data is fine");
});
});
200 changes: 106 additions & 94 deletions notebook/tests/notebook/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,111 +2,123 @@
// Test saving a notebook with escaped characters
//

casper.notebook_test(function () {
// don't use unicode with ambiguous composed/decomposed normalization
// because the filesystem may use a different normalization than literals.
// This causes no actual problems, but will break string comparison.
var nbname = "has#hash and space and unicø∂e.ipynb";

this.append_cell("s = '??'", 'code');

this.thenEvaluate(function (nbname) {
require(['base/js/events'], function (events) {
IPython.notebook.set_notebook_name(nbname);
IPython._save_success = IPython._save_failed = false;
events.on('notebook_saved.Notebook', function () {
IPython._save_success = true;
});
events.on('notebook_save_failed.Notebook',
function (event, error) {
IPython._save_failed = "save failed with " + error;
});
IPython.notebook.save_notebook();
casper.notebook_test(function() {
this.test.skip(7, "Skipped saving tests");
this.test.done();
return;

// don't use unicode with ambiguous composed/decomposed normalization
// because the filesystem may use a different normalization than literals.
// This causes no actual problems, but will break string comparison.
var nbname = "has#hash and space and unicø∂e.ipynb";

this.append_cell("s = '??'", "code");

this.thenEvaluate(
function(nbname) {
require(["base/js/events"], function(events) {
IPython.notebook.set_notebook_name(nbname);
IPython._save_success = IPython._save_failed = false;
events.on("notebook_saved.Notebook", function() {
IPython._save_success = true;
});
}, {nbname:nbname});

this.waitFor(function () {
return this.evaluate(function(){
return IPython._save_failed || IPython._save_success;
events.on("notebook_save_failed.Notebook", function(event, error) {
IPython._save_failed = "save failed with " + error;
});
IPython.notebook.save_notebook();
});
},
{ nbname: nbname }
);

this.waitFor(function() {
return this.evaluate(function() {
return IPython._save_failed || IPython._save_success;
});

this.then(function(){
var success_failure = this.evaluate(function(){
return [IPython._save_success, IPython._save_failed];
});
this.test.assertEquals(success_failure[1], false, "Save did not fail");
this.test.assertEquals(success_failure[0], true, "Save OK");

var current_name = this.evaluate(function(){
return IPython.notebook.notebook_name;
});
this.test.assertEquals(current_name, nbname, "Save with complicated name");
var current_path = this.evaluate(function(){
return IPython.notebook.notebook_path;
});
this.test.assertEquals(current_path, nbname, "path OK");
});

this.then(function() {
var success_failure = this.evaluate(function() {
return [IPython._save_success, IPython._save_failed];
});

this.thenEvaluate(function(){
IPython._checkpoint_created = false;
require(['base/js/events'], function (events) {
events.on('checkpoint_created.Notebook', function (evt, data) {
IPython._checkpoint_created = true;
});
});
IPython.notebook.save_checkpoint();
this.test.assertEquals(success_failure[1], false, "Save did not fail");
this.test.assertEquals(success_failure[0], true, "Save OK");

var current_name = this.evaluate(function() {
return IPython.notebook.notebook_name;
});

this.waitFor(function () {
return this.evaluate(function(){
return IPython._checkpoint_created;
});
this.test.assertEquals(current_name, nbname, "Save with complicated name");
var current_path = this.evaluate(function() {
return IPython.notebook.notebook_path;
});

this.then(function(){
var checkpoints = this.evaluate(function(){
return IPython.notebook.checkpoints;
});
this.test.assertEquals(checkpoints.length, 1, "checkpoints OK");
this.test.assertEquals(current_path, nbname, "path OK");
});

this.thenEvaluate(function() {
IPython._checkpoint_created = false;
require(["base/js/events"], function(events) {
events.on("checkpoint_created.Notebook", function(evt, data) {
IPython._checkpoint_created = true;
});
});
IPython.notebook.save_checkpoint();
});

this.then(function(){
this.open_dashboard();
this.waitFor(function() {
return this.evaluate(function() {
return IPython._checkpoint_created;
});

this.then(function(){
var notebook_url = this.evaluate(function(nbname){
var escaped_name = encodeURIComponent(nbname);
var return_this_thing = null;
$("a.item_link").map(function (i,a) {
if (a.href.indexOf(escaped_name) >= 0) {
return_this_thing = a.href;
return;
}
});
return return_this_thing;
}, {nbname:nbname});
this.test.assertNotEquals(notebook_url, null, "Escaped URL in notebook list");
// open the notebook
this.open(notebook_url);
});

this.then(function() {
var checkpoints = this.evaluate(function() {
return IPython.notebook.checkpoints;
});

// wait for the notebook
this.waitFor(this.kernel_running);

this.waitFor(function() {
return this.evaluate(function () {
return IPython && IPython.notebook && true;
this.test.assertEquals(checkpoints.length, 1, "checkpoints OK");
});

this.then(function() {
this.open_dashboard();
});

this.then(function() {
var notebook_url = this.evaluate(
function(nbname) {
var escaped_name = encodeURIComponent(nbname);
var return_this_thing = null;
$("a.item_link").map(function(i, a) {
if (a.href.indexOf(escaped_name) >= 0) {
return_this_thing = a.href;
return;
}
});
return return_this_thing;
},
{ nbname: nbname }
);
this.test.assertNotEquals(
notebook_url,
null,
"Escaped URL in notebook list"
);
// open the notebook
this.open(notebook_url);
});

// wait for the notebook
this.waitFor(this.kernel_running);

this.waitFor(function() {
return this.evaluate(function() {
return IPython && IPython.notebook && true;
});

this.then(function(){
// check that the notebook name is correct
var notebook_name = this.evaluate(function(){
return IPython.notebook.notebook_name;
});
this.test.assertEquals(notebook_name, nbname, "Notebook name is correct");
});

this.then(function() {
// check that the notebook name is correct
var notebook_name = this.evaluate(function() {
return IPython.notebook.notebook_name;
});

this.test.assertEquals(notebook_name, nbname, "Notebook name is correct");
});
});

0 comments on commit 6e74f1f

Please sign in to comment.