##// END OF EJS Templates
allow name as kwarg to new_notebook...
MinRK -
Show More
@@ -146,7 +146,7 b' def new_worksheet(name=None, cells=None):'
146 return ws
146 return ws
147
147
148
148
149 def new_notebook(metadata=None, worksheets=None):
149 def new_notebook(name=None, metadata=None, worksheets=None):
150 """Create a notebook by name, id and a list of worksheets."""
150 """Create a notebook by name, id and a list of worksheets."""
151 nb = NotebookNode()
151 nb = NotebookNode()
152 nb.nbformat = nbformat
152 nb.nbformat = nbformat
@@ -158,6 +158,8 b' def new_notebook(metadata=None, worksheets=None):'
158 nb.metadata = new_metadata()
158 nb.metadata = new_metadata()
159 else:
159 else:
160 nb.metadata = NotebookNode(metadata)
160 nb.metadata = NotebookNode(metadata)
161 if name is not None:
162 nb.metadata.name = unicode(name)
161 return nb
163 return nb
162
164
163
165
@@ -112,6 +112,13 b' class TestNotebook(TestCase):'
112 self.assertEquals(nb.worksheets,worksheets)
112 self.assertEquals(nb.worksheets,worksheets)
113 self.assertEquals(nb.nbformat,nbformat)
113 self.assertEquals(nb.nbformat,nbformat)
114
114
115 def test_notebook_name(self):
116 worksheets = [new_worksheet(),new_worksheet()]
117 nb = new_notebook(name='foo',worksheets=worksheets)
118 self.assertEquals(nb.metadata.name,u'foo')
119 self.assertEquals(nb.worksheets,worksheets)
120 self.assertEquals(nb.nbformat,nbformat)
121
115 class TestMetadata(TestCase):
122 class TestMetadata(TestCase):
116
123
117 def test_empty_metadata(self):
124 def test_empty_metadata(self):
General Comments 0
You need to be logged in to leave comments. Login now