Mercurial > wikked
annotate tests/test_formatter.py @ 383:c19b8cc11938
docs: Add information about the `ignore` section, and more wiki options.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 04 Oct 2015 08:14:20 -0700 |
parents | 1ef50117ec58 |
children |
rev | line source |
---|---|
228
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import pytest |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 from wikked.formatter import PageFormatter, FormattingContext |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 from tests import format_link, format_include |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 @pytest.mark.parametrize('in_text, text, meta, links', [ |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 ( |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 "Something.\nThat's it.\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 "Something.\nThat's it.\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 None, None), |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 ( |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 "Some meta.\n\n{{foo: Whatever man}}\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 "Some meta.\n\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 {'foo': ["Whatever man"]}, None), |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 ( |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 "Some multi-meta.\n\n{{foo: First}}\n{{foo: Second}}\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 "Some multi-meta.\n\n\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 {'foo': ["First", "Second"]}, None), |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 ( |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 "Multi-line meta:\n\n{{foo: This is a\n multi-line meta\n}}\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 "Multi-line meta:\n\n", |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 {'foo': ["This is a\n multi-line meta"]}, None) |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 ]) |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 def test_formatter(in_text, text, meta, links): |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 f = PageFormatter() |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 ctx = FormattingContext('/foo') |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 actual = f.formatText(ctx, in_text) |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 assert actual == text |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 if meta: |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 assert ctx.meta == meta |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
31 else: |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 assert ctx.meta == {} |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 if links: |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
34 assert ctx.out_links == links |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 else: |
1ef50117ec58
Added test for the `PageFormatter`.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 assert ctx.out_links == [] |