Beispiel #1
0
 def test_whitespace(self):
     unit = MockUnit(source=u'Foo\n')
     fix = SameBookendingWhitespace()
     self.assertEqual(fix.fix_target(['Bar'], unit), ([u'Bar\n'], True))
     self.assertEqual(fix.fix_target(['Bar\n'], unit), ([u'Bar\n'], False))
     unit = MockUnit(source=u' ')
     self.assertEqual(fix.fix_target(['  '], unit), (['  '], False))
Beispiel #2
0
 def test_translate(self):
     machine_translation = DummyTranslation()
     self.assertEqual(
         machine_translation.translate('cs', 'Hello', MockUnit(), None), [])
     self.assertEqual(
         len(
             machine_translation.translate('cs', 'Hello, world!',
                                           MockUnit(), None)), 2)
Beispiel #3
0
 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'), 0))
     self.assertFalse(
         self.check.check_single('some long text is here',
                                 'some long text is here',
                                 MockUnit(code='de',
                                          comment='Tag: screen'), 0))
 def test_extended_formatting(self):
     self.assertFalse(
         self.check.check_single(
             u'Value: {{ something.value | currency }}',
             u'Wert: {{ something.value | currency }}',
             MockUnit('angularjs_format', flags='angularjs-format')))
     self.assertTrue(
         self.check.check_single(
             u'Value: {{ something.value | currency }}',
             u'Value: {{ something.value }}',
             MockUnit('angularjs_format', flags='angularjs-format')))
Beispiel #5
0
 def test_fmtsourcediff(self):
     unit = MockUnit(source='Hello word!')
     self.assertEqual(
         fmtsourcediff('Hello world!', unit),
         u'<span lang="en" dir="ltr" class="direction">'
         'Hello wor<del>l</del>d!'
         '</span>')
 def test_different_whitespace(self):
     self.assertFalse(self.check.check_single(
         u'{{ name   }} string',
         u'{{name}} string',
         MockUnit('angularjs_different_whitespace',
                  flags='angularjs-format')
     ))
 def test_format_ignore_position(self):
     self.assertFalse(self.check.check_single(
         u'{{name}} string {{other}}',
         u'{{other}} string {{name}}',
         MockUnit('angularjs_format_ignore_position',
                  flags='angularjs-format')
     ))
Beispiel #8
0
 def test_same_english(self):
     self.assertFalse(
         self.check.check_single(
             'source',
             'source',
             MockUnit(code='en'),
         ))
Beispiel #9
0
 def test_controlchars(self):
     unit = MockUnit(source='Foo\x1b')
     fix = RemoveControlChars()
     self.assertEqual(fix.fix_target(['Bar'], unit), (['Bar'], False))
     self.assertEqual(fix.fix_target(['Bar\x1b'], unit),
                      (['Bar\x1b'], False))
     self.assertEqual(fix.fix_target(['Bar\n'], unit), (['Bar\n'], False))
Beispiel #10
0
 def test_failing(self):
     self.assertTrue(
         self.check.check_source(
             ['text...'],
             MockUnit(),
         )
     )
Beispiel #11
0
 def test_good(self):
     self.assertFalse(
         self.check.check_source(
             ['text…'],
             MockUnit(),
         )
     )
Beispiel #12
0
 def test_hit(self):
     self.assertTrue(
         self.check.check_target(
             ['string', 'plural'],
             ['string', 'string'],
             MockUnit('plural_partial_empty'),
         ))
Beispiel #13
0
 def test_plural(self):
     self.assertFalse(
         self.check.check_source(
             ['text', 'texts'],
             MockUnit(),
         )
     )
Beispiel #14
0
 def test_none(self):
     self.assertFalse(
         self.check.check_target(
             ['string'],
             ['string'],
             MockUnit('plural_none'),
         ))
Beispiel #15
0
 def test_empty(self):
     self.assertFalse(
         self.check.check_target(
             ['string', 'plural'],
             ['', ''],
             MockUnit('plural_empty'),
         ))
Beispiel #16
0
 def test_none(self):
     self.assertFalse(
         self.check.check_source(
             ['text'],
             MockUnit(),
         )
     )
Beispiel #17
0
 def test_good(self):
     self.assertFalse(
         self.check.check_target(
             ['string', 'plural'],
             ['translation', 'trplural'],
             MockUnit('plural_good'),
         ))
Beispiel #18
0
 def test_format_diff(self):
     unit = MockUnit(source='Hello word!')
     self.assertEqual(
         format_translation(
             unit.source,
             unit.translation.subproject.project.source_language,
             diff='Hello world!',
         )['items'][0]['content'], u'Hello wor<del>l</del>d!')
Beispiel #19
0
 def test_locale_delimiter(self):
     self.assertFalse(self.check.check_format(
         u'lines: %6.3f',
         u'radky: %\'6.3f',
         MockUnit('c_locale_delimiter'),
         0,
         False
     ))
Beispiel #20
0
 def test_no_format(self):
     self.assertFalse(self.check.check_format(
         'strins',
         'string',
         MockUnit('python_brace_no_format'),
         0,
         False
     ))
Beispiel #21
0
 def test_wrong_format(self):
     self.assertTrue(self.check.check_format(
         u'%s string',
         u'%c string',
         MockUnit('python_wrong_format'),
         0,
         False
     ))
Beispiel #22
0
 def test_named_format(self):
     self.assertFalse(self.check.check_format(
         u'{s1} string {s2}',
         u'{s1} string {s2}',
         MockUnit('python_brace_named_format'),
         0,
         False
     ))
Beispiel #23
0
 def test_named_format(self):
     self.assertFalse(self.check.check_format(
         u'%(name)s string',
         u'%(name)s string',
         MockUnit('python_named_format'),
         0,
         False
     ))
Beispiel #24
0
 def test_percent_format(self):
     self.assertFalse(self.check.check_format(
         u'%d%% string',
         u'%d%% string',
         MockUnit('python_percent_format'),
         0,
         False
     ))
Beispiel #25
0
 def test_wrong_attribute_format(self):
     self.assertTrue(self.check.check_format(
         u'{s.foo} string',
         u'{s.bar} string',
         MockUnit('python_brace_wrong_attribute_format'),
         0,
         False
     ))
Beispiel #26
0
 def test_escaping(self):
     self.assertFalse(self.check.check_format(
         u'{{ string }}',
         u'string',
         MockUnit('python_brace_escaping'),
         0,
         False
     ))
Beispiel #27
0
 def test_wrong_format(self):
     self.assertTrue(self.check.check_format(
         u'{s} string',
         u'{c} string',
         MockUnit('python_brace_wrong_format'),
         0,
         False
     ))
Beispiel #28
0
 def test_missing_named_format_ignore(self):
     self.assertFalse(self.check.check_format(
         u'%(name)s string',
         u'string',
         MockUnit('python_missing_named_format'),
         0,
         True
     ))
Beispiel #29
0
 def test_missing_named_format(self):
     self.assertTrue(self.check.check_format(
         u'{s1} string',
         u'string',
         MockUnit('python_brace_missing_named_format'),
         0,
         False
     ))
Beispiel #30
0
 def test_position_format(self):
     self.assertFalse(self.check.check_format(
         u'{} string {}',
         u'{} string {}',
         MockUnit('python_brace_position_format'),
         0,
         False
     ))