|
25 | 25 | from mkdocs.config import load_config
|
26 | 26 |
|
27 | 27 | # package
|
| 28 | +from mkdocs_rss_plugin.__about__ import __title_clean__ |
28 | 29 | from mkdocs_rss_plugin.integrations.theme_material_social_plugin import (
|
29 | 30 | IntegrationMaterialSocialCards,
|
30 | 31 | )
|
@@ -136,6 +137,55 @@ def test_plugin_config_social_cards_enabled_with_blog_plugin(self):
|
136 | 137 | )
|
137 | 138 | self.assertTrue(integration_social_cards.IS_ENABLED)
|
138 | 139 |
|
| 140 | + def test_plugin_config_social_cards_enabled_with_directory_urls_disabled(self): |
| 141 | + """Test case described in https://github.com/Guts/mkdocs-rss-plugin/issues/319.""" |
| 142 | + # default reference |
| 143 | + cfg_mkdocs = load_config( |
| 144 | + str( |
| 145 | + Path( |
| 146 | + "tests/fixtures/mkdocs_item_image_social_cards_blog_directory_url_disabled.yml" |
| 147 | + ).resolve() |
| 148 | + ) |
| 149 | + ) |
| 150 | + |
| 151 | + integration_social_cards = IntegrationMaterialSocialCards( |
| 152 | + mkdocs_config=cfg_mkdocs |
| 153 | + ) |
| 154 | + self.assertTrue(integration_social_cards.IS_THEME_MATERIAL) |
| 155 | + self.assertTrue(integration_social_cards.IS_SOCIAL_PLUGIN_ENABLED) |
| 156 | + self.assertTrue(integration_social_cards.IS_SOCIAL_PLUGIN_CARDS_ENABLED) |
| 157 | + self.assertIsInstance(integration_social_cards.social_cards_dir, str) |
| 158 | + self.assertTrue(integration_social_cards.social_cards_cache_dir.is_dir()) |
| 159 | + |
| 160 | + with tempfile.TemporaryDirectory( |
| 161 | + prefix=f"{__title_clean__.lower()}_", delete=False |
| 162 | + ) as tmpdirname: |
| 163 | + cli_result = self.build_docs_setup( |
| 164 | + testproject_path="docs", |
| 165 | + mkdocs_yml_filepath=Path( |
| 166 | + "tests/fixtures/mkdocs_item_image_social_cards_blog_directory_url_disabled.yml" |
| 167 | + ), |
| 168 | + output_path=tmpdirname, |
| 169 | + strict=False, |
| 170 | + ) |
| 171 | + print(tmpdirname) |
| 172 | + if cli_result.exception is not None: |
| 173 | + e = cli_result.exception |
| 174 | + logger.debug(format_exception(type(e), e, e.__traceback__)) |
| 175 | + |
| 176 | + self.assertEqual(cli_result.exit_code, 0) |
| 177 | + self.assertIsNone(cli_result.exception) |
| 178 | + |
| 179 | + # created items |
| 180 | + feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml") |
| 181 | + self.assertEqual(feed_parsed.bozo, 0) |
| 182 | + for feed_item in feed_parsed.entries: |
| 183 | + self.assertTrue(hasattr(feed_item, "enclosures")) |
| 184 | + |
| 185 | + # updated items |
| 186 | + feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_updated.xml") |
| 187 | + self.assertEqual(feed_parsed.bozo, 0) |
| 188 | + |
139 | 189 | def test_simple_build(self):
|
140 | 190 | with tempfile.TemporaryDirectory() as tmpdirname:
|
141 | 191 | cli_result = self.build_docs_setup(
|
|
0 commit comments