Skip to content

Commit

Permalink
Test against comments_path option
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Mar 29, 2022
1 parent d91b143 commit dc5be82
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 4 deletions.
23 changes: 23 additions & 0 deletions tests/fixtures/mkdocs_item_comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Project information
site_name: MkDocs RSS Plugin - TEST
site_description: Basic setup to test against MkDocs RSS plugin
site_author: Julien Moura (Guts)
site_url: https://guts.github.io/mkdocs-rss-plugin
copyright: 'Guts - In Geo Veritas'

# Repository
repo_name: 'guts/mkdocs-rss-plugin'
repo_url: 'https://github.com/guts/mkdocs-rss-plugin'

use_directory_urls: true

plugins:
- rss:
comments_path: "#__comments"

theme:
name: readthedocs

# Extensions to enhance markdown
markdown_extensions:
- meta
22 changes: 22 additions & 0 deletions tests/fixtures/mkdocs_item_no_comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Project information
site_name: MkDocs RSS Plugin - TEST
site_description: Basic setup to test against MkDocs RSS plugin
site_author: Julien Moura (Guts)
site_url: https://guts.github.io/mkdocs-rss-plugin
copyright: 'Guts - In Geo Veritas'

# Repository
repo_name: 'guts/mkdocs-rss-plugin'
repo_url: 'https://github.com/guts/mkdocs-rss-plugin'

use_directory_urls: true

plugins:
- rss

theme:
name: readthedocs

# Extensions to enhance markdown
markdown_extensions:
- meta
51 changes: 47 additions & 4 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,50 @@ def test_simple_build_feed_length(self):

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

def test_simple_build_item_comments_enabled(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cli_result = self.build_docs_setup(
testproject_path="docs",
mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_item_comments.yml"),
output_path=tmpdirname,
strict=True,
)
if cli_result.exception is not None:
e = cli_result.exception
logger.debug(format_exception(type(e), e, e.__traceback__))

self.assertEqual(cli_result.exit_code, 0)
self.assertIsNone(cli_result.exception)

# created items
feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml")
self.assertEqual(feed_parsed.bozo, 0)

for feed_item in feed_parsed.entries:
self.assertTrue("comments" in feed_item)

def test_simple_build_item_comments_disabled(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cli_result = self.build_docs_setup(
testproject_path="docs",
mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_item_no_comments.yml"),
output_path=tmpdirname,
strict=True,
)
if cli_result.exception is not None:
e = cli_result.exception
logger.debug(format_exception(type(e), e, e.__traceback__))

self.assertEqual(cli_result.exit_code, 0)
self.assertIsNone(cli_result.exception)

# created items
feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml")
self.assertEqual(feed_parsed.bozo, 0)

for feed_item in feed_parsed.entries:
self.assertTrue("comments" not in feed_item)

def test_simple_build_item_length_unlimited(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cli_result = self.build_docs_setup(
Expand All @@ -137,10 +181,9 @@ def test_simple_build_item_length_unlimited(self):
feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml")
self.assertEqual(feed_parsed.bozo, 0)

for item in feed_parsed.entries:
print(item.title, len(item.description))
if item.title not in ("Page without meta with short text",):
self.assertGreaterEqual(len(item.description), 150)
for feed_item in feed_parsed.entries:
if feed_item.title not in ("Page without meta with short text",):
self.assertGreaterEqual(len(feed_item.description), 150)

def test_rss_feed_validation(self):
with tempfile.TemporaryDirectory() as tmpdirname:
Expand Down

0 comments on commit dc5be82

Please sign in to comment.