Exemplo n.º 1
0
def test_sphinx_config_default(tmpdir):
    app = create_sphinx_app(tmpdir)
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert not template_cfg.keys()
    assert template_cfg.variables.keys() == set(['paper_size'])
    assert template_cfg.get_variable('paper_size', None) == LETTER
Exemplo n.º 2
0
def test_sphinx_config_default(tmpdir):
    app = create_sphinx_app(tmpdir)
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert not template_cfg.keys()
    assert template_cfg.variables.keys() == set(['paper_size'])
    assert template_cfg.get_variable('paper_size', None) == LETTER
Exemplo n.º 3
0
def test_sphinx_config_rinoh_template(tmpdir):
    template_cfg = Article.Configuration('test',
                                         stylesheet='sphinx_article')
    app = create_sphinx_app(tmpdir, rinoh_template=template_cfg)
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Article
    assert template_cfg['stylesheet'].name == 'Sphinx (article)'
Exemplo n.º 4
0
def test_sphinx_config_latex_elements_papersize(tmpdir):
    app = create_sphinx_app(tmpdir, latex_elements=dict(papersize='a4paper'))
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert not template_cfg.keys()
    assert template_cfg.variables.keys() == set(['paper_size'])
    assert template_cfg.get_variable('paper_size', None) == A4
Exemplo n.º 5
0
def test_sphinx_config_rinoh_template(tmpdir):
    template_cfg = Article.Configuration('test',
                                         stylesheet='sphinx_article')
    app = create_sphinx_app(tmpdir, rinoh_template=template_cfg)
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Article
    assert template_cfg['stylesheet'].name == 'Sphinx (article)'
Exemplo n.º 6
0
def test_sphinx_config_latex_elements_papersize(tmpdir):
    app = create_sphinx_app(tmpdir, latex_elements=dict(papersize='a4paper'))
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert not template_cfg.keys()
    assert template_cfg.variables.keys() == set(['paper_size'])
    assert template_cfg.get_variable('paper_size', None) == A4
Exemplo n.º 7
0
def test_sphinx_config_rinoh_paper_size(tmpdir):
    app = create_sphinx_app(tmpdir, rinoh_paper_size=A4,
                            latex_paper_size='letter')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert not template_cfg.keys()
    assert template_cfg.variables.keys() == set(['paper_size'])
    assert template_cfg.get_variable('paper_size', None) == A4
Exemplo n.º 8
0
def test_sphinx_set_document_metadata_subtitle(tmpdir):
    expected_subtitle = 'A subtitle'
    app = create_sphinx_app(tmpdir, rinoh_metadata={'subtitle': expected_subtitle})
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    docutil_tree = create_document()
    rinoh_tree = DocumentTree([])
    rinoh_doc = template_cfg.document(rinoh_tree)
    set_document_metadata(rinoh_doc, app.config, docutil_tree)
    assert expected_subtitle == rinoh_doc.metadata['subtitle']
Exemplo n.º 9
0
def test_sphinx_config_rinoh_template_from_filename(tmpdir):
    template_cfg_path = tmpdir.join('template_cfg.rtt').strpath
    with open(template_cfg_path, 'w') as template_cfg:
        print('[TEMPLATE_CONFIGURATION]', file=template_cfg)
        print('template = book', file=template_cfg)
    app = create_sphinx_app(tmpdir, rinoh_template=template_cfg_path)
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert not template_cfg.keys()
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].name == 'Sphinx'
Exemplo n.º 10
0
def test_sphinx_config_rinoh_template_from_filename(tmpdir):
    template_cfg_path = tmpdir.join('template_cfg.rtt').strpath
    with open(template_cfg_path, 'w') as template_cfg:
        print('[TEMPLATE_CONFIGURATION]', file=template_cfg)
        print('template = book', file=template_cfg)
    app = create_sphinx_app(tmpdir, rinoh_template=template_cfg_path)
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert not template_cfg.keys()
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].name == 'Sphinx'
Exemplo n.º 11
0
def test_sphinx_set_document_metadata(tmpdir):
    app = create_sphinx_app(tmpdir, release='1.0', rinoh_template='book')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    docutils_tree = create_document()
    rinoh_tree = DocumentTree([])
    rinoh_doc = template_cfg.document(rinoh_tree)
    set_document_metadata(rinoh_doc, app.config, docutils_tree)
    assert rinoh_doc.metadata['title'] == 'A Title'
    assert rinoh_doc.metadata['subtitle'] == 'Release 1.0'
    assert rinoh_doc.metadata['author'] == 'Ann Other'
    assert 'date' in rinoh_doc.metadata
Exemplo n.º 12
0
def test_sphinx_config_rinoh_template_from_entrypoint(tmpdir):
    app = create_sphinx_app(tmpdir, rinoh_template='book')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert not template_cfg.keys()
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].name == 'Sphinx'
Exemplo n.º 13
0
def test_sphinx_config_pygments_style(tmpdir):
    app = create_sphinx_app(tmpdir, pygments_style='igor')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].base is not None
Exemplo n.º 14
0
def test_sphinx_config_builtin_stylesheet(tmpdir):
    app = create_sphinx_app(tmpdir, rinoh_stylesheet='sphinx_base14')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].name == 'Sphinx (PDF Core Fonts)'
Exemplo n.º 15
0
def test_sphinx_config_language(tmpdir):
    app = create_sphinx_app(tmpdir, language='it')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert template_cfg['language'] == IT
Exemplo n.º 16
0
def test_sphinx_config_builtin_stylesheet(tmpdir):
    app = create_sphinx_app(tmpdir, rinoh_stylesheet='sphinx_base14')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].name == 'Sphinx (PDF Core Fonts)'
Exemplo n.º 17
0
def test_sphinx_config_rinoh_template_from_entrypoint(tmpdir):
    app = create_sphinx_app(tmpdir, rinoh_template='book')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert not template_cfg.keys()
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].name == 'Sphinx'
Exemplo n.º 18
0
def test_sphinx_config_pygments_style(tmpdir):
    app = create_sphinx_app(tmpdir, pygments_style='igor')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert template_cfg['stylesheet'].base is not None
Exemplo n.º 19
0
def get_template_cfg(tmpdir, **confoverrides):
    with docutils_namespace():
        app = create_sphinx_app(tmpdir, **confoverrides)
        template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    return template_cfg
Exemplo n.º 20
0
def test_sphinx_config_language(tmpdir):
    app = create_sphinx_app(tmpdir, language='it')
    template_cfg = template_from_config(app.config, CONFIG_DIR, print)
    assert template_cfg.template == Book
    assert template_cfg['language'] == IT