Skip to content

Commit

Permalink
tests: add test cases for abstract_delimiter
Browse files Browse the repository at this point in the history
One thing not entirely obvious from the changes is that
tests/fixtures/docs/page_without_meta_early_delimiter.md
together with test_simple_build_item_length_unlimited() checks the
priority of abstract_chars_count: -1 versus abstract_delimiter.
  • Loading branch information
tiosgz authored and Guts committed Apr 22, 2024
1 parent 885c564 commit e78ec88
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
5 changes: 5 additions & 0 deletions tests/fixtures/docs/page_without_meta_early_delimiter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Page without meta with early delimiter

<!-- more -->

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
23 changes: 23 additions & 0 deletions tests/fixtures/mkdocs_item_delimiter_empty.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:
abstract_delimiter: ""

theme:
name: readthedocs

# Extensions to enhance markdown
markdown_extensions:
- meta
52 changes: 49 additions & 3 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,55 @@ def test_simple_build_item_length_unlimited(self):
"Page without meta with short text",
"Blog sample",
):
self.assertGreaterEqual(
len(feed_item.description), 150, feed_item.title
)
self.assertGreater(len(feed_item.description), 150, feed_item.title)

def test_simple_build_item_delimiter(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cli_result = self.build_docs_setup(
testproject_path="docs",
mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_minimal.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) / OUTPUT_RSS_FEED_CREATED)
self.assertEqual(feed_parsed.bozo, 0)

for feed_item in feed_parsed.entries:
if feed_item.title in ("Page without meta with early delimiter",):
self.assertLess(len(feed_item.description), 50, feed_item.title)

def test_simple_build_item_delimiter_empty(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cli_result = self.build_docs_setup(
testproject_path="docs",
mkdocs_yml_filepath=Path(
"tests/fixtures/mkdocs_item_delimiter_empty.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) / OUTPUT_RSS_FEED_CREATED)
self.assertEqual(feed_parsed.bozo, 0)

for feed_item in feed_parsed.entries:
if feed_item.title in ("Page without meta with early delimiter",):
self.assertGreater(len(feed_item.description), 150, feed_item.title)

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

0 comments on commit e78ec88

Please sign in to comment.