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

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

Issue 1151283007: Docserver overhaul: Gitiles away from me. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove inform_users template to fix presubmit failure (it's now a redirect) Created 5 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 os 6 import os
7 import sys 7 import sys
8 import unittest 8 import unittest
9 9
10 from caching_file_system import CachingFileSystem 10 from caching_file_system import CachingFileSystem
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 # All data should be cached. 285 # All data should be cached.
286 self.assertTrue(*mock_fs.CheckAndReset()) 286 self.assertTrue(*mock_fs.CheckAndReset())
287 287
288 # Starting from a different root should still pull cached data. 288 # Starting from a different root should still pull cached data.
289 for walkinfo in file_system.Walk('root/dir1/'): 289 for walkinfo in file_system.Walk('root/dir1/'):
290 pass 290 pass
291 self.assertTrue(*mock_fs.CheckAndReset()) 291 self.assertTrue(*mock_fs.CheckAndReset())
292 # TODO(ahernandez): Test with a new instance CachingFileSystem so a 292 # TODO(ahernandez): Test with a new instance CachingFileSystem so a
293 # different object store is utilized. 293 # different object store is utilized.
294 294
295 def testVersionedStat(self):
296 test_fs = TestFileSystem({
297 'bob': {
298 'bob0': 'bob/bob0 contents',
299 'bob1': 'bob/bob1 contents'
300 }
301 })
302
303 # Create a versioned FileSystem and verify that multiple CachingFileSystem
304 # instances wrapping it will share the same stat cache.
305 mock_fs = MockFileSystem(test_fs)
306 mock_fs.SetVersion('abcdefg')
307
308 def run_and_expect_stat_count(paths, stat_count=0):
309 file_system = self._CreateCachingFileSystem(mock_fs, start_empty=True)
310 [file_system.Stat(path) for path in paths]
311 self.assertTrue(*mock_fs.CheckAndReset(stat_count=stat_count))
312
313 run_and_expect_stat_count(['bob/', 'bob/bob0', 'bob/bob1'], stat_count=1)
314 run_and_expect_stat_count(['bob/', 'bob/bob0', 'bob/bob1'], stat_count=0)
315 295
316 if __name__ == '__main__': 296 if __name__ == '__main__':
317 unittest.main() 297 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698