示例#1
0
 def test_partial_l10n(self):
     cfg = ProjectConfig(None)
     cfg.set_locales(['de', 'fr'])
     cfg.add_paths({'l10n': self.path('/{locale}/major/*')}, {
         'l10n': self.path('/{locale}/minor/*'),
         'locales': ['de']
     })
     mocks = [
         self.path(leaf) for leaf in [
             '/de/major/good.ftl',
             '/de/major/not/subdir/bad.ftl',
             '/de/minor/good.ftl',
             '/fr/major/good.ftl',
             '/fr/major/not/subdir/bad.ftl',
             '/fr/minor/good.ftl',
         ]
     ]
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(list(files), [
         (self.path('/de/major/good.ftl'), None, None, set()),
         (self.path('/de/minor/good.ftl'), None, None, set()),
     ])
     self.assertTupleEqual(
         files.match(self.path('/de/major/some.ftl')),
         (self.path('/de/major/some.ftl'), None, None, set()))
     self.assertIsNone(files.match(self.path('/de/other/some.ftl')))
     # 'fr' is not in the locale list of minor, should only return major
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(list(files), [
         (self.path('/fr/major/good.ftl'), None, None, set()),
     ])
     self.assertIsNone(files.match(self.path('/fr/minor/some.ftl')))
