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

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

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: add executable bits for tests Created 7 years, 7 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import unittest
7
8 from chained_compiled_file_system import ChainedCompiledFileSystem
9 from compiled_file_system import CompiledFileSystem
10 from object_store_creator import ObjectStoreCreator
11 from test_file_system import TestFileSystem
12
13 _TEST_DATA_BASE = {
14 'a.txt': 'base a.txt',
15 'dir': {
16 'b.txt': 'base b.txt'
17 },
18 }
19
20 _TEST_DATA_NEW = {
21 'a.txt': 'new a.txt',
22 'new.txt': 'a new file',
23 'dir': {
24 'b.txt': 'new b.txt',
25 'new.txt': 'new file in dir',
26 },
27 }
28
29 class ChainedCompiledFileSystemTest(unittest.TestCase):
30 def setUp(self):
31 self._object_store_creator = ObjectStoreCreator(
32 'chained', start_empty=False)
33 self._base_object_store_creator = ObjectStoreCreator(
34 'base', start_empty=False)
35 base_file_system = TestFileSystem(_TEST_DATA_BASE)
36 self._base_factory = CompiledFileSystem.Factory(
37 base_file_system,
38 self._base_object_store_creator)
39 self._file_system = TestFileSystem(_TEST_DATA_NEW)
40 self._patched_factory = CompiledFileSystem.Factory(
41 self._file_system,
42 self._object_store_creator)
43 self._chained_factory = ChainedCompiledFileSystem.Factory(
44 [(self._patched_factory, self._file_system),
45 (self._base_factory, base_file_system)])
46 self._base_compiled_fs = self._base_factory.CreateIdentity(TestFileSystem)
47 self._chained_compiled_fs = self._chained_factory.CreateIdentity(
48 TestFileSystem)
49
50 def testGetFromFile(self):
51 self.assertEqual(self._chained_compiled_fs.GetFromFile('a.txt'),
52 self._base_compiled_fs.GetFromFile('a.txt'))
53 self.assertEqual(self._chained_compiled_fs.GetFromFile('new.txt'),
54 'a new file')
55 self.assertEqual(self._chained_compiled_fs.GetFromFile('dir/new.txt'),
56 'new file in dir')
57 self._file_system.IncrementStat('a.txt')
58 self.assertNotEqual(self._chained_compiled_fs.GetFromFile('a.txt'),
59 self._base_compiled_fs.GetFromFile('a.txt'))
60 self.assertEqual(self._chained_compiled_fs.GetFromFile('a.txt'),
61 self._file_system.ReadSingle('a.txt'))
62
63 def testGetFromFileListing(self):
64 self.assertEqual(self._chained_compiled_fs.GetFromFile('dir/'),
65 self._base_compiled_fs.GetFromFile('dir/'))
66 self._file_system.IncrementStat('dir/')
67 self.assertNotEqual(self._chained_compiled_fs.GetFromFileListing('dir/'),
68 self._base_compiled_fs.GetFromFileListing('dir/'))
69 self.assertEqual(self._chained_compiled_fs.GetFromFileListing('dir/'),
70 self._file_system.ReadSingle('dir/'))
71
72 if __name__ == '__main__':
73 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698