##// END OF EJS Templates
Adds configuration options to use Google Drive content manager...
Adds configuration options to use Google Drive content manager Adds the key contentmanager_js_source to webapp_settings that allows for specifying the content manager JavaScript source file. Also adds a NotebookManager subclass, ClientSideNotebookManager, which does minimal logic. This class is used when the JavaScript content manager doesn't use the Python notebook manager, but rather implements that logic client side, as is the case for the Google Drive based content manager. A sample command line that uses the Google Drive content manager, and the ClientSideNotebookManager, is ipython notebook --NotebookApp.webapp_settings="{'contentmanager_js_source': 'base/js/drive_contentmanager'}" --NotebookApp.notebook_manager_class="IPython.html.services.notebooks.clientsidenbmanager.ClientSideNotebookManager"

File last commit:

r12521:eec42358
r18639:28c27a69
Show More
test_templateexporter.py
108 lines | 3.8 KiB | text/x-python | PythonLexer
"""
Module with tests for templateexporter.py
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from IPython.config import Config
from .base import ExportersTestsBase
from .cheese import CheesePreprocessor
from ..templateexporter import TemplateExporter
#-----------------------------------------------------------------------------
# Class
#-----------------------------------------------------------------------------
class TestExporter(ExportersTestsBase):
"""Contains test functions for exporter.py"""
def test_constructor(self):
"""
Can a TemplateExporter be constructed?
"""
TemplateExporter()
def test_export(self):
"""
Can a TemplateExporter export something?
"""
exporter = self._make_exporter()
(output, resources) = exporter.from_filename(self._get_notebook())
assert len(output) > 0
def test_extract_outputs(self):
"""
If the ExtractOutputPreprocessor is enabled, are outputs extracted?
"""
config = Config({'ExtractOutputPreprocessor': {'enabled': True}})
exporter = self._make_exporter(config=config)
(output, resources) = exporter.from_filename(self._get_notebook())
assert resources is not None
assert isinstance(resources['outputs'], dict)
assert len(resources['outputs']) > 0
def test_preprocessor_class(self):
"""
Can a preprocessor be added to the preprocessors list by class type?
"""
config = Config({'Exporter': {'preprocessors': [CheesePreprocessor]}})
exporter = self._make_exporter(config=config)
(output, resources) = exporter.from_filename(self._get_notebook())
assert resources is not None
assert resources['cheese'] == 'real'
def test_preprocessor_instance(self):
"""
Can a preprocessor be added to the preprocessors list by instance?
"""
config = Config({'Exporter': {'preprocessors': [CheesePreprocessor()]}})
exporter = self._make_exporter(config=config)
(output, resources) = exporter.from_filename(self._get_notebook())
assert resources is not None
assert resources['cheese'] == 'real'
def test_preprocessor_dottedobjectname(self):
"""
Can a preprocessor be added to the preprocessors list by dotted object name?
"""
config = Config({'Exporter': {'preprocessors': ['IPython.nbconvert.exporters.tests.cheese.CheesePreprocessor']}})
exporter = self._make_exporter(config=config)
(output, resources) = exporter.from_filename(self._get_notebook())
assert resources is not None
assert resources['cheese'] == 'real'
def test_preprocessor_via_method(self):
"""
Can a preprocessor be added via the Exporter convenience method?
"""
exporter = self._make_exporter()
exporter.register_preprocessor(CheesePreprocessor, enabled=True)
(output, resources) = exporter.from_filename(self._get_notebook())
assert resources is not None
assert resources['cheese'] == 'real'
def _make_exporter(self, config=None):
# Create the exporter instance, make sure to set a template name since
# the base TemplateExporter doesn't have a template associated with it.
exporter = TemplateExporter(config=config, template_file='python')
return exporter