def test_has_atom_id_in_metadata(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertEqual( 'https://www.example.com/feed.xml', extension.atom_metadata['id'])
def test_list_output_required_with_list_template(self): director = self.factory.make_director() self._add_blog_section(director.config.parser, exclude='list_output') extension = BlogExtension(director.config) with self.assertRaises(AbortError) as error: extension.on_pre_composition(director) self.assertTrue('list_output' in str(error.exception))
def test_has_atom_url_in_metadata(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertEqual('https://www.example.com/archive.html', extension.atom_metadata['url'])
def test_requires_atom_url(self): director = self.factory.make_director() self._add_blog_section(director.config.parser, exclude='atom_url') extension = BlogExtension(director.config) with self.assertRaises(AbortError) as error: extension.on_pre_composition(director) self.assertTrue('atom_url' in str(error.exception))
def test_requires_atom_title(self): director = self.factory.make_director() self._add_blog_section(director.config.parser, exclude='atom_title') extension = BlogExtension(director.config) with self.assertRaises(AbortError) as error: extension.on_pre_composition(director) self.assertTrue('atom_title' in str(error.exception))
def _make_preprocessed_one(self, director=None, exclude=None): """Make an instance that has all default metadata already parsed.""" if director is None: director = self.factory.make_director() self._add_blog_section(director.config.parser, exclude=exclude) extension = BlogExtension(director.config) extension.on_pre_composition(director) templates = os.path.join(director.site.path, 'templates') os.mkdir(templates) open(os.path.join(templates, 'archive.j2'), 'w').close() return extension
def test_has_list_output_in_extension(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertEqual('archive.html', extension.list_output)
def test_list_template_not_required(self): director = self.factory.make_director() self._add_blog_section(director.config.parser, exclude='list_template') extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertIsNone(extension.list_template)
def test_obtains_resolver(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertTrue(isinstance(extension._resolver, FileResolver))
def test_has_atom_output_in_metadata(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertEqual('feed.xml', extension.atom_output)
def test_has_atom_author_in_metadata(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertEqual('Nikola Tesla', extension.atom_metadata['author'])
def test_requires_blog_section(self): """A config with no blog section aborts.""" director = self.factory.make_director() extension = BlogExtension(director.config) self.assertRaises(AbortError, extension.on_pre_composition, director)
def test_handles_pre_composition(self): extension = BlogExtension(None) self.assertTrue(extension.handle_pre_composition)
def test_ignores_non_blog_post(self): extension = BlogExtension(None) extension.on_frontmatter_loaded('exosquad.md', {}) self.assertEqual(0, len(extension.posts))
def test_handles_frontmatter_loaded(self): extension = BlogExtension(None) self.assertTrue(extension.handle_frontmatter_loaded)
def test_should_generate_output_at_start(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) self.assertTrue(extension._should_generate)
def test_has_atom_title_in_metadata(self): director = self.factory.make_director() self._add_blog_section(director.config.parser) extension = BlogExtension(director.config) extension.on_pre_composition(director) self.assertEqual('Amazing blog', extension.atom_metadata['title'])
def test_blog_must_be_boolean(self): extension = BlogExtension(None) self.assertRaises(AbortError, extension.on_frontmatter_loaded, 'animaniacs.md', {'blog': 'crazy'})