##// END OF EJS Templates
tweak collapsed navbar style...
tweak collapsed navbar style - notification and indicators appear above menu on small screen - collapsed menu button floats left

File last commit:

r18244:f1ae99ef
r18414:c264a484
Show More
test_revealhelp.py
79 lines | 3.0 KiB | text/x-python | PythonLexer
MinRK
fix some validation bugs in v3...
r18244 """Tests for the revealhelp preprocessor"""
Jonathan Frederic
Added revealhelp transformer tests
r12032
MinRK
fix some validation bugs in v3...
r18244 # Copyright (c) IPython Development Team.
Jonathan Frederic
Added revealhelp transformer tests
r12032 # Distributed under the terms of the Modified BSD License.
from IPython.nbformat import current as nbformat
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 from .base import PreprocessorTestsBase
from ..revealhelp import RevealHelpPreprocessor
Jonathan Frederic
Added revealhelp transformer tests
r12032
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 class Testrevealhelp(PreprocessorTestsBase):
Jonathan Frederic
Added revealhelp transformer tests
r12032 """Contains test functions for revealhelp.py"""
def build_notebook(self):
damianavila
Fixed test and add fragments to the list of resets.
r16869 """Build a reveal slides notebook in memory for use with tests.
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 Overrides base in PreprocessorTestsBase"""
Jonathan Frederic
Added revealhelp transformer tests
r12032
outputs = [nbformat.new_output(output_type="stream", stream="stdout", output_text="a")]
damianavila
Fixed test and add fragments to the list of resets.
r16869
Jonathan Frederic
Added revealhelp transformer tests
r12032 slide_metadata = {'slideshow' : {'slide_type': 'slide'}}
subslide_metadata = {'slideshow' : {'slide_type': 'subslide'}}
cells=[nbformat.new_code_cell(input="", prompt_number=1, outputs=outputs),
nbformat.new_text_cell('markdown', source="", metadata=slide_metadata),
nbformat.new_code_cell(input="", prompt_number=2, outputs=outputs),
nbformat.new_text_cell('markdown', source="", metadata=slide_metadata),
nbformat.new_text_cell('markdown', source="", metadata=subslide_metadata)]
MinRK
fix some validation bugs in v3...
r18244 worksheets = [nbformat.new_worksheet(cells=cells)]
Jonathan Frederic
Added revealhelp transformer tests
r12032
return nbformat.new_notebook(name="notebook1", worksheets=worksheets)
Jonathan Frederic
Fixes small things pointed out by @minrk
r12035
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 def build_preprocessor(self):
"""Make an instance of a preprocessor"""
preprocessor = RevealHelpPreprocessor()
preprocessor.enabled = True
return preprocessor
Jonathan Frederic
Fixes small things pointed out by @minrk
r12035
def test_constructor(self):
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 """Can a RevealHelpPreprocessor be constructed?"""
self.build_preprocessor()
damianavila
Fixed test and add fragments to the list of resets.
r16869
Jonathan Frederic
Added revealhelp transformer tests
r12032
def test_reveal_attribute(self):
"""Make sure the reveal url_prefix resources is set"""
Jonathan Frederic
Expanded transformer pass line, for easier debugging
r12039 nb = self.build_notebook()
res = self.build_resources()
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 preprocessor = self.build_preprocessor()
nb, res = preprocessor(nb, res)
Jonathan Frederic
Added revealhelp transformer tests
r12032 assert 'reveal' in res
assert 'url_prefix' in res['reveal']
def test_reveal_output(self):
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 """Make sure that the reveal preprocessor """
Jonathan Frederic
Expanded transformer pass line, for easier debugging
r12039 nb = self.build_notebook()
res = self.build_resources()
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 preprocessor = self.build_preprocessor()
nb, res = preprocessor(nb, res)
Jonathan Frederic
Added revealhelp transformer tests
r12032 cells = nb.worksheets[0].cells
# Make sure correct metadata tags are available on every cell.
Jonathan Frederic
Fixes small things pointed out by @minrk
r12035 for cell in cells:
assert 'slide_type' in cell.metadata
Jonathan Frederic
Added revealhelp transformer tests
r12032
# Make sure slide end is only applied to the cells preceeding slide
# cells.
damianavila
Fixed test and add fragments to the list of resets.
r16869 assert 'slide_helper' in cells[1].metadata
self.assertEqual(cells[1].metadata['slide_helper'], '-')
Jonathan Frederic
Added revealhelp transformer tests
r12032
# Verify 'slide-end'
assert 'slide_helper' in cells[0].metadata
self.assertEqual(cells[0].metadata['slide_helper'], 'slide_end')
assert 'slide_helper' in cells[2].metadata
self.assertEqual(cells[2].metadata['slide_helper'], 'slide_end')
assert 'slide_helper' in cells[3].metadata
self.assertEqual(cells[3].metadata['slide_helper'], 'subslide_end')