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

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

Issue 10828235: Extensions Docs Server: Efficient MemcacheFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 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 unified diff | Download patch | Annotate | Revision Log
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 json
6 import os 7 import os
7 import unittest 8 import unittest
8 9
9 from fake_url_fetcher import FakeUrlFetcher 10 from fake_url_fetcher import FakeUrlFetcher
10 from subversion_file_system import SubversionFileSystem 11 from subversion_file_system import SubversionFileSystem
11 12
12 class SubversionFileSystemTest(unittest.TestCase): 13 class SubversionFileSystemTest(unittest.TestCase):
13 def setUp(self): 14 def setUp(self):
14 fetcher = FakeUrlFetcher(os.path.join('test_data', 'file_system')) 15 self._base_path = os.path.join('test_data', 'file_system')
15 self._file_system = SubversionFileSystem(fetcher) 16 fetcher = FakeUrlFetcher(self._base_path)
17 self._file_system = SubversionFileSystem(fetcher, fetcher)
18
19 def _ReadLocalFile(self, filename):
20 with open(os.path.join(self._base_path, filename), 'r') as f:
21 return f.read()
16 22
17 def testReadFiles(self): 23 def testReadFiles(self):
18 expected = { 24 expected = {
19 'test1.txt': 'test1\n', 25 'test1.txt': 'test1\n',
20 'test2.txt': 'test2\n', 26 'test2.txt': 'test2\n',
21 'test3.txt': 'test3\n', 27 'test3.txt': 'test3\n',
22 } 28 }
23 self.assertEqual( 29 self.assertEqual(
24 expected, 30 expected,
25 self._file_system.Read(['test1.txt', 'test2.txt', 'test3.txt']).Get()) 31 self._file_system.Read(['test1.txt', 'test2.txt', 'test3.txt']).Get())
26 32
27 def testListDir(self): 33 def testListDir(self):
28 expected = ['dir/'] 34 expected = ['dir/']
29 for i in range(7): 35 for i in range(7):
30 expected.append('file%d.html' % i) 36 expected.append('file%d.html' % i)
31 self.assertEqual(expected, 37 self.assertEqual(expected,
32 sorted(self._file_system.ReadSingle('list/'))) 38 sorted(self._file_system.ReadSingle('list/')))
33 39
34 def testStat(self): 40 def testStat(self):
35 # Value is hard-coded into FakeUrlFetcher. 41 stat_info = self._file_system.Stat('stat/')
36 self.assertEqual(0, self._file_system.Stat('list/dir/').version) 42 self.assertEquals('151113', stat_info.version)
43 self.assertEquals(json.loads(self._ReadLocalFile('stat_result.json')),
44 stat_info.child_versions)
37 45
38 if __name__ == '__main__': 46 if __name__ == '__main__':
39 unittest.main() 47 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698