# HG changeset patch # User Ludovic Chabant # Date 1394772374 25200 # Node ID 1ef50117ec58ad8052778a44f560939088bf1e25 # Parent 6457416ac7d7c72cfd4360ae67259e2fecacb110 Added test for the `PageFormatter`. diff -r 6457416ac7d7 -r 1ef50117ec58 tests/test_formatter.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_formatter.py Thu Mar 13 21:46:14 2014 -0700 @@ -0,0 +1,36 @@ +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 == []