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

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

Issue 10825067: Extensions Docs Server: Apps samples page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import os
7 import unittest
8
9 from zip_file_system import ZipFileSystem
10
11 class FakeFetcher(object):
12 def __init__(self, base_path):
13 self._base_path = base_path
14
15 def _ReadFile(self, filename):
16 with open(os.path.join(self._base_path, filename), 'r') as f:
17 return f.read()
18
19 def Fetch(self, path):
20 if path == 'zipball':
21 return self._ReadFile('file_system.zip')
22 return '[ { "sha": 0 } ]'
23
24 class ZipFileSystemTest(unittest.TestCase):
25 def setUp(self):
26 self._file_system = ZipFileSystem(FakeFetcher('test_data'))
27
28 def testReadFiles(self):
29 expected = {
30 '/test1.txt': 'test1\n',
31 '/test2.txt': 'test2\n',
32 '/test3.txt': 'test3\n',
33 }
34 self.assertEqual(
35 expected,
36 self._file_system.Read(
37 ['/test1.txt', '/test2.txt', '/test3.txt']).Get())
38
39 def testListDir(self):
40 expected = ['dir/']
41 for i in range(7):
42 expected.append('file%d.html' % i)
43 self.assertEqual(expected,
44 sorted(self._file_system.ReadSingle('/list/')))
45
46 if __name__ == '__main__':
47 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698