mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
first review pass on widget tests
This commit is contained in:
parent
36db60eacb
commit
119052f75d
@ -6,7 +6,7 @@ casper.notebook_test(function () {
|
||||
|
||||
// Check if the WidgetManager class is defined.
|
||||
this.test.assert(this.evaluate(function() {
|
||||
return IPython.WidgetManager != undefined;
|
||||
return IPython.WidgetManager !== undefined;
|
||||
}), 'WidgetManager class is defined');
|
||||
});
|
||||
|
||||
@ -19,10 +19,10 @@ casper.notebook_test(function () {
|
||||
this.wait(500); // Wait for require.js async callbacks to load dependencies.
|
||||
|
||||
this.then(function () {
|
||||
// Check if the widget manager has been instanciated.
|
||||
// Check if the widget manager has been instantiated.
|
||||
this.test.assert(this.evaluate(function() {
|
||||
return IPython.notebook.kernel.widget_manager != undefined;
|
||||
}), 'Notebook widget manager instanciated');
|
||||
return IPython.notebook.kernel.widget_manager !== undefined;
|
||||
}), 'Notebook widget manager instantiated');
|
||||
});
|
||||
|
||||
throttle_index = this.append_cell(
|
||||
@ -33,10 +33,10 @@ casper.notebook_test(function () {
|
||||
'def handle_change(name, old, new):\n' +
|
||||
' print(len(new))\n' +
|
||||
' time.sleep(0.5)\n' +
|
||||
'textbox.on_trait_change(handle_change)\n' +
|
||||
'textbox.on_trait_change(handle_change, "value")\n' +
|
||||
'print("Success")');
|
||||
this.execute_cell_then(throttle_index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Test throttling cell executed with correct output');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -53,24 +53,17 @@ casper.notebook_test(function () {
|
||||
this.wait(2000); // Wait for clicks to execute in kernel
|
||||
|
||||
this.then(function(){
|
||||
var resume = true;
|
||||
var i = 0;
|
||||
while (resume) {
|
||||
i++;
|
||||
var output = this.get_output_cell(throttle_index, i);
|
||||
if (output === undefined || output === null) {
|
||||
resume = false;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
var outputs = this.evaluate(function(i) {
|
||||
return IPython.notebook.get_cell(i).output_area.outputs;
|
||||
}, {i : throttle_index});
|
||||
|
||||
// Only 4 outputs should have printed, but because of timing, sometimes
|
||||
// 5 outputs will print. All we need to do is verify num outputs <= 5
|
||||
// because that is much less than 20.
|
||||
this.test.assert(i <= 5, 'Messages throttled.');
|
||||
this.test.assert(outputs.length <= 5, 'Messages throttled.');
|
||||
|
||||
// We also need to verify that the last state sent was correct.
|
||||
var last_state = this.get_output_cell(throttle_index, i).text;
|
||||
this.test.assert(last_state == "20\n", "Last state sent when throttling.");
|
||||
var last_state = outputs[outputs.length-1].text;
|
||||
this.test.assertEquals(last_state, "20\n", "Last state sent when throttling.");
|
||||
});
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")');
|
||||
this.execute_cell_then(bool_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create bool widget cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -57,7 +57,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")');
|
||||
this.execute_cell_then(index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Change bool widget value cell executed with correct output.');
|
||||
|
||||
this.test.assert(! this.cell_element_function(bool_index,
|
||||
|
@ -15,7 +15,7 @@ casper.notebook_test(function () {
|
||||
'button.on_click(handle_click)');
|
||||
this.execute_cell_then(button_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create button cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -37,7 +37,7 @@ casper.notebook_test(function () {
|
||||
this.wait(500); // Wait for click to execute in kernel and write output
|
||||
|
||||
this.then(function () {
|
||||
this.test.assert(this.get_output_cell(button_index, 1).text == 'Clicked\n',
|
||||
this.test.assertEquals(this.get_output_cell(button_index, 1).text, 'Clicked\n',
|
||||
'Button click event fires.');
|
||||
});
|
||||
});
|
@ -15,7 +15,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(container_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create container cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -40,7 +40,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Set container class CSS cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_function(container_index,
|
||||
@ -53,7 +53,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Remove container class cell executed with correct output.');
|
||||
|
||||
this.test.assert(! this.cell_element_exists(container_index,
|
||||
@ -66,7 +66,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Display container child executed with correct output.');
|
||||
|
||||
this.test.assert(! this.cell_element_exists(index,
|
||||
|
@ -15,7 +15,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(float_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create float cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -33,7 +33,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(float_widget.value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '1.05\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '1.05\n',
|
||||
'Float textbox value set.');
|
||||
this.cell_element_function(float_index, float_text_query_2, 'val', ['']);
|
||||
this.sendKeys(float_text_query_2, '123456789.0');
|
||||
@ -43,7 +43,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(float_widget.value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '123456789.0\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '123456789.0\n',
|
||||
'Long float textbox value set (probably triggers throttling).');
|
||||
this.cell_element_function(float_index, float_text_query_2, 'val', ['']);
|
||||
this.sendKeys(float_text_query_2, '12hello');
|
||||
@ -53,7 +53,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(float_widget.value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '12.0\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '12.0\n',
|
||||
'Invald float textbox value caught and filtered.');
|
||||
});
|
||||
|
||||
@ -73,7 +73,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(floatrange_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create float range cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -95,7 +95,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Float range properties cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(floatrange_index, slider_query),
|
||||
|
@ -32,7 +32,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(image_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create image executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -49,12 +49,12 @@ casper.notebook_test(function () {
|
||||
this.captureSelector(capture_filename, '.my-test-image');
|
||||
var stream = fs.open(capture_filename, 'rb');
|
||||
var captured = btoa(stream.read());
|
||||
stream.close()
|
||||
stream.close();
|
||||
fs.remove(capture_filename);
|
||||
|
||||
// Uncomment line below to output captured image data to a text file.
|
||||
// fs.write('./captured.txt', captured, 'w');
|
||||
|
||||
this.test.assert(test_results==captured, "Red image data displayed correctly.");
|
||||
this.test.assertEquals(test_results, captured, "Red image data displayed correctly.");
|
||||
});
|
||||
});
|
@ -15,7 +15,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(int_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create int cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -33,7 +33,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(int_widget.value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '1\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '1\n',
|
||||
'Int textbox value set.');
|
||||
this.cell_element_function(int_index, int_text_query_2, 'val', ['']);
|
||||
this.sendKeys(int_text_query_2, '123456789');
|
||||
@ -43,7 +43,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(int_widget.value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '123456789\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '123456789\n',
|
||||
'Long int textbox value set (probably triggers throttling).');
|
||||
this.cell_element_function(int_index, int_text_query_2, 'val', ['']);
|
||||
this.sendKeys(int_text_query_2, '12hello');
|
||||
@ -53,7 +53,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(int_widget.value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '12\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '12\n',
|
||||
'Invald int textbox value caught and filtered.');
|
||||
});
|
||||
|
||||
@ -74,7 +74,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(intrange_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create int range cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -96,7 +96,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Int range properties cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(intrange_index, slider_query),
|
||||
@ -119,7 +119,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(intrange[0].value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '1\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '1\n',
|
||||
'Int textbox set int range value');
|
||||
|
||||
// Clear the int textbox value and then set it to 120 by emulating
|
||||
@ -132,7 +132,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(intrange[0].value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '50\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '50\n',
|
||||
'Int textbox value bound');
|
||||
|
||||
// Clear the int textbox value and then set it to 'hello world' by
|
||||
@ -145,7 +145,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(intrange[0].value)\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '50\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '50\n',
|
||||
'Invalid int textbox characters ignored');
|
||||
});
|
||||
});
|
@ -19,7 +19,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(multicontainer1_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create multicontainer cell executed with correct output. (1)');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -33,7 +33,7 @@ casper.notebook_test(function () {
|
||||
'First widget tab list exists.');
|
||||
|
||||
// JQuery selector is 1 based
|
||||
this.click(multicontainer1_query + ' li:nth-child(2) a')
|
||||
this.click(multicontainer1_query + ' li:nth-child(2) a');
|
||||
});
|
||||
|
||||
this.wait(500); // Wait for change to execute in kernel
|
||||
@ -42,16 +42,16 @@ casper.notebook_test(function () {
|
||||
'print(multicontainer.selected_index)\n' +
|
||||
'multicontainer.selected_index = 2'); // 0 based
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '1\n', // 0 based
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '1\n', // 0 based
|
||||
'selected_index property updated with tab change.');
|
||||
|
||||
// JQuery selector is 1 based
|
||||
this.test.assert(!this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(1)', 'hasClass', ['active']),
|
||||
"Tab 1 is not selected.")
|
||||
"Tab 1 is not selected.");
|
||||
this.test.assert(!this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(2)', 'hasClass', ['active']),
|
||||
"Tab 2 is not selected.")
|
||||
"Tab 2 is not selected.");
|
||||
this.test.assert(this.cell_element_function(multicontainer1_index, multicontainer1_query + ' li:nth-child(3)', 'hasClass', ['active']),
|
||||
"Tab 3 is selected.")
|
||||
"Tab 3 is selected.");
|
||||
});
|
||||
|
||||
index = this.append_cell('multicontainer.set_title(1, "hello")\nprint("Success")'); // 0 based
|
||||
@ -75,7 +75,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(multicontainer2_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create multicontainer cell executed with correct output. (2)');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -102,7 +102,7 @@ casper.notebook_test(function () {
|
||||
|
||||
index = this.append_cell('print(multicontainer.selected_index)'); // 0 based
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == '1\n', // 0 based
|
||||
this.test.assertEquals(this.get_output_cell(index).text, '1\n', // 0 based
|
||||
'selected_index property updated with tab change.');
|
||||
});
|
||||
});
|
@ -6,10 +6,10 @@ casper.notebook_test(function () {
|
||||
'print("Success")');
|
||||
this.execute_cell_then(index);
|
||||
|
||||
var combo_selector = '.widget-area .widget-subarea .widget-hbox-single .btn-group .widget-combo-btn'
|
||||
var multibtn_selector = '.widget-area .widget-subarea .widget-hbox-single .btn-group[data-toggle="buttons-radio"]'
|
||||
var radio_selector = '.widget-area .widget-subarea .widget-hbox .vbox'
|
||||
var list_selector = '.widget-area .widget-subarea .widget-hbox .widget-listbox'
|
||||
var combo_selector = '.widget-area .widget-subarea .widget-hbox-single .btn-group .widget-combo-btn';
|
||||
var multibtn_selector = '.widget-area .widget-subarea .widget-hbox-single .btn-group[data-toggle="buttons-radio"]';
|
||||
var radio_selector = '.widget-area .widget-subarea .widget-hbox .vbox';
|
||||
var list_selector = '.widget-area .widget-subarea .widget-hbox .widget-listbox';
|
||||
|
||||
var selection_index;
|
||||
var selection_values = 'abcd';
|
||||
@ -30,7 +30,7 @@ casper.notebook_test(function () {
|
||||
combo_state == state;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var verify_selection = function(context, index){
|
||||
for (var i = 0; i < selection_values.length; i++) {
|
||||
@ -39,7 +39,7 @@ casper.notebook_test(function () {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//values=["' + selection_values + '"[i] for i in range(4)]
|
||||
selection_index = this.append_cell(
|
||||
@ -56,7 +56,7 @@ casper.notebook_test(function () {
|
||||
' widget.on_trait_change(handle_change, "value")\n' +
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(selection_index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create selection cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
@ -84,7 +84,7 @@ casper.notebook_test(function () {
|
||||
' widget.value = "a"\n' +
|
||||
'print("Success")\n');
|
||||
this.execute_cell_then(index, function(index){
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Python select item executed with correct output.');
|
||||
|
||||
// Verify that the first item is selected.
|
||||
|
@ -15,7 +15,7 @@ casper.notebook_test(function () {
|
||||
'print("Success")');
|
||||
this.execute_cell_then(string_index, function(index){
|
||||
|
||||
this.test.assert(this.get_output_cell(index).text == 'Success\n',
|
||||
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
|
||||
'Create string widget cell executed with correct output.');
|
||||
|
||||
this.test.assert(this.cell_element_exists(index,
|
||||
|
Loading…
Reference in New Issue
Block a user