view tests/test_formatter.py @ 243:c6ec6096bd95

Simpler out-of-the-box support for background updates. Now by default Celery uses an SQLite broker, with storage in the `.wiki` directory. This makes it possible to support async updates by simply passing `--usetasks` to `wk runserver`, while also running `wk runtasks` in a different process.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 29 Mar 2014 22:28:07 -0700
parents 1ef50117ec58
children
line wrap: on
line source

import pytest
from wikked.formatter import PageFormatter, FormattingContext
from tests import format_link, format_include


@pytest.mark.parametrize('in_text, text, meta, links', [
    (
        "Something.\nThat's it.\n",
        "Something.\nThat's it.\n",
        None, None),
    (
        "Some meta.\n\n{{foo: Whatever man}}\n",
        "Some meta.\n\n",
        {'foo': ["Whatever man"]}, None),
    (
        "Some multi-meta.\n\n{{foo: First}}\n{{foo: Second}}\n",
        "Some multi-meta.\n\n\n",
        {'foo': ["First", "Second"]}, None),
    (
        "Multi-line meta:\n\n{{foo: This is a\n     multi-line meta\n}}\n",
        "Multi-line meta:\n\n",
        {'foo': ["This is a\n     multi-line meta"]}, None)
    ])
def test_formatter(in_text, text, meta, links):
    f = PageFormatter()
    ctx = FormattingContext('/foo')
    actual = f.formatText(ctx, in_text)
    assert actual == text
    if meta:
        assert ctx.meta == meta
    else:
        assert ctx.meta == {}
    if links:
        assert ctx.out_links == links
    else:
        assert ctx.out_links == []