Beispiel #1
0
def test_render_multiple_pages(renderer, mock_write):
    renderer.output = 'folder'
    mock_open, handle = mock_write

    with renderer:
        renderer.add_page(
            rst.RenderedPage(
                filename='foo.rst',
                content='Hello, World',
                title='foo',
            ))
        renderer.add_page(
            rst.RenderedPage(
                filename='bar.rst',
                content='Goodbye, World',
                title='bar',
            ))

    assert mock_open.call_args_list == [
        call('folder/index.rst', 'w'),
        call('folder/foo.rst', 'w'),
        call('folder/bar.rst', 'w'),
    ]

    assert handle.write.call_args_list == [
        call('Services\n========\n\n.. toctree::\n    :maxdepth: 3\n\n'
             '    bar\n    foo'),
        call('Hello, World'),
        call('Goodbye, World'),
    ]
Beispiel #2
0
def test_render_page():
    res = rst.render_page(
        name='foo',
        parts=[
            rst.render_title('Three', level=3),
            rst.render_include_method(path='foo.BarClass.baz')
        ])
    expected_content_lines = [
        'Three',
        '~~~~~',
        '',
        '.. automethod:: foo.BarClass.baz',
        '    ',
        '',
    ]
    expected_content = '\n'.join(expected_content_lines)

    expected = rst.RenderedPage(filename='foo.rst',
                                content=expected_content,
                                title='foo')

    assert res == expected