Mercurial > wikked
comparison tests/test_formatter.py @ 228:1ef50117ec58
Added test for the `PageFormatter`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 13 Mar 2014 21:46:14 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
227:6457416ac7d7 | 228:1ef50117ec58 |
---|---|
1 import pytest | |
2 from wikked.formatter import PageFormatter, FormattingContext | |
3 from tests import format_link, format_include | |
4 | |
5 | |
6 @pytest.mark.parametrize('in_text, text, meta, links', [ | |
7 ( | |
8 "Something.\nThat's it.\n", | |
9 "Something.\nThat's it.\n", | |
10 None, None), | |
11 ( | |
12 "Some meta.\n\n{{foo: Whatever man}}\n", | |
13 "Some meta.\n\n", | |
14 {'foo': ["Whatever man"]}, None), | |
15 ( | |
16 "Some multi-meta.\n\n{{foo: First}}\n{{foo: Second}}\n", | |
17 "Some multi-meta.\n\n\n", | |
18 {'foo': ["First", "Second"]}, None), | |
19 ( | |
20 "Multi-line meta:\n\n{{foo: This is a\n multi-line meta\n}}\n", | |
21 "Multi-line meta:\n\n", | |
22 {'foo': ["This is a\n multi-line meta"]}, None) | |
23 ]) | |
24 def test_formatter(in_text, text, meta, links): | |
25 f = PageFormatter() | |
26 ctx = FormattingContext('/foo') | |
27 actual = f.formatText(ctx, in_text) | |
28 assert actual == text | |
29 if meta: | |
30 assert ctx.meta == meta | |
31 else: | |
32 assert ctx.meta == {} | |
33 if links: | |
34 assert ctx.out_links == links | |
35 else: | |
36 assert ctx.out_links == [] |