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 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', '')
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 ))
class SameCheckTest(CheckTestCase): check = SameCheck() def setUp(self): super(SameCheckTest, self).setUp() 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'), )) def test_same_db_screen(self): self.assertTrue(self.check.check_single( 'some long text is here', 'some long text is here', MockUnit(code='de'), )) self.assertFalse(self.check.check_single( 'some long text is here', 'some long text is here', MockUnit(code='de', comment='Tag: screen'), )) 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, ( 'Linux kernel', 'Linux kernel', '' ) ) self.do_test( True, ( 'Linux kernel testing image', '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', '', ) ) self.do_test( False, ( 'n/a mm', 'n/a mm', '', ) ) def test_same_copyright(self): self.do_test( False, ( '(c) Copyright 2013 Michal Čihař', '(c) Copyright 2013 Michal Čihař', '' ) ) self.do_test( False, ( '© Copyright 2013 Michal Čihař', '© 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, ( '%d table(s)', '%d table(s)', '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, ('Write [email protected]', 'Write [email protected]', '') ) def test_same_url(self): self.do_test( False, ('https://weblate.org/', 'https://weblate.org/', '') ) self.do_test( True, ('See https://weblate.org/', 'See https://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( False, ('@NAME@: @BOO@', '@NAME@: @BOO@', '') ) self.do_test( True, ('{building}: summary', '{building}: summary', '') ) self.do_test( True, ('@NAME@: long text', '@NAME@: long text', '') ) 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.', '') ) def test_same_alphabet(self): self.do_test( False, ( "!\"#$%%&'()*+,-./0123456789:;<=>?@" "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" "abcdefghijklmnopqrstuvwxyz{|}~", "!\"#$%%&'()*+,-./0123456789:;<=>?@" "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" "abcdefghijklmnopqrstuvwxyz{|}~", '', ) )
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.', '' ) ) def test_same_alphabet(self): self.do_test( False, ( "!\"#$%%&'()*+,-./0123456789:;<=>?@" "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" "abcdefghijklmnopqrstuvwxyz{|}~", "!\"#$%%&'()*+,-./0123456789:;<=>?@" "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" "abcdefghijklmnopqrstuvwxyz{|}~", '', ) )