def test_run_with_default_opts(self): content = parser('''\ asd --- .. blohg-attachmentimage:: foo.jpg ''', 3) self.url_for.assert_called_once_with('attachments', filename='foo.jpg', _external=True) self.assertIn('http://lol/foo.jpg', content['images']) self.assertIn('src="http://lol/foo.jpg"', content['fragment'])
def test_simple_include(self): content = parser('''\ asd === hahah .. blohg-includehg:: content/foo.rst ''', 3) self.assertIn('<h3>Included paragraph</h3>', content['fragment']) self.assertIn('<p>lol</p>', content['fragment']) self.assertIn('<p>XD</p>', content['fragment'])
def test_include_literal(self): content = parser('''\ asd === hahah .. blohg-includehg:: content/foo.rst :literal: ''', 3) self.assertIn('\nIncluded paragraph\n', content['fragment']) self.assertIn('\nlol\n', content['fragment']) self.assertIn('\nXD\n', content['fragment'])
def test_run_with_default_opts(self): content = parser('''\ asd --- .. blohg-vimeo:: 34368016 ''', 3) self.assertIn('http://player.vimeo.com/video/34368016', content['fragment']) self.assertIn('width: 425px', content['fragment']) self.assertIn('height: 344px', content['fragment']) self.assertIn('align-center', content['fragment']) self.assertIn('frameborder="0"', content['fragment']) self.assertIn('allowfullscreen', content['fragment'])
def test_run_with_default_opts(self): content = parser('''\ asd --- .. blohg-youtube:: ssMfQ9ybTEc ''', 3) self.assertIn('http://www.youtube.com/embed/ssMfQ9ybTEc', content['fragment']) self.assertIn('width: 425px', content['fragment']) self.assertIn('height: 344px', content['fragment']) self.assertIn('align-center', content['fragment']) self.assertIn('frameborder="0"', content['fragment']) self.assertIn('allowfullscreen', content['fragment'])
def test_run_with_default_opts(self): content = parser('''\ asd --- .. blohg-sourcecode:: python import os print os.path ''', 3) self.assertIn('class="highlight"', content['fragment']) self.assertIn('import', content['fragment'])
def test_run_with_default_opts(self): content = parser('''\ asd --- .. blohg-math:: \\frac{x^2}{1+x} ''', 3) self.assertIn('https://chart.googleapis.com/chart?cht=tx&chl=' '%5Cfrac%7Bx%5E2%7D%7B1%2Bx%7D', content['images']) self.assertIn('https://chart.googleapis.com/chart?cht=tx&' 'chl=%5Cfrac%7Bx%5E2%7D%7B1%2Bx%7D', content['fragment']) self.assertIn('align-center', content['fragment'])
def test_include_with_start_and_end(self): content = parser('''\ asd === hahah .. blohg-includehg:: content/foo.rst :start-line: 3 :end-line: 4 ''', 3) self.assertNotIn('<h3>Included paragraph</h3>', content['fragment']) self.assertIn('<p>lol</p>', content['fragment']) self.assertNotIn('<p>XD</p>', content['fragment'])
def test_run_with_argument_for_subsubpage(self): content = parser('''\ asd --- .. blohg-subpages:: foo/bar ''', 3) self.assertNotIn('"/foo/"', content['fragment']) self.assertNotIn('>Foo :)<', content['fragment']) self.assertNotIn('"/bar/"', content['fragment']) self.assertNotIn('>Bar!<', content['fragment']) self.assertNotIn('"/foo/bar/"', content['fragment']) self.assertNotIn('>Foo Bar :P<', content['fragment']) self.assertIn('"/foo/bar/baz/"', content['fragment']) self.assertIn('>Foo Bar Baz XD<', content['fragment'])
def test_run_with_argument_from_subpage(self): content = parser('''\ asd --- .. blohg-subpages:: foo ''', 3, ':repo:cont/foo/index.rs') self.assertNotIn('"/foo/"', content['fragment']) self.assertNotIn('>Foo :)<', content['fragment']) self.assertNotIn('"/bar/"', content['fragment']) self.assertNotIn('>Bar!<', content['fragment']) self.assertIn('"/foo/bar/"', content['fragment']) self.assertIn('>Foo Bar :P<', content['fragment']) self.assertNotIn('"/foo/bar/baz/"', content['fragment']) self.assertNotIn('>Foo Bar Baz XD<', content['fragment'])
def test_run(self): content = parser('''\ asd --- .. blohg-sourcecode:: python :linenos: import os print os.path ''', 3) self.assertIn('class="lineno">3', content['fragment']) self.assertIn('import', content['fragment'])
def test_run(self): content = parser('''\ asd --- .. blohg-attachmentfigure:: foo.jpg :align: left asdf lol. ''', 3) self.url_for.assert_called_once_with('attachments', filename='foo.jpg', _external=True) self.assertIn('http://lol/foo.jpg', content['images']) self.assertIn('src="http://lol/foo.jpg"', content['fragment']) self.assertIn('caption">asdf lol.', content['fragment']) self.assertIn('align-left', content['fragment'])
def test_run_with_argument_for_subsubpage(self): content = parser('''\ asd --- .. blohg-subpages:: foo/bar ''', 3) self.assertNotIn('"/foo/"', content['fragment']) self.assertNotIn('>Foo :)<', content['fragment']) self.assertNotIn('"/bar/"', content['fragment']) self.assertNotIn('>Bar!<', content['fragment']) self.assertNotIn('"/foo/bar/"', content['fragment']) self.assertNotIn('>Foo Bar :P<', content['fragment']) self.assertIn('"/foo/bar/baz/"', content['fragment']) self.assertIn('>Foo Bar Baz XD<', content['fragment']) self.assertNotIn('>Foo Bar Bad XD<', content['fragment']) self.assertIn('"/foo/bar/bad/"', content['fragment']) self.assertIn('###asd###', content['fragment'])
def test_run(self): content = parser('''\ asd --- .. blohg-vimeo:: 34368016 :align: left :width: 100 :height: 200 :allowfullscreen: false :border: 1 ''', 3) self.assertIn('http://player.vimeo.com/video/34368016', content['fragment']) self.assertIn('width: 100px', content['fragment']) self.assertIn('height: 200px', content['fragment']) self.assertIn('align-left', content['fragment']) self.assertIn('frameborder="1"', content['fragment']) self.assertNotIn('allowfullscreen', content['fragment'])
def test_run(self): content = parser('''\ asd --- .. blohg-youtube:: ssMfQ9ybTEc :align: left :width: 100 :height: 200 :allowfullscreen: false :border: 1 ''', 3) self.assertIn('http://www.youtube.com/embed/ssMfQ9ybTEc', content['fragment']) self.assertIn('width: 100px', content['fragment']) self.assertIn('height: 200px', content['fragment']) self.assertIn('align-left', content['fragment']) self.assertIn('frameborder="1"', content['fragment']) self.assertNotIn('allowfullscreen', content['fragment'])
def parsed_source(self): return parser(self.full, self._rst_header_level, ':repo:%s' % self.path)
def parsed_abstract(self): if not self.read_more: return self.parsed_source return parser(self.abstract, self._rst_header_level, ':repo:%s' % self.path)