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

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

Issue 512453002: Docserver: Add more skip_not_found support and cache "not found"s (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 ea27048c63a45b69a2ee3e74702d418ea0087df0..e66732d5fe8a955a1d1a662ce6daf22cb516acef 100755
--- a/chrome/common/extensions/docs/server2/caching_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/caching_file_system_test.py
@@ -9,7 +9,7 @@ import unittest
from caching_file_system import CachingFileSystem
from extensions_paths import SERVER2
-from file_system import StatInfo
+from file_system import FileNotFoundError, StatInfo
from local_file_system import LocalFileSystem
from mock_file_system import MockFileSystem
from object_store_creator import ObjectStoreCreator
@@ -159,6 +159,21 @@ class CachingFileSystemTest(unittest.TestCase):
file_system.ReadSingle('bob/bob0').Get())
self.assertTrue(*mock_fs.CheckAndReset())
+ file_system = create_empty_caching_fs()
+ future = file_system.ReadSingle('bob/no_file', skip_not_found=True)
+ self.assertTrue(*mock_fs.CheckAndReset(read_count=1))
+ self.assertEqual(None, future.Get())
+ self.assertTrue(*mock_fs.CheckAndReset(read_resolve_count=1, stat_count=1))
+ future = file_system.ReadSingle('bob/no_file', skip_not_found=True)
+ # There shouldn't be another read/stat from the file system;
+ # we know the file is not there.
+ self.assertTrue(*mock_fs.CheckAndReset())
+ future = file_system.ReadSingle('bob/no_file')
+ # Even though we cached information about non-existent files,
+ # trying to read one without specifiying skip_not_found should
+ # still raise an error.
+ self.assertRaises(FileNotFoundError, future.Get)
not at google - send to devlin 2014/08/26 20:59:34 Nice tests. Is it possible to extend the test to c
ahernandez 2014/08/27 18:54:38 I'm not sure I can do that, because Stat updates a
not at google - send to devlin 2014/08/27 19:22:13 Isn't this line 107 kinda?
ahernandez 2014/08/27 19:29:00 That does increment the stat, but the stat_cache d
not at google - send to devlin 2014/08/27 19:32:49 Ah yes I think you're right, those tests are ... p
+
def testCachedStat(self):
test_fs = TestFileSystem({
'bob': {
@@ -219,20 +234,20 @@ class CachingFileSystemTest(unittest.TestCase):
test_fs.IncrementStat()
run_expecting_stat('1')
- def testSkipNotFound(self):
- caching_fs = self._CreateCachingFileSystem(TestFileSystem({
- 'bob': {
- 'bob0': 'bob/bob0 contents',
- 'bob1': 'bob/bob1 contents'
- }
- }))
- def read_skip_not_found(paths):
- return caching_fs.Read(paths, skip_not_found=True).Get()
- self.assertEqual({}, read_skip_not_found(('grub',)))
- self.assertEqual({}, read_skip_not_found(('bob/bob2',)))
- self.assertEqual({
- 'bob/bob0': 'bob/bob0 contents',
- }, read_skip_not_found(('bob/bob0', 'bob/bob2')))
+ def testSkipNotFound(self):
ahernandez 2014/08/26 20:08:37 This test wasn't even running before because of im
not at google - send to devlin 2014/08/26 20:59:34 Oh man :\ good catch.
+ caching_fs = self._CreateCachingFileSystem(TestFileSystem({
+ 'bob': {
+ 'bob0': 'bob/bob0 contents',
+ 'bob1': 'bob/bob1 contents'
+ }
+ }))
+ def read_skip_not_found(paths):
+ return caching_fs.Read(paths, skip_not_found=True).Get()
+ self.assertEqual({}, read_skip_not_found(('grub',)))
+ self.assertEqual({}, read_skip_not_found(('bob/bob2',)))
+ self.assertEqual({
+ 'bob/bob0': 'bob/bob0 contents',
+ }, read_skip_not_found(('bob/bob0', 'bob/bob2')))
if __name__ == '__main__':

Powered by Google App Engine
This is Rietveld 408576698