예제 #1
0
    def setUp(self):
        """
        Prepares a sitemap instance with a fake config.
        """
        self.app = Holocron(conf={
            'encoding': {
                'output': 'my-enc',
            },

            'paths': {
                'output': 'path/to/output',
            },

            'ext': {
                'enabled': [],
            },
        })
        self.sitemap = Sitemap(self.app)

        self.open_fn = 'holocron.ext.sitemap.open'

        self.post_url = 'http://example.com/post/'
        self.page_url = 'http://example.com/page/'

        self.page_date = datetime(2014, 12, 27)
        self.post_date = datetime(2013, 4, 1)

        self.post = mock.Mock(
            spec=Post, abs_url=self.post_url, updated_local=self.post_date)
        self.page = mock.Mock(
            spec=Page, abs_url=self.page_url, updated_local=self.page_date)
        self.static = mock.Mock(spec=Static)
예제 #2
0
    def test_extra_tables(self):
        """
        Converter has to support tables syntax.
        """
        self.conv = Markdown(Holocron(conf={
            'ext': {
                'enabled': [],
                'markdown': {
                    'extensions': ['markdown.extensions.extra'],
                },
            },
        }))

        _, html = self.conv.to_html(textwrap.dedent('''\
            column a | column b
            ---------|---------
               foo   |   bar
        '''))

        self.assertIn('table', html)

        self.assertIn('<th>column a</th>', html)
        self.assertIn('<th>column b</th>', html)

        self.assertIn('<td>foo</td>', html)
        self.assertIn('<td>bar</td>', html)
예제 #3
0
 def setUp(self):
     self.conv = ReStructuredText(
         Holocron(conf={
             'ext': {
                 'enabled': [],
             },
         }))
예제 #4
0
    def setUp(self):
        self.app = Holocron(
            conf={
                'site': {
                    'title': 'MyTestSite',
                    'author': 'Tester',
                    'url': 'http://www.mytest.com/',
                },
                'encoding': {
                    'output': 'my-enc',
                },
                'paths': {
                    'output': 'path/to/output',
                },
                'ext': {
                    'enabled': [],
                    'feed': {
                        'save_as': 'myfeed.xml',
                        'posts_number': 3,
                    },
                },
            })
        self.feed = Feed(self.app)

        self.date_early = datetime(2012, 2, 2)
        self.date_moderate = datetime(2013, 4, 1)
        self.date_late = datetime(2014, 6, 12)

        self.date_early_updated = datetime(2012, 12, 6)
        self.date_moderate_updated = datetime(2013, 12, 6)
        self.date_late_updated = datetime(2014, 12, 6)

        self.post_early = mock.Mock(spec=Post,
                                    published=self.date_early,
                                    updated_local=self.date_early_updated,
                                    abs_url='http://www.post_early.com',
                                    title='MyEarlyPost')

        self.post_moderate = mock.Mock(
            spec=Post,
            published=self.date_moderate,
            updated_local=self.date_moderate_updated,
            abs_url='http://www.post_moderate.com')

        self.post_late = mock.Mock(spec=Post,
                                   published=self.date_late,
                                   updated_local=self.date_late_updated,
                                   url='www.post_late.com',
                                   abs_url='http://www.post_late.com',
                                   title='MyTestPost')

        self.late_id = '<id>http://www.post_late.com</id>'
        self.moderate_id = '<id>http://www.post_moderate.com</id>'
        self.early_id = '<id>http://www.post_early.com</id>'

        self.page = mock.Mock(spec=Page, url='www.page.com')
        self.static = mock.Mock(spec=Static, url='www.image.com')

        self.open_fn = 'holocron.ext.feed.open'
예제 #5
0
 def setUp(self):
     self.conv = Markdown(Holocron(conf={
         'ext': {
             'enabled': [],
             'markdown': {
                 'extensions': [],
             },
         },
     }))
예제 #6
0
    def setUp(self):
        self.app = Holocron(conf={
            'sitename': 'MyTestSite',
            'siteurl': 'www.mytest.com',
            'author': 'Tester',

            'encoding': {
                'output': 'my-enc',
            },

            'paths': {
                'output': 'path/to/output',
            },

            'ext': {
                'enabled': [],
                'tags': {
                    'output': 'mypath/tags/{tag}',
                },
            },
        })
        self.tags = Tags(self.app)

        self.date_early = datetime(2012, 2, 2)
        self.date_moderate = datetime(2013, 4, 1)
        self.date_late = datetime(2014, 6, 12)

        self.post_early = mock.Mock(
            spec=Post,
            published=self.date_early,
            tags=['testtag1', 'testtag2'],
            title='MyTestPost',
            url='www.post_early.com')

        self.post_moderate = mock.Mock(
            spec=Post,
            published=self.date_moderate,
            url='www.post_moderate.com',
            tags=['testtag2', 'testtag3'])

        self.post_late = mock.Mock(
            spec=Post,
            published=self.date_late,
            url='www.post_late.com',
            tags=['testtag2'])

        self.post_malformed = mock.Mock(
            spec=Post,
            short_source='test',
            tags='testtag')

        self.page = mock.Mock(spec=Page)
        self.static = mock.Mock(spec=Static)

        self.open_fn = 'holocron.ext.tags.open'
