mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 971272 - Part 2: Expose FileRegistry.required_directories. r=gps
This commit is contained in:
parent
b3c684284a
commit
f52b37797f
@ -134,6 +134,15 @@ class FileRegistry(object):
|
||||
'''
|
||||
return self._files.iteritems()
|
||||
|
||||
def required_directories(self):
|
||||
'''
|
||||
Return the set of directories required by the paths in the container,
|
||||
in no particular order. The returned directories are relative to an
|
||||
unspecified (virtual) root directory (and do not include said root
|
||||
directory).
|
||||
'''
|
||||
return set(k for k, v in self._required_directories.items() if v > 0)
|
||||
|
||||
|
||||
class FileCopyResult(object):
|
||||
"""Represents results of a FileCopier.copy operation."""
|
||||
|
@ -116,6 +116,33 @@ class TestFileRegistry(MatchTestTemplate, unittest.TestCase):
|
||||
self.registry.remove('bar/zot')
|
||||
self.registry.add('bar/zot', GeneratedFile('barzot'))
|
||||
|
||||
def test_required_directories(self):
|
||||
self.registry = FileRegistry()
|
||||
|
||||
self.registry.add('foo', GeneratedFile('foo'))
|
||||
self.assertEqual(self.registry.required_directories(), set())
|
||||
|
||||
self.registry.add('bar/baz', GeneratedFile('barbaz'))
|
||||
self.assertEqual(self.registry.required_directories(), {'bar'})
|
||||
|
||||
self.registry.add('bar/zot', GeneratedFile('barzot'))
|
||||
self.assertEqual(self.registry.required_directories(), {'bar'})
|
||||
|
||||
self.registry.add('bar/zap/zot', GeneratedFile('barzapzot'))
|
||||
self.assertEqual(self.registry.required_directories(), {'bar', 'bar/zap'})
|
||||
|
||||
self.registry.remove('bar/zap/zot')
|
||||
self.assertEqual(self.registry.required_directories(), {'bar'})
|
||||
|
||||
self.registry.remove('bar/baz')
|
||||
self.assertEqual(self.registry.required_directories(), {'bar'})
|
||||
|
||||
self.registry.remove('bar/zot')
|
||||
self.assertEqual(self.registry.required_directories(), set())
|
||||
|
||||
self.registry.add('x/y/z', GeneratedFile('xyz'))
|
||||
self.assertEqual(self.registry.required_directories(), {'x', 'x/y'})
|
||||
|
||||
|
||||
class TestFileCopier(TestWithTmpDir):
|
||||
def all_dirs(self, base):
|
||||
|
Loading…
Reference in New Issue
Block a user