| Index: chrome/common/extensions/docs/server2/file_system_test.py
|
| diff --git a/chrome/common/extensions/docs/server2/file_system_test.py b/chrome/common/extensions/docs/server2/file_system_test.py
|
| index dc2d8364df15842ec24d16679ae335756f822469..116f12dcab87f05105d4491c065b0b8079dd2958 100755
|
| --- a/chrome/common/extensions/docs/server2/file_system_test.py
|
| +++ b/chrome/common/extensions/docs/server2/file_system_test.py
|
| @@ -8,7 +8,9 @@ import unittest
|
| from test_file_system import TestFileSystem
|
|
|
| file_system = TestFileSystem({
|
| + 'file.txt': '',
|
| 'templates': {
|
| + 'README': '',
|
| 'public': {
|
| 'apps': {
|
| '404.html': '',
|
| @@ -28,31 +30,34 @@ file_system = TestFileSystem({
|
|
|
| class FileSystemTest(unittest.TestCase):
|
| def testWalk(self):
|
| - expected_files = set([
|
| + expected_files = [
|
| + '^/file.txt',
|
| + 'templates/README',
|
| 'templates/public/apps/404.html',
|
| 'templates/public/apps/a11y.html',
|
| 'templates/public/extensions/404.html',
|
| 'templates/public/extensions/cookies.html',
|
| 'templates/public/redirects.json',
|
| 'templates/json/manifest.json'
|
| - ])
|
| + ]
|
|
|
| - expected_dirs = set([
|
| - '/templates/',
|
| + expected_dirs = [
|
| + '^/templates/',
|
| 'templates/public/',
|
| 'templates/public/apps/',
|
| 'templates/public/extensions/',
|
| 'templates/json/'
|
| - ])
|
| + ]
|
|
|
| - all_files = set()
|
| - all_dirs = set()
|
| + all_files = []
|
| + all_dirs = []
|
| for root, dirs, files in file_system.Walk(''):
|
| - all_files.update(root + '/' + name for name in files)
|
| - all_dirs.update(root + '/' + name for name in dirs)
|
| + if not root: root = '^'
|
| + all_files += [root + '/' + name for name in files]
|
| + all_dirs += [root + '/' + name for name in dirs]
|
|
|
| - self.assertEqual(expected_files, all_files)
|
| - self.assertEqual(expected_dirs, all_dirs)
|
| + self.assertEqual(sorted(expected_files), sorted(all_files))
|
| + self.assertEqual(sorted(expected_dirs), sorted(all_dirs))
|
|
|
| def testSubWalk(self):
|
| expected_files = set([
|
| @@ -64,10 +69,36 @@ class FileSystemTest(unittest.TestCase):
|
| ])
|
|
|
| all_files = set()
|
| - for root, dirs, files in file_system.Walk('templates/public'):
|
| + for root, dirs, files in file_system.Walk('templates/public/'):
|
| all_files.update(root + '/' + name for name in files)
|
|
|
| self.assertEqual(expected_files, all_files)
|
|
|
| + def testExists(self):
|
| + def exists(path):
|
| + return file_system.Exists(path).Get()
|
| +
|
| + # Root directory.
|
| + self.assertTrue(exists(''))
|
| +
|
| + # Directories (are not files).
|
| + self.assertFalse(exists('templates'))
|
| + self.assertTrue(exists('templates/'))
|
| + self.assertFalse(exists('templates/public'))
|
| + self.assertTrue(exists('templates/public/'))
|
| + self.assertFalse(exists('templates/public/apps'))
|
| + self.assertTrue(exists('templates/public/apps/'))
|
| +
|
| + # Files (are not directories).
|
| + self.assertTrue(exists('file.txt'))
|
| + self.assertFalse(exists('file.txt/'))
|
| + self.assertTrue(exists('templates/README'))
|
| + self.assertFalse(exists('templates/README/'))
|
| + self.assertTrue(exists('templates/public/redirects.json'))
|
| + self.assertFalse(exists('templates/public/redirects.json/'))
|
| + self.assertTrue(exists('templates/public/apps/a11y.html'))
|
| + self.assertFalse(exists('templates/public/apps/a11y.html/'))
|
| +
|
| +
|
| if __name__ == '__main__':
|
| unittest.main()
|
|
|