Example #1
0
 def setUp(self):
     super(SameCheckTest, self).setUp()
     self.check = SameCheck()
     self.test_good_none = ('%(source)s', '%(source)s', 'python-format')
     self.test_good_matching = ('source', 'translation', '')
     self.test_good_ignore = ('alarm', 'alarm', '')
     self.test_failure_1 = ('string', 'string', '')
Example #2
0
 def setUp(self):
     super(SameCheckTest, self).setUp()
     self.check = SameCheck()
     self.test_good_none = ('%(source)s', '%(source)s', 'python-format')
     self.test_good_matching = ('source', 'translation', '')
     self.test_good_ignore = ('alarm', 'alarm', '')
     self.test_failure_1 = ('retezec', 'retezec', '')
Example #3
0
class SameCheckTest(CheckTestCase):
    def setUp(self):
        super(SameCheckTest, self).setUp()
        self.check = SameCheck()
        self.test_good_none = ('%(source)s', '%(source)s', 'python-format')
        self.test_good_matching = ('source', 'translation', '')
        self.test_good_ignore = ('alarm', 'alarm', '')
        self.test_failure_1 = ('string', 'string', '')

    def test_same_english(self):
        self.assertFalse(self.check.check_single(
            'source',
            'source',
            '',
            Language('en'),
            None,
            0
        ))
Example #4
0
class SameCheckTest(CheckTestCase):
    def setUp(self):
        super(SameCheckTest, self).setUp()
        self.check = SameCheck()
        self.test_good_none = ('%(source)s', '%(source)s', 'python-format')
        self.test_good_matching = ('source', 'translation', '')
        self.test_good_ignore = ('alarm', 'alarm', '')
        self.test_failure_1 = ('string', 'string', '')

    def test_same_english(self):
        self.assertFalse(self.check.check_single(
            'source',
            'source',
            '',
            Language('en'),
            None,
            0
        ))

    def test_same_numbers(self):
        self.do_test(False, ('1:4', '1:4', ''))

    def test_same_copyright(self):
        self.do_test(
            False,
            (
                u'(c) Copyright 2013 Michal Čihař',
                u'(c) Copyright 2013 Michal Čihař',
                ''
            )
        )
        self.do_test(
            False,
            (
                u'© Copyright 2013 Michal Čihař',
                u'© Copyright 2013 Michal Čihař',
                ''
            )
        )
Example #5
0
class SameCheckTest(CheckTestCase):
    def setUp(self):
        super(SameCheckTest, self).setUp()
        self.check = SameCheck()
        self.test_good_none = ('%(source)s', '%(source)s', 'python-format')
        self.test_good_matching = ('source', 'translation', '')
        self.test_good_ignore = ('alarm', 'alarm', '')
        self.test_failure_1 = ('string', 'string', '')

    def test_same_english(self):
        self.assertFalse(self.check.check_single(
            'source',
            'source',
            Unit(code='en'),
            0
        ))

    def test_same_numbers(self):
        self.do_test(False, ('1:4', '1:4', ''))

    def test_same_copyright(self):
        self.do_test(
            False,
            (
                u'(c) Copyright 2013 Michal Čihař',
                u'(c) Copyright 2013 Michal Čihař',
                ''
            )
        )
        self.do_test(
            False,
            (
                u'© Copyright 2013 Michal Čihař',
                u'© Copyright 2013 Michal Čihař',
                ''
            )
        )
