1414# ##################################
1515
1616# Standard library
17+ import tempfile
1718import unittest
1819from logging import DEBUG , getLogger
1920from pathlib import Path
21+ from traceback import format_exception
2022
2123# 3rd party
24+ import feedparser
2225from mkdocs .config import load_config
2326
2427# package
@@ -41,6 +44,24 @@ class TestRssPluginIntegrationsMaterialBlog(BaseTest):
4144 """Test integration of Material Blog plugin with RSS plugin."""
4245
4346 # -- TESTS ---------------------------------------------------------
47+ def test_plugin_config_social_cards_enabled_but_integration_disabled (self ):
48+ # default reference
49+ cfg_mkdocs = load_config (
50+ str (
51+ Path (
52+ "tests/fixtures/mkdocs_items_material_blog_enabled_but_integration_disabled.yml"
53+ ).resolve ()
54+ )
55+ )
56+
57+ integration_social_cards = IntegrationMaterialBlog (
58+ mkdocs_config = cfg_mkdocs ,
59+ switch_force = cfg_mkdocs .plugins .get ("rss" ).config .use_material_blog ,
60+ )
61+ self .assertTrue (integration_social_cards .IS_THEME_MATERIAL )
62+ self .assertTrue (integration_social_cards .IS_BLOG_PLUGIN_ENABLED )
63+ self .assertFalse (integration_social_cards .IS_ENABLED )
64+
4465 def test_plugin_config_blog_enabled (self ):
4566 # default reference
4667 cfg_mkdocs = load_config (
@@ -52,6 +73,57 @@ def test_plugin_config_blog_enabled(self):
5273 self .assertTrue (integration_social_cards .IS_BLOG_PLUGIN_ENABLED )
5374 self .assertTrue (integration_social_cards .IS_ENABLED )
5475
76+ def test_simple_build (self ):
77+ with tempfile .TemporaryDirectory () as tmpdirname :
78+ cli_result = self .build_docs_setup (
79+ testproject_path = "docs" ,
80+ mkdocs_yml_filepath = Path (
81+ "tests/fixtures/mkdocs_items_material_blog_enabled.yml"
82+ ),
83+ output_path = tmpdirname ,
84+ strict = False ,
85+ )
86+
87+ if cli_result .exception is not None :
88+ e = cli_result .exception
89+ logger .debug (format_exception (type (e ), e , e .__traceback__ ))
90+
91+ self .assertEqual (cli_result .exit_code , 0 )
92+ self .assertIsNone (cli_result .exception )
93+
94+ # created items
95+ feed_parsed = feedparser .parse (Path (tmpdirname ) / "feed_rss_created.xml" )
96+ self .assertEqual (feed_parsed .bozo , 0 )
97+
98+ # updated items
99+ feed_parsed = feedparser .parse (Path (tmpdirname ) / "feed_rss_updated.xml" )
100+ self .assertEqual (feed_parsed .bozo , 0 )
101+
102+ with tempfile .TemporaryDirectory () as tmpdirname :
103+ cli_result = self .build_docs_setup (
104+ testproject_path = "docs" ,
105+ mkdocs_yml_filepath = Path (
106+ "tests/fixtures/mkdocs_items_material_blog_enabled_but_integration_disabled.yml"
107+ ),
108+ output_path = tmpdirname ,
109+ strict = False ,
110+ )
111+
112+ if cli_result .exception is not None :
113+ e = cli_result .exception
114+ logger .debug (format_exception (type (e ), e , e .__traceback__ ))
115+
116+ self .assertEqual (cli_result .exit_code , 0 )
117+ self .assertIsNone (cli_result .exception )
118+
119+ # created items
120+ feed_parsed = feedparser .parse (Path (tmpdirname ) / "feed_rss_created.xml" )
121+ self .assertEqual (feed_parsed .bozo , 0 )
122+
123+ # updated items
124+ feed_parsed = feedparser .parse (Path (tmpdirname ) / "feed_rss_updated.xml" )
125+ self .assertEqual (feed_parsed .bozo , 0 )
126+
55127
56128# ##############################################################################
57129# ##### Stand alone program ########
0 commit comments