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

Unified Diff: chrome/common/extensions/docs/server2/caching_file_system_test.py

Issue 521453003: Docserver: Override Walk in CachingFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/caching_file_system_test.py
diff --git a/chrome/common/extensions/docs/server2/caching_file_system_test.py b/chrome/common/extensions/docs/server2/caching_file_system_test.py
index 78becf1a8dc9c8e35f567662cdae3b73dc266bda..bc12ffb2959bb7ddfc0a30e0efabd9fe22accd28 100755
--- a/chrome/common/extensions/docs/server2/caching_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/caching_file_system_test.py
@@ -251,6 +251,44 @@ class CachingFileSystemTest(unittest.TestCase):
'bob/bob0': 'bob/bob0 contents',
}, read_skip_not_found(('bob/bob0', 'bob/bob2')))
+ def testWalkCaching(self):
+ test_fs = TestFileSystem({
+ 'root': {
+ 'file1': 'file1',
+ 'file2': 'file2',
+ 'dir1': {
+ 'dir1_file1': 'dir1_file1',
+ 'dir2': {},
+ 'dir3': {
+ 'dir3_file1': 'dir3_file1',
+ 'dir3_file2': 'dir3_file2'
+ }
+ }
+ }
+ })
+ mock_fs = MockFileSystem(test_fs)
+ file_system = self._CreateCachingFileSystem(mock_fs, start_empty=True)
+ for walkinfo in file_system.Walk(''):
+ pass
+ self.assertTrue(*mock_fs.CheckAndReset(
+ read_resolve_count=5, read_count=5, stat_count=5))
+
+ all_dirs, all_files = [], []
+ for root, dirs, files in file_system.Walk(''):
+ all_dirs.extend(dirs)
+ all_files.extend(files)
+ self.assertEqual(sorted(['root/', 'dir1/', 'dir2/', 'dir3/']),
+ sorted(all_dirs))
+ self.assertEqual(
+ sorted(['file1', 'file2', 'dir1_file1', 'dir3_file1', 'dir3_file2']),
+ sorted(all_files))
+ # All data should be cached.
+ self.assertTrue(*mock_fs.CheckAndReset())
+
+ # Starting from a different root should still pull cached data.
+ for walkinfo in file_system.Walk('root/dir1/'):
+ pass
+ self.assertTrue(*mock_fs.CheckAndReset())
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698