Example #6
0
class SameCheckTest(CheckTestCase):
    def setUp(self):
        super(SameCheckTest, self).setUp()
        self.check = SameCheck()
        self.test_good_none = ('%(source)s', '%(source)s', 'python-format')
        self.test_good_matching = ('source', 'translation', '')
        self.test_good_ignore = ('alarm', 'alarm', '')
        self.test_failure_1 = ('retezec', 'retezec', '')

    def test_same_english(self):
        self.assertFalse(self.check.check_single(
            'source',
            'source',
            MockUnit(code='en'),
            0
        ))

    def test_same_numbers(self):
        self.do_test(False, ('1:4', '1:4', ''))

    def test_same_multi(self):
        self.do_test(
            False,
            (
                u'Linux kernel',
                u'Linux kernel',
                ''
            )
        )
        self.do_test(
            True,
            (
                u'Linux kernel image',
                u'Linux kernel image',
                ''
            )
        )

    def test_same_copyright(self):
        self.do_test(
            False,
            (
                u'(c) Copyright 2013 Michal Čihař',
                u'(c) Copyright 2013 Michal Čihař',
                ''
            )
        )
        self.do_test(
            False,
            (
                u'© Copyright 2013 Michal Čihař',
                u'© Copyright 2013 Michal Čihař',
                ''
            )
        )

    def test_same_format(self):
        self.do_test(
            False,
            (
                '%d.%m.%Y, %H:%M',
                '%d.%m.%Y, %H:%M',
                'php-format'
            )
        )

        self.do_test(
            True,
            (
                '%d bajt',
                '%d bajt',
                'php-format'
            )
        )

        self.do_test(
            False,
            (
                '%s %s %s %s %s %s   %s',
                '%s %s %s %s %s %s   %s',
                'c-format',
            )
        )

        self.do_test(
            False,
            (
                '%s%s, %s%s (',
                '%s%s, %s%s (',
                'c-format',
            )
        )

        self.do_test(
            False,
            (
                '%s %s Fax: %s',
                '%s %s Fax: %s',
                'c-format',
            )
        )

        self.do_test(
            False,
            (
                '%i C',
                '%i C',
                'c-format',
            )
        )

    def test_same_email(self):
        self.do_test(
            False,
            (
                '*****@*****.**',
                '*****@*****.**',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please contact [email protected]',
                'Please contact [email protected]',
                ''
            )
        )

    def test_same_url(self):
        self.do_test(
            False,
            (
                'http://weblate.org/',
                'http://weblate.org/',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please see http://weblate.org/',
                'Please see http://weblate.org/',
                ''
            )
        )
        self.do_test(
            False,
            (
                '[2]: http://code.google.com/p/pybluez/',
                '[2]: http://code.google.com/p/pybluez/',
                ''
            )
        )

    def test_same_channel(self):
        self.do_test(
            False,
            (
                '#weblate',
                '#weblate',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please use #weblate',
                'Please use #weblate',
                ''
            )
        )

    def test_same_domain(self):
        self.do_test(
            False,
            (
                'weblate.org',
                'weblate.org',
                ''
            )
        )
        self.do_test(
            False,
            (
                'demo.weblate.org',
                'demo.weblate.org',
                ''
            )
        )
        self.do_test(
            False,
            (
                '#weblate @ irc.freenode.net',
                '#weblate @ irc.freenode.net',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please see demo.weblate.org',
                'Please see demo.weblate.org',
                ''
            )
        )

    def test_same_path(self):
        self.do_test(
            False,
            (
                '/cgi-bin/koha/catalogue/search.pl?q=',
                '/cgi-bin/koha/catalogue/search.pl?q=',
                ''
            )
        )
        self.do_test(
            True,
            (
                'File/directory',
                'File/directory',
                ''
            )
        )

    def test_same_template(self):
        self.do_test(
            False,
            (
                '{building}: {description}',
                '{building}: {description}',
                ''
            )
        )
        self.do_test(
            True,
            (
                '{building}: some description',
                '{building}: some description',
                ''
            )
        )
