Skip to content

Commit dc5be82

Browse files
committed
Test against comments_path option
1 parent d91b143 commit dc5be82

3 files changed

Lines changed: 92 additions & 4 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Project information
2+
site_name: MkDocs RSS Plugin - TEST
3+
site_description: Basic setup to test against MkDocs RSS plugin
4+
site_author: Julien Moura (Guts)
5+
site_url: https://guts.github.io/mkdocs-rss-plugin
6+
copyright: 'Guts - In Geo Veritas'
7+
8+
# Repository
9+
repo_name: 'guts/mkdocs-rss-plugin'
10+
repo_url: 'https://github.com/guts/mkdocs-rss-plugin'
11+
12+
use_directory_urls: true
13+
14+
plugins:
15+
- rss:
16+
comments_path: "#__comments"
17+
18+
theme:
19+
name: readthedocs
20+
21+
# Extensions to enhance markdown
22+
markdown_extensions:
23+
- meta
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Project information
2+
site_name: MkDocs RSS Plugin - TEST
3+
site_description: Basic setup to test against MkDocs RSS plugin
4+
site_author: Julien Moura (Guts)
5+
site_url: https://guts.github.io/mkdocs-rss-plugin
6+
copyright: 'Guts - In Geo Veritas'
7+
8+
# Repository
9+
repo_name: 'guts/mkdocs-rss-plugin'
10+
repo_url: 'https://github.com/guts/mkdocs-rss-plugin'
11+
12+
use_directory_urls: true
13+
14+
plugins:
15+
- rss
16+
17+
theme:
18+
name: readthedocs
19+
20+
# Extensions to enhance markdown
21+
markdown_extensions:
22+
- meta

tests/test_build.py

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,50 @@ def test_simple_build_feed_length(self):
116116

117117
self.assertEqual(len(feed_parsed.entries), 3)
118118

119+
def test_simple_build_item_comments_enabled(self):
120+
with tempfile.TemporaryDirectory() as tmpdirname:
121+
cli_result = self.build_docs_setup(
122+
testproject_path="docs",
123+
mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_item_comments.yml"),
124+
output_path=tmpdirname,
125+
strict=True,
126+
)
127+
if cli_result.exception is not None:
128+
e = cli_result.exception
129+
logger.debug(format_exception(type(e), e, e.__traceback__))
130+
131+
self.assertEqual(cli_result.exit_code, 0)
132+
self.assertIsNone(cli_result.exception)
133+
134+
# created items
135+
feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml")
136+
self.assertEqual(feed_parsed.bozo, 0)
137+
138+
for feed_item in feed_parsed.entries:
139+
self.assertTrue("comments" in feed_item)
140+
141+
def test_simple_build_item_comments_disabled(self):
142+
with tempfile.TemporaryDirectory() as tmpdirname:
143+
cli_result = self.build_docs_setup(
144+
testproject_path="docs",
145+
mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_item_no_comments.yml"),
146+
output_path=tmpdirname,
147+
strict=True,
148+
)
149+
if cli_result.exception is not None:
150+
e = cli_result.exception
151+
logger.debug(format_exception(type(e), e, e.__traceback__))
152+
153+
self.assertEqual(cli_result.exit_code, 0)
154+
self.assertIsNone(cli_result.exception)
155+
156+
# created items
157+
feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml")
158+
self.assertEqual(feed_parsed.bozo, 0)
159+
160+
for feed_item in feed_parsed.entries:
161+
self.assertTrue("comments" not in feed_item)
162+
119163
def test_simple_build_item_length_unlimited(self):
120164
with tempfile.TemporaryDirectory() as tmpdirname:
121165
cli_result = self.build_docs_setup(
@@ -137,10 +181,9 @@ def test_simple_build_item_length_unlimited(self):
137181
feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml")
138182
self.assertEqual(feed_parsed.bozo, 0)
139183

140-
for item in feed_parsed.entries:
141-
print(item.title, len(item.description))
142-
if item.title not in ("Page without meta with short text",):
143-
self.assertGreaterEqual(len(item.description), 150)
184+
for feed_item in feed_parsed.entries:
185+
if feed_item.title not in ("Page without meta with short text",):
186+
self.assertGreaterEqual(len(feed_item.description), 150)
144187

145188
def test_rss_feed_validation(self):
146189
with tempfile.TemporaryDirectory() as tmpdirname:

0 commit comments

Comments
 (0)