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

Unified Diff: chrome/common/extensions/docs/server2/compiled_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: Bumpin yaml 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/compiled_file_system_test.py
diff --git a/chrome/common/extensions/docs/server2/compiled_file_system_test.py b/chrome/common/extensions/docs/server2/compiled_file_system_test.py
index f791288ed87d7bd94d015446ba5958a3baf3b53f..e1b930fd358c6deb2e4b3c92fde653b9bac0fc99 100755
--- a/chrome/common/extensions/docs/server2/compiled_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/compiled_file_system_test.py
@@ -200,6 +200,24 @@ class CompiledFileSystemTest(unittest.TestCase):
future.Get()
self.assertTrue(*mock_fs.CheckAndReset(read_count=2, read_resolve_count=3))
+ def testSkipNotFound(self):
+ mock_fs = MockFileSystem(TestFileSystem(_TEST_DATA))
+ compiled_fs = CompiledFileSystem.Factory(
+ ObjectStoreCreator.ForTest()).Create(
+ mock_fs, lambda path, contents: contents, type(self))
+
+ future = compiled_fs.GetFromFile('no_file', skip_not_found=True)
+ # If the file doesn't exist, then the file system is not read.
+ self.assertTrue(*mock_fs.CheckAndReset(read_count=1, stat_count=1))
+ self.assertEqual(None, future.Get())
+ self.assertTrue(*mock_fs.CheckAndReset(read_resolve_count=1))
+ future = compiled_fs.GetFromFile('no_file', skip_not_found=True)
+ self.assertTrue(*mock_fs.CheckAndReset(stat_count=1))
+ self.assertEqual(None, future.Get())
+ # The result for a non-existent file should still be cached.
+ self.assertTrue(*mock_fs.CheckAndReset())
+ future = compiled_fs.GetFromFile('no_file')
+ self.assertRaises(FileNotFoundError, future.Get)
if __name__ == '__main__':
« no previous file with comments | « chrome/common/extensions/docs/server2/compiled_file_system.py ('k') | chrome/common/extensions/docs/server2/cron.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698