Esempio n. 1
0
 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'])
Esempio n. 2
0
 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))
Esempio n. 3
0
 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'])
Esempio n. 4
0
 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))
Esempio n. 5
0
 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))
Esempio n. 6
0
 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))
Esempio n. 7
0
 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
Esempio n. 8
0
 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
Esempio n. 9
0
 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)
Esempio n. 10
0
 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)
Esempio n. 11
0
 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))
Esempio n. 12
0
 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)
Esempio n. 13
0
 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))
Esempio n. 14
0
 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'])
Esempio n. 15
0
 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)
Esempio n. 16
0
 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)
Esempio n. 17
0
 def test_handles_pre_composition(self):
     extension = BlogExtension(None)
     self.assertTrue(extension.handle_pre_composition)
Esempio n. 18
0
 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'])
Esempio n. 19
0
 def test_ignores_non_blog_post(self):
     extension = BlogExtension(None)
     extension.on_frontmatter_loaded('exosquad.md', {})
     self.assertEqual(0, len(extension.posts))
Esempio n. 20
0
 def test_handles_frontmatter_loaded(self):
     extension = BlogExtension(None)
     self.assertTrue(extension.handle_frontmatter_loaded)
Esempio n. 21
0
 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)
Esempio n. 22
0
 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)
Esempio n. 23
0
 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'])
Esempio n. 24
0
 def test_ignores_non_blog_post(self):
     extension = BlogExtension(None)
     extension.on_frontmatter_loaded('exosquad.md', {})
     self.assertEqual(0, len(extension.posts))
Esempio n. 25
0
 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)
Esempio n. 26
0
 def test_blog_must_be_boolean(self):
     extension = BlogExtension(None)
     self.assertRaises(AbortError, extension.on_frontmatter_loaded,
                       'animaniacs.md', {'blog': 'crazy'})
Esempio n. 27
0
 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'])