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

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

Issue 151883009: Docserver: Make MockFileSystem not iterate over the entire file system as part (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 | Annotate | Revision Log
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 functools 6 import functools
7 import os 7 import os
8 8
9 from appengine_wrappers import GetAppVersion 9 from appengine_wrappers import GetAppVersion
10 from compiled_file_system import CompiledFileSystem 10 from compiled_file_system import CompiledFileSystem
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 compiled_fs.GetFromFileListing( 132 compiled_fs.GetFromFileListing(
133 'apps/deepdir/deeper/').Get()) 133 'apps/deepdir/deeper/').Get())
134 134
135 def testCaching(self): 135 def testCaching(self):
136 compiled_fs = _GetTestCompiledFsCreator()(identity, CompiledFileSystemTest) 136 compiled_fs = _GetTestCompiledFsCreator()(identity, CompiledFileSystemTest)
137 self.assertEqual('404.html contents', 137 self.assertEqual('404.html contents',
138 compiled_fs.GetFromFile('404.html').Get()) 138 compiled_fs.GetFromFile('404.html').Get())
139 self.assertEqual(set(('file.html',)), 139 self.assertEqual(set(('file.html',)),
140 set(compiled_fs.GetFromFileListing('apps/fakedir').Get())) 140 set(compiled_fs.GetFromFileListing('apps/fakedir').Get()))
141 141
142 compiled_fs._file_system._obj['404.html'] = 'boom' 142 compiled_fs._file_system._path_values['404.html'] = 'boom'
143 compiled_fs._file_system._obj['apps']['fakedir']['boom.html'] = 'blam' 143 compiled_fs._file_system._path_values['apps/fakedir/'] = [
144 'file.html', 'boom.html']
144 self.assertEqual('404.html contents', 145 self.assertEqual('404.html contents',
145 compiled_fs.GetFromFile('404.html').Get()) 146 compiled_fs.GetFromFile('404.html').Get())
146 self.assertEqual(set(('file.html',)), 147 self.assertEqual(set(('file.html',)),
147 set(compiled_fs.GetFromFileListing('apps/fakedir').Get())) 148 set(compiled_fs.GetFromFileListing('apps/fakedir').Get()))
148 149
149 compiled_fs._file_system.IncrementStat() 150 compiled_fs._file_system.IncrementStat()
150 self.assertEqual('boom', compiled_fs.GetFromFile('404.html').Get()) 151 self.assertEqual('boom', compiled_fs.GetFromFile('404.html').Get())
151 self.assertEqual(set(('file.html', 'boom.html')), 152 self.assertEqual(set(('file.html', 'boom.html')),
152 set(compiled_fs.GetFromFileListing('apps/fakedir').Get())) 153 set(compiled_fs.GetFromFileListing('apps/fakedir').Get()))
153 154
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 self.assertTrue(*mock_fs.CheckAndReset(stat_count=1, 209 self.assertTrue(*mock_fs.CheckAndReset(stat_count=1,
209 read_count=2, 210 read_count=2,
210 read_resolve_count=1)) 211 read_resolve_count=1))
211 future.Get() 212 future.Get()
212 self.assertTrue(*mock_fs.CheckAndReset(read_count=2, read_resolve_count=3)) 213 self.assertTrue(*mock_fs.CheckAndReset(read_count=2, read_resolve_count=3))
213 214
214 215
215 216
216 if __name__ == '__main__': 217 if __name__ == '__main__':
217 unittest.main() 218 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698