示例#2
0
 def test_l10n_path(self):
     cfg = ProjectConfig(None)
     cfg.add_environment(l10n_base=self.root)
     cfg.set_locales(['de'])
     cfg.add_paths({'l10n': '{l10n_base}/{locale}/*'})
     mocks = [
         self.path(leaf) for leaf in (
             '/de/good.ftl',
             '/de/not/subdir/bad.ftl',
             '/fr/good.ftl',
             '/fr/not/subdir/bad.ftl',
         )
     ]
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(list(files),
                          [(self.path('/de/good.ftl'), None, None, set())])
     self.assertTupleEqual(files.match(self.path('/de/good.ftl')),
                           (self.path('/de/good.ftl'), None, None, set()))
     self.assertIsNone(files.match(self.path('/fr/something.ftl')))
     files = MockProjectFiles(mocks, 'de', [cfg], mergebase='merging')
     self.assertListEqual(
         list(files),
         [(self.path('/de/good.ftl'), None, 'merging/de/good.ftl', set())])
     self.assertTupleEqual(files.match(self.path('/de/something.ftl')),
                           (self.path('/de/something.ftl'), None,
                            'merging/de/something.ftl', set()))
     # 'fr' is not in the locale list, should return no files
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(list(files), [])
示例#3
0
 def test_validation_mode(self):
     cfg = ProjectConfig()
     cfg.add_environment(l10n_base='/tmp/l10n')
     cfg.locales.append('de')
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/*',
         'reference': '/tmp/reference/*'
     })
     mocks = {
         '/tmp/l10n/de/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/l10n/fr/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/reference/': [
             'ref.ftl',
             'not/subdir/bad.ftl'
         ],
     }
     # `None` switches on validation mode
     files = MockProjectFiles(mocks, None, [cfg])
     self.assertListEqual(
         list(files),
         [
             ('/tmp/reference/ref.ftl', '/tmp/reference/ref.ftl', None,
              set()),
         ])
示例#4
0
 def test_single_reference_path(self):
     cfg = ProjectConfig(None)
     cfg.add_environment(l10n_base=self.path('/l10n'))
     cfg.set_locales(['de'])
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/good.ftl',
         'reference': self.path('/reference/good.ftl')
     })
     mocks = [
         self.path('/reference/good.ftl'),
         self.path('/reference/not/subdir/bad.ftl'),
     ]
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(list(files), [
         (self.path('/l10n/de/good.ftl'), self.path('/reference/good.ftl'),
          None, set()),
     ])
     self.assertTupleEqual(
         files.match(self.path('/reference/good.ftl')),
         (self.path('/l10n/de/good.ftl'), self.path('/reference/good.ftl'),
          None, set()),
     )
     self.assertTupleEqual(
         files.match(self.path('/l10n/de/good.ftl')),
         (self.path('/l10n/de/good.ftl'), self.path('/reference/good.ftl'),
          None, set()),
     )
示例#5
0
 def test_l10n_path(self):
     cfg = ProjectConfig()
     cfg.add_environment(l10n_base='/tmp')
     cfg.locales.append('de')
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/*'
     })
     mocks = {
         '/tmp/de/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/fr/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
     }
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files), [('/tmp/de/good.ftl', None, None, set())])
     self.assertTupleEqual(
         files.match('/tmp/de/something.ftl'),
         ('/tmp/de/something.ftl', None, None, set()))
     self.assertIsNone(files.match('/tmp/fr/something.ftl'))
     files = MockProjectFiles(mocks, 'de', [cfg], mergebase='merging')
     self.assertListEqual(
         list(files),
         [('/tmp/de/good.ftl', None, 'merging/de/good.ftl', set())])
     self.assertTupleEqual(
         files.match('/tmp/de/something.ftl'),
         ('/tmp/de/something.ftl', None, 'merging/de/something.ftl', set()))
     # 'fr' is not in the locale list, should return no files
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(list(files), [])
示例#6
0
 def test_l10n_path(self):
     cfg = ProjectConfig()
     cfg.locales.append('de')
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/*'
     })
     cfg.add_environment(l10n_base='/tmp')
     mocks = {
         '/tmp/de/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/fr/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
     }
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files), [('/tmp/de/good.ftl', None, None, set())])
     self.assertTupleEqual(
         files.match('/tmp/de/something.ftl'),
         ('/tmp/de/something.ftl', None, None, set()))
     self.assertIsNone(files.match('/tmp/fr/something.ftl'))
     files = MockProjectFiles(mocks, 'de', [cfg], mergebase='merging')
     self.assertListEqual(
         list(files),
         [('/tmp/de/good.ftl', None, 'merging/de/good.ftl', set())])
     self.assertTupleEqual(
         files.match('/tmp/de/something.ftl'),
         ('/tmp/de/something.ftl', None, 'merging/de/something.ftl', set()))
     # 'fr' is not in the locale list, should return no files
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(list(files), [])
示例#7
0
 def test_single_reference_path(self):
     cfg = ProjectConfig(None)
     cfg.add_environment(l10n_base=self.path('/l10n'))
     cfg.set_locales(['de'])
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/good.ftl',
         'reference': self.path('/reference/good.ftl')
     })
     mocks = [
         self.path('/reference/good.ftl'),
         self.path('/reference/not/subdir/bad.ftl'),
     ]
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files),
         [
             (self.path('/l10n/de/good.ftl'),
              self.path('/reference/good.ftl'),
              None,
              set()),
         ])
     self.assertTupleEqual(
         files.match(self.path('/reference/good.ftl')),
         (self.path('/l10n/de/good.ftl'),
          self.path('/reference/good.ftl'),
          None,
          set()),
         )
     self.assertTupleEqual(
         files.match(self.path('/l10n/de/good.ftl')),
         (self.path('/l10n/de/good.ftl'),
          self.path('/reference/good.ftl'),
          None,
          set()),
         )
示例#8
0
 def test_validation_mode(self):
     cfg = ProjectConfig(None)
     cfg.add_environment(l10n_base=self.path('/l10n'))
     cfg.set_locales(['de'])
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/*',
         'reference': self.path('/reference/*')
     })
     mocks = [
         self.path(leaf)
         for leaf in [
             '/l10n/de/good.ftl',
             '/l10n/de/not/subdir/bad.ftl',
             '/l10n/fr/good.ftl',
             '/l10n/fr/not/subdir/bad.ftl',
             '/reference/ref.ftl',
             '/reference/not/subdir/bad.ftl',
         ]
     ]
     # `None` switches on validation mode
     files = MockProjectFiles(mocks, None, [cfg])
     self.assertListEqual(
         list(files),
         [
             (self.path('/reference/ref.ftl'),
              self.path('/reference/ref.ftl'),
              None,
              set()),
         ])
示例#9
0
 def test_validation_mode(self):
     cfg = ProjectConfig(None)
     cfg.add_environment(l10n_base=self.path('/l10n'))
     cfg.locales.append('de')
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/*',
         'reference': self.path('/reference/*')
     })
     mocks = [
         self.path(leaf)
         for leaf in [
             '/l10n/de/good.ftl',
             '/l10n/de/not/subdir/bad.ftl',
             '/l10n/fr/good.ftl',
             '/l10n/fr/not/subdir/bad.ftl',
             '/reference/ref.ftl',
             '/reference/not/subdir/bad.ftl',
         ]
     ]
     # `None` switches on validation mode
     files = MockProjectFiles(mocks, None, [cfg])
     self.assertListEqual(
         list(files),
         [
             (self.path('/reference/ref.ftl'),
              self.path('/reference/ref.ftl'),
              None,
              set()),
         ])
示例#10
0
 def test_paths(self):
     one = ProjectConfig('one.toml')
     one.set_locales(['ab'])
     one.add_paths({'l10n': '/tmp/somedir/{locale}/**'})
     other = ProjectConfig('one.toml')
     self.assertFalse(one.same(other))
     other.add_paths({'l10n': '/tmp/somedir/{locale}/**'})
     self.assertTrue(one.same(other))
示例#11
0
 def test_locales_in_paths(self):
     pc = ProjectConfig(None)
     child = ProjectConfig(None)
     child.add_paths({
         'l10n': '/tmp/somedir/{locale}/toolkit/**',
         'locales': ['it']
     })
     child.set_locales([])
     pc.add_child(child)
     self.assertListEqual(pc.all_locales, ['it'])
     pc.set_locales(['de', 'fr'])
     self.assertListEqual(pc.all_locales, ['de', 'fr', 'it'])
示例#12
0
 def test_paths(self):
     one = ProjectConfig('one.toml')
     one.set_locales(['ab'])
     one.add_paths({
         'l10n': '/tmp/somedir/{locale}/**'
     })
     other = ProjectConfig('one.toml')
     self.assertFalse(one.same(other))
     other.add_paths({
         'l10n': '/tmp/somedir/{locale}/**'
     })
     self.assertTrue(one.same(other))
示例#13
0
 def test_locales_in_paths(self):
     pc = ProjectConfig(None)
     child = ProjectConfig(None)
     child.add_paths({
         'l10n': '/tmp/somedir/{locale}/toolkit/**',
         'locales': ['it']
     })
     child.set_locales([])
     pc.add_child(child)
     self.assertListEqual(pc.all_locales, ['it'])
     pc.set_locales(['de', 'fr'])
     self.assertListEqual(pc.all_locales, ['de', 'fr', 'it'])
示例#14
0
 def test_partial_l10n(self):
     cfg = ProjectConfig()
     cfg.locales.extend(['de', 'fr'])
     cfg.add_paths({
         'l10n': '/tmp/{locale}/major/*'
     }, {
         'l10n': '/tmp/{locale}/minor/*',
         'locales': ['de']
     })
     mocks = {
         '/tmp/de/major/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/de/minor/': [
             'good.ftl',
         ],
         '/tmp/fr/major/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/fr/minor/': [
             'good.ftl',
         ],
     }
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files),
         [
             ('/tmp/de/major/good.ftl', None, None, set()),
             ('/tmp/de/minor/good.ftl', None, None, set()),
         ])
     self.assertTupleEqual(
         files.match('/tmp/de/major/some.ftl'),
         ('/tmp/de/major/some.ftl', None, None, set()))
     self.assertIsNone(files.match('/tmp/de/other/some.ftl'))
     # 'fr' is not in the locale list of minor, should only return major
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(
         list(files),
         [
             ('/tmp/fr/major/good.ftl', None, None, set()),
         ])
     self.assertIsNone(files.match('/tmp/fr/minor/some.ftl'))
示例#15
0
 def test_partial_l10n(self):
     cfg = ProjectConfig()
     cfg.locales.extend(['de', 'fr'])
     cfg.add_paths({
         'l10n': '/tmp/{locale}/major/*'
     }, {
         'l10n': '/tmp/{locale}/minor/*',
         'locales': ['de']
     })
     mocks = {
         '/tmp/de/major/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/de/minor/': [
             'good.ftl',
         ],
         '/tmp/fr/major/': [
             'good.ftl',
             'not/subdir/bad.ftl'
         ],
         '/tmp/fr/minor/': [
             'good.ftl',
         ],
     }
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files),
         [
             ('/tmp/de/major/good.ftl', None, None, set()),
             ('/tmp/de/minor/good.ftl', None, None, set()),
         ])
     self.assertTupleEqual(
         files.match('/tmp/de/major/some.ftl'),
         ('/tmp/de/major/some.ftl', None, None, set()))
     self.assertIsNone(files.match('/tmp/de/other/some.ftl'))
     # 'fr' is not in the locale list of minor, should only return major
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(
         list(files),
         [
             ('/tmp/fr/major/good.ftl', None, None, set()),
         ])
     self.assertIsNone(files.match('/tmp/fr/minor/some.ftl'))
示例#16
0
 def test_l10n_path(self):
     cfg = ProjectConfig(None)
     cfg.add_environment(l10n_base=self.root)
     cfg.set_locales(['de'])
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/*'
     })
     mocks = [
         self.path(leaf)
         for leaf in (
             '/de/good.ftl',
             '/de/not/subdir/bad.ftl',
             '/fr/good.ftl',
             '/fr/not/subdir/bad.ftl',
         )
     ]
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files),
         [
             (self.path('/de/good.ftl'), None, None, set())
         ]
     )
     self.assertTupleEqual(
         files.match(self.path('/de/good.ftl')),
         (self.path('/de/good.ftl'), None, None, set())
     )
     self.assertIsNone(files.match(self.path('/fr/something.ftl')))
     files = MockProjectFiles(mocks, 'de', [cfg], mergebase='merging')
     self.assertListEqual(
         list(files),
         [
             (self.path('/de/good.ftl'), None, 'merging/de/good.ftl', set())
         ]
     )
     self.assertTupleEqual(
         files.match(self.path('/de/something.ftl')),
         (self.path('/de/something.ftl'),
          None,
          'merging/de/something.ftl',
          set()))
     # 'fr' is not in the locale list, should return no files
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(list(files), [])
示例#17
0
 def test_partial_l10n(self):
     cfg = ProjectConfig(None)
     cfg.set_locales(['de', 'fr'])
     cfg.add_paths({
         'l10n': self.path('/{locale}/major/*')
     }, {
         'l10n': self.path('/{locale}/minor/*'),
         'locales': ['de']
     })
     mocks = [
         self.path(leaf)
         for leaf in [
             '/de/major/good.ftl',
             '/de/major/not/subdir/bad.ftl',
             '/de/minor/good.ftl',
             '/fr/major/good.ftl',
             '/fr/major/not/subdir/bad.ftl',
             '/fr/minor/good.ftl',
         ]
     ]
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files),
         [
             (self.path('/de/major/good.ftl'), None, None, set()),
             (self.path('/de/minor/good.ftl'), None, None, set()),
         ])
     self.assertTupleEqual(
         files.match(self.path('/de/major/some.ftl')),
         (self.path('/de/major/some.ftl'), None, None, set()))
     self.assertIsNone(files.match(self.path('/de/other/some.ftl')))
     # 'fr' is not in the locale list of minor, should only return major
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(
         list(files),
         [
             (self.path('/fr/major/good.ftl'), None, None, set()),
         ])
     self.assertIsNone(files.match(self.path('/fr/minor/some.ftl')))
示例#18
0
 def test_reference_path(self):
     cfg = ProjectConfig(None)
     cfg.add_environment(l10n_base=self.path('/l10n'))
     cfg.locales.append('de')
     cfg.add_paths({
         'l10n': '{l10n_base}/{locale}/*',
         'reference': self.path('/reference/*')
     })
     mocks = [
         self.path(leaf)
         for leaf in [
             '/l10n/de/good.ftl',
             '/l10n/de/not/subdir/bad.ftl',
             '/l10n/fr/good.ftl',
             '/l10n/fr/not/subdir/bad.ftl',
             '/reference/ref.ftl',
             '/reference/not/subdir/bad.ftl',
         ]
     ]
     files = MockProjectFiles(mocks, 'de', [cfg])
     self.assertListEqual(
         list(files),
         [
             (self.path('/l10n/de/good.ftl'),
              self.path('/reference/good.ftl'),
              None,
              set()),
             (self.path('/l10n/de/ref.ftl'),
              self.path('/reference/ref.ftl'),
              None,
              set()),
         ])
     self.assertTupleEqual(
         files.match(self.path('/l10n/de/good.ftl')),
         (self.path('/l10n/de/good.ftl'),
          self.path('/reference/good.ftl'),
          None,
          set()),
         )
     self.assertTupleEqual(
         files.match(self.path('/reference/good.ftl')),
         (self.path('/l10n/de/good.ftl'),
          self.path('/reference/good.ftl'),
          None,
          set()),
         )
     self.assertIsNone(files.match(self.path('/l10n/de/subdir/bad.ftl')))
     self.assertIsNone(files.match(self.path('/reference/subdir/bad.ftl')))
     files = MockProjectFiles(mocks, 'de', [cfg], mergebase='merging')
     self.assertListEqual(
         list(files),
         [
             (self.path('/l10n/de/good.ftl'),
              self.path('/reference/good.ftl'),
              'merging/de/good.ftl', set()),
             (self.path('/l10n/de/ref.ftl'),
              self.path('/reference/ref.ftl'),
              'merging/de/ref.ftl', set()),
         ])
     self.assertTupleEqual(
         files.match(self.path('/l10n/de/good.ftl')),
         (self.path('/l10n/de/good.ftl'),
          self.path('/reference/good.ftl'),
          'merging/de/good.ftl', set()),
         )
     self.assertTupleEqual(
         files.match(self.path('/reference/good.ftl')),
         (self.path('/l10n/de/good.ftl'),
          self.path('/reference/good.ftl'),
          'merging/de/good.ftl', set()),
         )
     # 'fr' is not in the locale list, should return no files
     files = MockProjectFiles(mocks, 'fr', [cfg])
     self.assertListEqual(list(files), [])