From 0a67ba69fd3695a49dadf1e4e50fb50e4d7c77a1 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Mon, 2 Dec 2024 12:11:48 +0100 Subject: [PATCH] improve(material_integrations): add minimal test against material blog integration --- .../mkdocs_items_material_blog_enabled.yml | 11 ++++ tests/test_integrations_material_blog.py | 60 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/fixtures/mkdocs_items_material_blog_enabled.yml create mode 100644 tests/test_integrations_material_blog.py diff --git a/tests/fixtures/mkdocs_items_material_blog_enabled.yml b/tests/fixtures/mkdocs_items_material_blog_enabled.yml new file mode 100644 index 0000000..d637ea6 --- /dev/null +++ b/tests/fixtures/mkdocs_items_material_blog_enabled.yml @@ -0,0 +1,11 @@ +site_name: Test RSS Plugin +site_description: Test RSS with blog plugin also enabled +site_url: https://guts.github.io/mkdocs-rss-plugin + +plugins: + - blog: + blog_dir: blog + - rss + +theme: + name: material diff --git a/tests/test_integrations_material_blog.py b/tests/test_integrations_material_blog.py new file mode 100644 index 0000000..3255777 --- /dev/null +++ b/tests/test_integrations_material_blog.py @@ -0,0 +1,60 @@ +#! python3 # noqa E265 + +"""Usage from the repo root folder: + +.. code-block:: python + + # for whole test + python -m unittest tests.test_build + +""" + +# ############################################################################# +# ########## Libraries ############# +# ################################## + +# Standard library +import unittest +from logging import DEBUG, getLogger +from pathlib import Path + +# 3rd party +from mkdocs.config import load_config + +# package +from mkdocs_rss_plugin.integrations.theme_material_blog_plugin import ( + IntegrationMaterialBlog, +) + +# test suite +from tests.base import BaseTest + +# ############################################################################# +# ########## Classes ############### +# ################################## + +logger = getLogger(__name__) +logger.setLevel(DEBUG) + + +class TestRssPluginIntegrationsMaterialBlog(BaseTest): + """Test integration of Material Blog plugin with RSS plugin.""" + + # -- TESTS --------------------------------------------------------- + def test_plugin_config_blog_enabled(self): + # default reference + cfg_mkdocs = load_config( + str(Path("tests/fixtures/mkdocs_items_material_blog_enabled.yml").resolve()) + ) + + integration_social_cards = IntegrationMaterialBlog(mkdocs_config=cfg_mkdocs) + self.assertTrue(integration_social_cards.IS_THEME_MATERIAL) + self.assertTrue(integration_social_cards.IS_BLOG_PLUGIN_ENABLED) + self.assertTrue(integration_social_cards.IS_ENABLED) + + +# ############################################################################## +# ##### Stand alone program ######## +# ################################## +if __name__ == "__main__": + unittest.main()