##// END OF EJS Templates
Adding dashboard navigation tests for dir browsing.
Brian E. Granger -
Show More
@@ -0,0 +1,45 b''
1 casper.wait_for_list = function () {
2 casper.waitForSelector('.list_item');
3 // casper.wait(500);
4 }
5
6 casper.get_list_items = function () {
7 return this.evaluate(function () {
8 return $.makeArray($('.item_link').map(function () {
9 return {
10 link: $(this).attr('href'),
11 label: $(this).find('.item_name').text()
12 }
13 }));
14 });
15 }
16
17 casper.test_items = function (test, baseUrl) {
18 casper.then(function () {
19 var items = casper.get_list_items();
20 casper.each(items, function (self, item) {
21 if (!item.label.match('.ipynb$')) {
22 var followed_url = baseUrl+item.link;
23 if (!followed_url.match('/\.\.$')) {
24 casper.thenOpen(baseUrl+item.link, function () {
25 casper.wait_for_list();
26 test.assertEquals(this.getCurrentUrl(), followed_url, 'Testing dashboard link: '+followed_url);
27 casper.test_items(test, baseUrl);
28 this.back();
29 });
30 }
31 }
32 });
33 });
34 }
35
36 casper.test.begin('Testing dashboard navigation', function (test) {
37 var baseUrl = casper.get_notebook_server();
38 casper.start(baseUrl);
39 casper.echo(baseUrl);
40 casper.wait_for_list();
41 casper.test_items(test, baseUrl);
42 casper.run(function() {
43 test.done();
44 });
45 });
@@ -68,7 +68,7 b' class TestNotebookManager(TestCase):'
68 try:
68 try:
69 os.makedirs(os_path)
69 os.makedirs(os_path)
70 except OSError:
70 except OSError:
71 print("Directory already exists.")
71 print("Directory already exists: %r" % os_path)
72
72
73 def test_create_notebook_model(self):
73 def test_create_notebook_model(self):
74 with TemporaryDirectory() as td:
74 with TemporaryDirectory() as td:
@@ -1,5 +1,7 b''
1 """Base class for notebook tests."""
1 """Base class for notebook tests."""
2
2
3 from __future__ import print_function
4
3 import sys
5 import sys
4 import time
6 import time
5 import requests
7 import requests
@@ -167,6 +167,10 b' class JSController(TestController):'
167 self.section = section
167 self.section = section
168
168
169 self.ipydir = TemporaryDirectory()
169 self.ipydir = TemporaryDirectory()
170 self.nbdir = os.path.join(self.ipydir.name, 'notebooks')
171 print("Running notebook tests in directory: %r" % self.nbdir)
172 os.makedirs(os.path.join(self.nbdir, 'subdir1/subdir1a'))
173 os.makedirs(os.path.join(self.nbdir, 'subdir2/subdir2a'))
170 # print(self.ipydir.name)
174 # print(self.ipydir.name)
171 self.dirs.append(self.ipydir)
175 self.dirs.append(self.ipydir)
172 self.env['IPYTHONDIR'] = self.ipydir.name
176 self.env['IPYTHONDIR'] = self.ipydir.name
@@ -191,7 +195,7 b' class JSController(TestController):'
191 def _init_server(self):
195 def _init_server(self):
192 "Start the notebook server in a separate process"
196 "Start the notebook server in a separate process"
193 self.queue = q = Queue()
197 self.queue = q = Queue()
194 self.server = Process(target=run_webapp, args=(q, self.ipydir.name))
198 self.server = Process(target=run_webapp, args=(q, self.ipydir.name, self.nbdir))
195 self.server.start()
199 self.server.start()
196 self.server_port = q.get()
200 self.server_port = q.get()
197
201
@@ -202,17 +206,17 b' class JSController(TestController):'
202
206
203 js_test_group_names = {'js'}
207 js_test_group_names = {'js'}
204
208
205 def run_webapp(q, nbdir, loglevel=0):
209 def run_webapp(q, ipydir, nbdir, loglevel=0):
206 """start the IPython Notebook, and pass port back to the queue"""
210 """start the IPython Notebook, and pass port back to the queue"""
207 import os
211 import os
208 import IPython.html.notebookapp as nbapp
212 import IPython.html.notebookapp as nbapp
209 import sys
213 import sys
210 sys.stderr = open(os.devnull, 'w')
214 sys.stderr = open(os.devnull, 'w')
211 os.environ["IPYTHONDIR"] = nbdir
215 os.environ["IPYTHONDIR"] = ipydir
212 server = nbapp.NotebookApp()
216 server = nbapp.NotebookApp()
213 args = ['--no-browser']
217 args = ['--no-browser']
214 args.append('--notebook-dir='+nbdir)
218 args.append('--notebook-dir='+nbdir)
215 args.append('--profile-dir='+nbdir)
219 args.append('--profile-dir='+ipydir)
216 args.append('--log-level='+str(loglevel))
220 args.append('--log-level='+str(loglevel))
217 server.initialize(args)
221 server.initialize(args)
218 # communicate the port number to the parent process
222 # communicate the port number to the parent process
General Comments 0
You need to be logged in to leave comments. Login now