Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/common/extensions/docs/server2/file_system_test.py

Issue 453713002: Docserver: Generate a table of extension/app API owners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mlg rebasing Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 7
8 from test_file_system import TestFileSystem 8 from test_file_system import TestFileSystem
9 9
10 file_system = TestFileSystem({ 10 file_system = TestFileSystem({
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 all_files = [] 52 all_files = []
53 all_dirs = [] 53 all_dirs = []
54 for root, dirs, files in file_system.Walk(''): 54 for root, dirs, files in file_system.Walk(''):
55 if not root: root = '^' 55 if not root: root = '^'
56 all_files += [root + '/' + name for name in files] 56 all_files += [root + '/' + name for name in files]
57 all_dirs += [root + '/' + name for name in dirs] 57 all_dirs += [root + '/' + name for name in dirs]
58 58
59 self.assertEqual(sorted(expected_files), sorted(all_files)) 59 self.assertEqual(sorted(expected_files), sorted(all_files))
60 self.assertEqual(sorted(expected_dirs), sorted(all_dirs)) 60 self.assertEqual(sorted(expected_dirs), sorted(all_dirs))
61 61
62 def testWalkDepth(self):
63 all_dirs = []
64 all_files = []
65 for root, dirs, files in file_system.Walk('', depth=0):
66 all_dirs.extend(dirs)
67 all_files.extend(files)
68 self.assertEqual([], all_dirs)
69 self.assertEqual([], all_files)
70
71 for root, dirs, files in file_system.Walk('', depth=1):
72 all_dirs.extend(dirs)
73 all_files.extend(files)
74 self.assertEqual(['templates/'], all_dirs)
75 self.assertEqual(['file.txt'], all_files)
76
77 all_dirs = []
78 all_files = []
79 for root, dirs, files in file_system.Walk('', depth=2):
80 all_dirs.extend(dirs)
81 all_files.extend(files)
82 self.assertEqual(sorted(['templates/', 'public/', 'json/']),
83 sorted(all_dirs))
84 self.assertEqual(sorted(['file.txt', 'README']), sorted(all_files))
85
86
62 def testSubWalk(self): 87 def testSubWalk(self):
63 expected_files = set([ 88 expected_files = set([
64 '/redirects.json', 89 '/redirects.json',
65 'apps/404.html', 90 'apps/404.html',
66 'apps/a11y.html', 91 'apps/a11y.html',
67 'extensions/404.html', 92 'extensions/404.html',
68 'extensions/cookies.html' 93 'extensions/cookies.html'
69 ]) 94 ])
70 95
71 all_files = set() 96 all_files = set()
(...skipping 23 matching lines...) Expand all
95 self.assertTrue(exists('templates/README')) 120 self.assertTrue(exists('templates/README'))
96 self.assertFalse(exists('templates/README/')) 121 self.assertFalse(exists('templates/README/'))
97 self.assertTrue(exists('templates/public/redirects.json')) 122 self.assertTrue(exists('templates/public/redirects.json'))
98 self.assertFalse(exists('templates/public/redirects.json/')) 123 self.assertFalse(exists('templates/public/redirects.json/'))
99 self.assertTrue(exists('templates/public/apps/a11y.html')) 124 self.assertTrue(exists('templates/public/apps/a11y.html'))
100 self.assertFalse(exists('templates/public/apps/a11y.html/')) 125 self.assertFalse(exists('templates/public/apps/a11y.html/'))
101 126
102 127
103 if __name__ == '__main__': 128 if __name__ == '__main__':
104 unittest.main() 129 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/file_system.py ('k') | chrome/common/extensions/docs/server2/owners_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698