コード例 #1
0
        def test_language_tags_replacement(self):
            """webdoc - replacing <lang:link /> and <lang:current /> in
            webdoc files"""
            result = transform('<lang:current />', languages=[CFG_SITE_LANG])
            self.assertEqual(result[0][1], CFG_SITE_LANG)

            result = transform('<lang:link />', languages=[CFG_SITE_LANG])
            self.assertEqual(result[0][1], '?ln=%s' % CFG_SITE_LANG)

            result = transform('<lang:link />', languages=['fr'])
            self.assertEqual(result[0][1], '?ln=fr')
コード例 #2
0
        def test_language_tags_replacement(self):
            """webdoc - replacing <lang:link /> and <lang:current /> in
            webdoc files"""
            result = transform('<lang:current />', languages=[CFG_SITE_LANG])
            self.assertEqual(result[0][1], CFG_SITE_LANG)

            result = transform('<lang:link />', languages=[CFG_SITE_LANG])
            self.assertEqual(result[0][1], '?ln=%s' % CFG_SITE_LANG)

            result = transform('<lang:link />', languages=['fr'])
            self.assertEqual(result[0][1], '?ln=fr')
コード例 #3
0
ファイル: webdoc_tests.py プロジェクト: pombredanne/invenio
        def test_parts(self):
            """webdoc - retrieving parts of webdoc file (title, navtrail, etc)"""
            _ = gettext_set_language(CFG_SITE_LANG)

            result = transform('''
            <!-- WebDoc-Page-Title: _(Help Central)_  -->
            <!-- WebDoc-Page-Navtrail: <a class="navtrail" href="<CFG_SITE_URL>/help/hacking">Hacking Invenio</a> &gt; <a class="navtrail" href="webstyle-internals">WebStyle Internals</a> -->
            <!-- WebDoc-Page-Revision: $Id: help-central.webdoc,v 1.5 2008/05/26 12:52:41 jerome Exp $ -->
            <!-- WebDoc-Page-Description: A description -->''',
                               languages=[CFG_SITE_LANG])

            # Title
            self.assertEqual(result[0][2], _("Help Central"))

            # Keywords. None in our sample
            self.assertEqual(result[0][3], None)

            # Navtrail
            self.assertEqual(result[0][4], '<a class="navtrail" href="%s/help/hacking">Hacking Invenio</a> &gt; <a class="navtrail" href="webstyle-internals">WebStyle Internals</a>' % CFG_SITE_URL)

            # Revision. Keep date & time only
            self.assertEqual(result[0][5], '2008-05-26 12:52:41')

            # Description
            self.assertEqual(result[0][6], 'A description')
コード例 #4
0
ファイル: webdoc_tests.py プロジェクト: pombredanne/invenio
 def test_string_translation(self):
     """webdoc - string translation"""
     result = transform('my_string: _(Search)_ (end)',
                        languages=[CFG_SITE_LANG])
     _ = gettext_set_language(CFG_SITE_LANG)
     self.assertEqual(result[0][1],
                      'my_string: %s (end)' % _("Search"))
コード例 #5
0
        def test_parts(self):
            """webdoc - retrieving parts of webdoc file (title, navtrail, etc)"""
            _ = gettext_set_language(CFG_SITE_LANG)

            result = transform('''
            <!-- WebDoc-Page-Title: _(Help Central)_  -->
            <!-- WebDoc-Page-Navtrail: <a class="navtrail" href="<CFG_SITE_URL>/help/hacking">Hacking Invenio</a> &gt; <a class="navtrail" href="webstyle-internals">WebStyle Internals</a> -->
            <!-- WebDoc-Page-Revision: $Id: help-central.webdoc,v 1.5 2008/05/26 12:52:41 jerome Exp $ -->
            <!-- WebDoc-Page-Description: A description -->''',
                               languages=[CFG_SITE_LANG])

            # Title
            self.assertEqual(result[0][2], _("Help Central"))

            # Keywords. None in our sample
            self.assertEqual(result[0][3], None)

            # Navtrail
            self.assertEqual(
                result[0][4],
                '<a class="navtrail" href="%s/help/hacking">Hacking Invenio</a> &gt; <a class="navtrail" href="webstyle-internals">WebStyle Internals</a>'
                % CFG_SITE_URL)

            # Revision. Keep date & time only
            self.assertEqual(result[0][5], '2008-05-26 12:52:41')

            # Description
            self.assertEqual(result[0][6], 'A description')
コード例 #6
0
        def test_language_filtering(self):
            """webdoc - language filtering"""
            result = transform('''
            <strong>
            <lang>
                <python>{}</python>
                <en><red>Book</red></en>
                <fr><yellow>Livre</yellow></fr>
                <de><blue>Buch</blue></de>
            </lang>
            </strong>
            ''',
                               languages=['de'])

            # German is kept
            self.assertEqual(result[0][0], 'de')
            self.assert_('<blue>Buch</blue>' in result[0][1])

            # English and French must be filtered out in any case
            self.assert_('Livre' not in result[0][1])
            self.assert_('Book' not in result[0][1])

            # Python is not considered as a language, so the string is
            # kept as it is
            self.assert_('<python>{}</python' in result[0][1])
コード例 #7
0
ファイル: webdoc_tests.py プロジェクト: pombredanne/invenio
        def test_comments_filtering(self):
            """webdoc - removing comments"""
            result = transform('''# -*- coding: utf-8 -*-
    ## $Id$
    ##''',
                               languages=[CFG_SITE_LANG])

            self.assertEqual(result[0][1], '')
コード例 #8
0
        def test_comments_filtering(self):
            """webdoc - removing comments"""
            result = transform('''# -*- coding: utf-8 -*-
    ## $Id$
    ##''',
                               languages=[CFG_SITE_LANG])

            self.assertEqual(result[0][1], '')
コード例 #9
0
ファイル: webdoc_tests.py プロジェクト: pombredanne/invenio
        def test_language_filtering(self):
            """webdoc - language filtering"""
            result = transform('''
            <strong>
            <lang>
                <python>{}</python>
                <en><red>Book</red></en>
                <fr><yellow>Livre</yellow></fr>
                <de><blue>Buch</blue></de>
            </lang>
            </strong>
            ''', languages=['de'])

            # German is kept
            self.assertEqual(result[0][0], 'de')
            self.assert_('<blue>Buch</blue>' in result[0][1])

            # English and French must be filtered out in any case
            self.assert_('Livre' not in result[0][1])
            self.assert_('Book' not in result[0][1])

            # Python is not considered as a language, so the string is
            # kept as it is
            self.assert_('<python>{}</python' in result[0][1])
コード例 #10
0
ファイル: webdoc_tests.py プロジェクト: pombredanne/invenio
 def test_CFG_SITE_URL_variable_replacement(self):
     """webdoc - replacing <CFG_SITE_URL> in webdoc files"""
     result = transform('<CFG_SITE_URL>', languages=[CFG_SITE_LANG])
     self.assertEqual(result[0][1], CFG_SITE_URL)
コード例 #11
0
 def test_string_translation(self):
     """webdoc - string translation"""
     result = transform('my_string: _(Search)_ (end)',
                        languages=[CFG_SITE_LANG])
     _ = gettext_set_language(CFG_SITE_LANG)
     self.assertEqual(result[0][1], 'my_string: %s (end)' % _("Search"))
コード例 #12
0
 def test_CFG_SITE_URL_variable_replacement(self):
     """webdoc - replacing <CFG_SITE_URL> in webdoc files"""
     result = transform('<CFG_SITE_URL>', languages=[CFG_SITE_LANG])
     self.assertEqual(result[0][1], CFG_SITE_URL)