예제 #7
0
    def setUp(self, getcwd, getctime, getmtime):
        """
        Prepares a document instance with a fake config.
        """
        filename = os.path.join(self._conf['paths.content'],
                                self.document_filename)

        self.app = Holocron(self._conf)
        self.app.add_converter(FakeConverter())

        self.doc = self.document_class(filename, self.app)
예제 #8
0
    def test_user_settings(self):
        """
        Tests creating an instance with custom settings: check for settings
        overriding.
        """
        app = Holocron({
            'sitename': 'Luke Skywalker',
            'paths': {
                'content': 'path/to/content',
            },
        })

        conf = copy.deepcopy(app.default_conf)
        conf['sitename'] = 'Luke Skywalker'
        conf['paths']['content'] = 'path/to/content'

        self.assertEqual(app.conf, conf)
예제 #9
0
    def setUp(self):
        """
        Creates generator object and number of posts which will be further used
        in test sets.
        """
        self.app = Holocron(
            conf={
                'sitename': 'MyTestSite',
                'siteurl': 'www.mytest.com',
                'author': 'Tester',
                'encoding': {
                    'output': 'my-enc',
                },
                'paths': {
                    'output': 'path/to/output',
                },
                'ext': {
                    'enabled': [],
                },
            })
        self.index = Index(self.app)

        self.open_fn = 'holocron.ext.index.open'

        self.date_early = datetime(2012, 2, 2)
        self.date_late = datetime(2014, 6, 12)
        self.date_moderate = datetime(2013, 4, 1)

        self.post_early = mock.Mock(
            spec=Post,
            published=self.date_early,
            url='www.post_early.com',
        )

        self.post_moderate = mock.Mock(spec=Post,
                                       published=self.date_moderate,
                                       url='www.post_moderate.com')

        self.post_late = mock.Mock(spec=Post,
                                   published=self.date_late,
                                   url='www.post_late.com')

        self.page = mock.Mock(spec=Page)
        self.static = mock.Mock(spec=Static)
예제 #10
0
    def test_codehilite_extension(self):
        """
        Converter has to use Pygments to highlight code blocks.
        """
        self.conv = Markdown(Holocron(conf={
            'ext': {
                'enabled': [],
                'markdown': {
                    'extensions': ['markdown.extensions.codehilite'],
                },
            },
        }))

        _, html = self.conv.to_html(textwrap.dedent('''\
            test codeblock

                :::python
                lambda x: pass
        '''))

        self.assertRegexpMatches(html, '.*codehilite.*<pre>[\s\S]+</pre>.*')
예제 #11
0
    def test_extra_code(self):
        """
        Converter has to support GitHub's fence code syntax.
        """
        self.conv = Markdown(Holocron(conf={
            'ext': {
                'enabled': [],
                'markdown': {
                    'extensions': [
                        'markdown.extensions.codehilite',
                        'markdown.extensions.extra',
                    ],
                },
            },
        }))

        _, html = self.conv.to_html(textwrap.dedent('''\
            ```python
            lambda x: pass
            ```
        '''))

        self.assertRegexpMatches(html, '.*codehilite.*<pre>[\s\S]+</pre>.*')
예제 #12
0
    def test_code_macros_is_enabled(self):
        """
        Converter has to use Pygments to highlight code blocks.
        """
        self.conv = Creole(
            Holocron(
                conf={
                    'ext': {
                        'enabled': ['creole'],
                        'creole': {
                            'syntax_highlight': True,
                        }
                    }
                }))

        _, html = self.conv.to_html(
            textwrap.dedent('''\
            <<code ext=".py">>
                lambda x: pass
            <</code>>
        '''))

        self.assertRegexpMatches(html, '.*pygments.*<pre>[\s\S]+</pre>.*')
예제 #13
0
    def test_code_macros_is_disabled(self):
        """
        Converter shouldn't support code macros if syntax highlighting is
        turned off.
        """
        self.conv = Creole(
            Holocron(
                conf={
                    'ext': {
                        'enabled': ['creole'],
                        'creole': {
                            'syntax_highlight': False,
                        }
                    }
                }))

        _, html = self.conv.to_html(
            textwrap.dedent('''\
            <<code ext=".py">>
                lambda x: pass
            <</code>>
        '''))

        self.assertEqual(html, "[Error: Macro 'code' doesn't exist]")
예제 #14
0
 def setUp(self):
     self.conv = Creole(Holocron(conf={
         'ext': {
             'enabled': ['creole'],
         },
     }))
예제 #15
0
 def setUp(self):
     self.app = Holocron({
         'ext': {
             'enabled': [],
         },
     })
예제 #16
0
 def setUp(self):
     self.app = Holocron()
예제 #17
0
 def _create_document(self, filename, getcwd, getctime, getmtime, _):
     app = Holocron({'paths': {
         'content': './content',
     }})
     app.add_converter(FakeConverter())
     return content.create_document(filename, app)
예제 #18
0
 def setUp(self):
     self.holocron = Holocron(conf={
         'ext': {
             'enabled': ['creole'],
         },
     })