Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/host_file_system_provider_test.py |
| diff --git a/chrome/common/extensions/docs/server2/host_file_system_provider_test.py b/chrome/common/extensions/docs/server2/host_file_system_provider_test.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..9c99644b455302bbf67904442620ae62811710ec |
| --- /dev/null |
| +++ b/chrome/common/extensions/docs/server2/host_file_system_provider_test.py |
| @@ -0,0 +1,48 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2013 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from copy import deepcopy |
| +import unittest |
| + |
| +from caching_file_system import CachingFileSystem |
| +from file_system import FileNotFoundError |
| +from host_file_system_provider import HostFileSystemProvider |
| +from object_store_creator import ObjectStoreCreator |
| +from offline_file_system import OfflineFileSystem |
| +from test_data.canned_data import CANNED_API_FILE_SYSTEM_DATA |
| +from test_file_system import TestFileSystem |
| + |
| +class HostFileSystemProviderTest(unittest.TestCase): |
| + def setUp(self): |
| + self._idle_path = 'api/idle.json' |
| + self._canned_data = deepcopy(CANNED_API_FILE_SYSTEM_DATA) |
| + |
| + def _constructor_for_test(self, branch, **optargs): |
| + return TestFileSystem(self._canned_data[branch]) |
| + |
| + def testWithCaching(self): |
| + creator = HostFileSystemProvider( |
| + ObjectStoreCreator.ForTest(), |
|
Jeffrey Yasskin
2013/10/08 17:46:05
If you want git to notice moves (which is helpful
|
| + constructor_for_test=self._constructor_for_test) |
| + |
| + fs = creator.GetBranch('1500') |
| + first_read = fs.ReadSingle(self._idle_path) |
| + self._canned_data['1500']['api']['idle.json'] = 'blah blah blah' |
| + second_read = fs.ReadSingle(self._idle_path) |
| + |
| + self.assertEqual(first_read, second_read) |
| + |
| + def testWithOffline(self): |
| + creator = HostFileSystemProvider( |
| + ObjectStoreCreator.ForTest(), |
| + offline=True, |
| + constructor_for_test=self._constructor_for_test) |
| + |
| + fs = creator.GetBranch('1500') |
| + # Offline file system should raise a FileNotFoundError if read is attempted. |
| + self.assertRaises(FileNotFoundError, fs.ReadSingle, self._idle_path) |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |