Пример #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'])
Пример #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))
Пример #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'])
Пример #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))
Пример #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))
Пример #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))
Пример #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
Пример #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
Пример #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)
Пример #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)
Пример #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))
Пример #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)
Пример #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))
Пример #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'])
Пример #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)
Пример #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)
Пример #17
0
 def test_handles_pre_composition(self):
     extension = BlogExtension(None)
     self.assertTrue(extension.handle_pre_composition)
Пример #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'])
Пример #19
0
 def test_ignores_non_blog_post(self):
     extension = BlogExtension(None)
     extension.on_frontmatter_loaded('exosquad.md', {})
     self.assertEqual(0, len(extension.posts))
Пример #20
0
 def test_handles_frontmatter_loaded(self):
     extension = BlogExtension(None)
     self.assertTrue(extension.handle_frontmatter_loaded)
Пример #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)
Пример #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)
Пример #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'])
Пример #24
0
 def test_ignores_non_blog_post(self):
     extension = BlogExtension(None)
     extension.on_frontmatter_loaded('exosquad.md', {})
     self.assertEqual(0, len(extension.posts))
Пример #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)
Пример #26
0
 def test_blog_must_be_boolean(self):
     extension = BlogExtension(None)
     self.assertRaises(AbortError, extension.on_frontmatter_loaded,
                       'animaniacs.md', {'blog': 'crazy'})
Пример #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'])