Adding dashboard navigation tests for dir browsing.

pull/37/head
Brian E. Granger 12 years ago
parent c1a8f5af6a
commit 717f031e01

@ -68,7 +68,7 @@ class TestNotebookManager(TestCase):
try:
os.makedirs(os_path)
except OSError:
print("Directory already exists.")
print("Directory already exists: %r" % os_path)
def test_create_notebook_model(self):
with TemporaryDirectory() as td:

@ -0,0 +1,45 @@
casper.wait_for_list = function () {
casper.waitForSelector('.list_item');
// casper.wait(500);
}
casper.get_list_items = function () {
return this.evaluate(function () {
return $.makeArray($('.item_link').map(function () {
return {
link: $(this).attr('href'),
label: $(this).find('.item_name').text()
}
}));
});
}
casper.test_items = function (test, baseUrl) {
casper.then(function () {
var items = casper.get_list_items();
casper.each(items, function (self, item) {
if (!item.label.match('.ipynb$')) {
var followed_url = baseUrl+item.link;
if (!followed_url.match('/\.\.$')) {
casper.thenOpen(baseUrl+item.link, function () {
casper.wait_for_list();
test.assertEquals(this.getCurrentUrl(), followed_url, 'Testing dashboard link: '+followed_url);
casper.test_items(test, baseUrl);
this.back();
});
}
}
});
});
}
casper.test.begin('Testing dashboard navigation', function (test) {
var baseUrl = casper.get_notebook_server();
casper.start(baseUrl);
casper.echo(baseUrl);
casper.wait_for_list();
casper.test_items(test, baseUrl);
casper.run(function() {
test.done();
});
});

@ -1,5 +1,7 @@
"""Base class for notebook tests."""
from __future__ import print_function
import sys
import time
import requests

@ -167,6 +167,10 @@ class JSController(TestController):
self.section = section
self.ipydir = TemporaryDirectory()
self.nbdir = os.path.join(self.ipydir.name, 'notebooks')
print("Running notebook tests in directory: %r" % self.nbdir)
os.makedirs(os.path.join(self.nbdir, 'subdir1/subdir1a'))
os.makedirs(os.path.join(self.nbdir, 'subdir2/subdir2a'))
# print(self.ipydir.name)
self.dirs.append(self.ipydir)
self.env['IPYTHONDIR'] = self.ipydir.name
@ -191,7 +195,7 @@ class JSController(TestController):
def _init_server(self):
"Start the notebook server in a separate process"
self.queue = q = Queue()
self.server = Process(target=run_webapp, args=(q, self.ipydir.name))
self.server = Process(target=run_webapp, args=(q, self.ipydir.name, self.nbdir))
self.server.start()
self.server_port = q.get()
@ -202,17 +206,17 @@ class JSController(TestController):
js_test_group_names = {'js'}
def run_webapp(q, nbdir, loglevel=0):
def run_webapp(q, ipydir, nbdir, loglevel=0):
"""start the IPython Notebook, and pass port back to the queue"""
import os
import IPython.html.notebookapp as nbapp
import sys
sys.stderr = open(os.devnull, 'w')
os.environ["IPYTHONDIR"] = nbdir
os.environ["IPYTHONDIR"] = ipydir
server = nbapp.NotebookApp()
args = ['--no-browser']
args.append('--notebook-dir='+nbdir)
args.append('--profile-dir='+nbdir)
args.append('--profile-dir='+ipydir)
args.append('--log-level='+str(loglevel))
server.initialize(args)
# communicate the port number to the parent process

Loading…
Cancel
Save