Example #7
0
class SameCheckTest(CheckTestCase):
    def setUp(self):
        super(SameCheckTest, self).setUp()
        self.check = SameCheck()
        self.test_good_none = ('%(source)s', '%(source)s', 'python-format')
        self.test_good_matching = ('source', 'translation', '')
        self.test_good_ignore = ('alarm', 'alarm', '')
        self.test_failure_1 = ('retezec', 'retezec', '')

    def test_same_english(self):
        self.assertFalse(self.check.check_single(
            'source',
            'source',
            MockUnit(code='en'),
            0
        ))

    def test_same_numbers(self):
        self.do_test(False, ('1:4', '1:4', ''))
        self.do_test(False, ('1, 3, 10', '1, 3, 10', ''))

    def test_same_multi(self):
        self.do_test(
            False,
            (
                u'Linux kernel',
                u'Linux kernel',
                ''
            )
        )
        self.do_test(
            True,
            (
                u'Linux kernel testing image',
                u'Linux kernel testing image',
                ''
            )
        )
        self.do_test(
            False,
            (
                'Gettext (PO)',
                'Gettext (PO)',
                ''
            )
        )
        self.do_test(
            False,
            (
                'powerpc, m68k, i386, amd64',
                'powerpc, m68k, i386, amd64',
                '',
            )
        )

        self.do_test(
            False,
            (
                'Fedora & openSUSE',
                'Fedora & openSUSE',
                '',
            )
        )

    def test_same_copyright(self):
        self.do_test(
            False,
            (
                u'(c) Copyright 2013 Michal Čihař',
                u'(c) Copyright 2013 Michal Čihař',
                ''
            )
        )
        self.do_test(
            False,
            (
                u'© Copyright 2013 Michal Čihař',
                u'© Copyright 2013 Michal Čihař',
                ''
            )
        )

    def test_same_format(self):
        self.do_test(
            False,
            (
                '%d.%m.%Y, %H:%M',
                '%d.%m.%Y, %H:%M',
                'php-format'
            )
        )

        self.do_test(
            True,
            (
                '%d bajt',
                '%d bajt',
                'php-format'
            )
        )

        self.do_test(
            False,
            (
                '%s %s %s %s %s %s   %s',
                '%s %s %s %s %s %s   %s',
                'c-format',
            )
        )

        self.do_test(
            False,
            (
                '%s %s %s %s %s%s:%s %s ',
                '%s %s %s %s %s%s:%s %s ',
                'c-format'
            )
        )

        self.do_test(
            False,
            (
                '%s%s, %s%s (',
                '%s%s, %s%s (',
                'c-format',
            )
        )

        self.do_test(
            False,
            (
                '%s %s Fax: %s',
                '%s %s Fax: %s',
                'c-format',
            )
        )

        self.do_test(
            False,
            (
                '%i C',
                '%i C',
                'c-format',
            )
        )

    def test_same_rst(self):
        self.do_test(
            False,
            (
                ':ref:`index`',
                ':ref:`index`',
                'rst-text',
            )
        )
        self.do_test(
            True,
            (
                'See :ref:`index`',
                'See :ref:`index`',
                'rst-text',
            )
        )
        self.do_test(
            False,
            (
                '``mysql``',
                '``mysql``',
                'rst-text',
            )
        )
        self.do_test(
            True,
            (
                'Use ``mysql`` module',
                'Use ``mysql`` module',
                'rst-text',
            )
        )

    def test_same_email(self):
        self.do_test(
            False,
            (
                '*****@*****.**',
                '*****@*****.**',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please contact [email protected]',
                'Please contact [email protected]',
                ''
            )
        )

    def test_same_url(self):
        self.do_test(
            False,
            (
                'http://weblate.org/',
                'http://weblate.org/',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please see http://weblate.org/',
                'Please see http://weblate.org/',
                ''
            )
        )
        self.do_test(
            False,
            (
                '[2]: http://code.google.com/p/pybluez/',
                '[2]: http://code.google.com/p/pybluez/',
                ''
            )
        )
        self.do_test(
            False,
            (
                '[2]: https://sourceforge.net/projects/pywin32/',
                '[2]: https://sourceforge.net/projects/pywin32/',
                ''
            )
        )

    def test_same_channel(self):
        self.do_test(
            False,
            (
                '#weblate',
                '#weblate',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please use #weblate',
                'Please use #weblate',
                ''
            )
        )

    def test_same_domain(self):
        self.do_test(
            False,
            (
                'weblate.org',
                'weblate.org',
                ''
            )
        )
        self.do_test(
            False,
            (
                'demo.weblate.org',
                'demo.weblate.org',
                ''
            )
        )
        self.do_test(
            False,
            (
                '#weblate @ irc.freenode.net',
                '#weblate @ irc.freenode.net',
                ''
            )
        )
        self.do_test(
            True,
            (
                'Please see demo.weblate.org',
                'Please see demo.weblate.org',
                ''
            )
        )

    def test_same_path(self):
        self.do_test(
            False,
            (
                '/cgi-bin/koha/catalogue/search.pl?q=',
                '/cgi-bin/koha/catalogue/search.pl?q=',
                ''
            )
        )
        self.do_test(
            True,
            (
                'File/directory',
                'File/directory',
                ''
            )
        )

    def test_same_template(self):
        self.do_test(
            False,
            (
                '{building}: {description}',
                '{building}: {description}',
                ''
            )
        )
        self.do_test(
            True,
            (
                '{building}: some description',
                '{building}: some description',
                ''
            )
        )

    def test_same_lists(self):
        self.do_test(
            False,
            (
                'a.,b.,c.,d.',
                'a.,b.,c.,d.',
                ''
            )
        )
        self.do_test(
            False,
            (
                'i.,ii.,iii.,iv.',
                'i.,ii.,iii.,iv.',
                ''
            )
        )