Skip to content

Commit bd9feb3

Browse files
authored
Merge pull request #2 from render-engine/add-tests
Adds tests from render-engine
2 parents 0708d5d + 40468d7 commit bd9feb3

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,4 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
.vscode/settings.json

tests/test_base_parser.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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

Comments
 (0)