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 sys 8 import posixpath 9 import unittest 10 11 from extensions_paths import SERVER2 12 from local_file_system import LocalFileSystem 13 14 15 class LocalFileSystemTest(unittest.TestCase): 16 def setUp(self): 17 self._file_system = LocalFileSystem.Create( 18 SERVER2, 'test_data', 'file_system/') 19 20 def testReadFiles(self): 21 expected = { 22 'test1.txt': 'test1\n', 23 'test2.txt': 'test2\n', 24 'test3.txt': 'test3\n', 25 } 26 self.assertEqual( 27 expected, 28 self._file_system.Read(['test1.txt', 'test2.txt', 'test3.txt']).Get()) 29 30 def testListDir(self): 31 expected = ['dir/'] 32 for i in range(7): 33 expected.append('file%d.html' % i) 34 self.assertEqual(expected, 35 sorted(self._file_system.ReadSingle('list/').Get())) 36 37 38 if __name__ == '__main__': 39 unittest.main() 40