Test Article objects caching at the generator level
(self)
| 156 | self.assertEqual(uncached_hidden_pages, cached_hidden_pages) |
| 157 | |
| 158 | def test_article_object_caching(self): |
| 159 | """Test Article objects caching at the generator level""" |
| 160 | settings = self._get_cache_enabled_settings() |
| 161 | settings["CONTENT_CACHING_LAYER"] = "generator" |
| 162 | settings["DEFAULT_DATE"] = (1970, 1, 1) |
| 163 | settings["READERS"] = {"asc": None} |
| 164 | context = get_context(settings) |
| 165 | |
| 166 | generator = ArticlesGenerator( |
| 167 | context=context.copy(), |
| 168 | settings=settings, |
| 169 | path=CONTENT_DIR, |
| 170 | theme=settings["THEME"], |
| 171 | output_path=None, |
| 172 | ) |
| 173 | generator.generate_context() |
| 174 | self.assertTrue(hasattr(generator, "_cache")) |
| 175 | |
| 176 | generator = ArticlesGenerator( |
| 177 | context=context.copy(), |
| 178 | settings=settings, |
| 179 | path=CONTENT_DIR, |
| 180 | theme=settings["THEME"], |
| 181 | output_path=None, |
| 182 | ) |
| 183 | generator.readers.read_file = MagicMock() |
| 184 | generator.generate_context() |
| 185 | """ |
| 186 | 7 files don't get cached because they were not valid |
| 187 | - article_with_attributes_containing_double_quotes.html |
| 188 | - article_with_comments.html |
| 189 | - article_with_null_attributes.html |
| 190 | - 2012-11-30_md_w_filename_meta#foo-bar.md |
| 191 | - empty.md |
| 192 | - empty_with_bom.md |
| 193 | - article_skip.md |
| 194 | """ |
| 195 | self.assertEqual(generator.readers.read_file.call_count, 7) |
| 196 | |
| 197 | def test_article_reader_content_caching(self): |
| 198 | """Test raw article content caching at the reader level""" |
nothing calls this directly
no test coverage detected