|
| 1 | +import pytest |
| 2 | + |
| 3 | +from render_engine_parser.base_parsers import BasePageParser, parse_content |
| 4 | + |
| 5 | + |
| 6 | +@pytest.fixture() |
| 7 | +def base_content() -> str: |
| 8 | + return """ |
| 9 | +--- |
| 10 | +title: This is a Test |
| 11 | +--- |
| 12 | +
|
| 13 | +# This is a Test""" |
| 14 | + |
| 15 | + |
| 16 | +@pytest.fixture() |
| 17 | +def base_content_path(tmp_path, base_content): |
| 18 | + """Returns the path to a test file""" |
| 19 | + d = tmp_path / "test_page.md" |
| 20 | + d.write_text(base_content) |
| 21 | + return d |
| 22 | + |
| 23 | + |
| 24 | +def test_parse_content(base_content): |
| 25 | + """ |
| 26 | + Tests that parse_content returns a split of the content and attributes |
| 27 | + Currently python-frontmatter is used to do this. This test is here to |
| 28 | + ensure that the API is consistent. |
| 29 | +
|
| 30 | + Base Content is an example of a markdown file with frontmatter. |
| 31 | + """ |
| 32 | + |
| 33 | + expected_result = ({"title": "This is a Test"}, "# This is a Test") |
| 34 | + assert expected_result == parse_content(base_content) |
| 35 | + |
| 36 | + |
| 37 | +def test_base_parser_parse_content(base_content): |
| 38 | + """ |
| 39 | + Tests for the BasePageParser pase_content Functionality. |
| 40 | + This assures that the API is consistently calling the parse_content |
| 41 | + """ |
| 42 | + |
| 43 | + expected_result = ({"title": "This is a Test"}, "# This is a Test") |
| 44 | + assert expected_result == BasePageParser.parse_content(base_content) |
| 45 | + |
| 46 | + |
| 47 | +def test_base_parser_parse_content_path(base_content_path): |
| 48 | + """ |
| 49 | + Tests for the BasePageParser parse_content_path Functionality. |
| 50 | + This assures that the API is consistently calling the parse_content |
| 51 | + """ |
| 52 | + |
| 53 | + expected_result = ({"title": "This is a Test"}, "# This is a Test") |
| 54 | + assert expected_result == BasePageParser.parse_content_path(base_content_path) |
0 commit comments