Beispiel #1
0
def test_package_template_dir(monkeypatch, doc):
    renderer = Mock()
    resource = PackageTemplateDir(renderers='html',
                                  path=Path('mypkg') / 'templates')
    resource.alter(document=doc,
                   rendererName='html',
                   renderer=renderer,
                   target=Path('buildir'))
    renderer.importDirectory.assert_called_with(
        str(Path('mypkg') / 'templates'))
Beispiel #2
0
def test_package_template_dir_user_dir(monkeypatch, doc):
    renderer = Mock()
    resource = PackageTemplateDir(renderers='html', package='mypkg')
    monkeypatch.setattr('os.path.isdir', lambda x: True)
    monkeypatch.setattr('plasTeX.PackageResource.rendererDir',
                        lambda x: 'html')

    resource.alter(document=doc,
                   rendererName='html',
                   renderer=renderer,
                   target='buildir')
    renderer.importDirectory.assert_called_with('mypkg' + os.sep)
Beispiel #3
0
def test_package_template_dir_missing(monkeypatch, doc):
    renderer = Mock()
    resource = PackageTemplateDir(renderers='html', package='mypkg')
    monkeypatch.setattr('os.path.isdir', lambda x: False)
    monkeypatch.setattr('plasTeX.PackageResource.rendererDir',
                        lambda x: 'html')
    mock_logger = Mock()
    monkeypatch.setattr('plasTeX.PackageResource.log.error', mock_logger)

    resource.alter(document=doc,
                   rendererName='html',
                   renderer=renderer,
                   target='buildir')

    assert mock_logger.call_count == 1