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

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

Issue 14856006: Docserver: achieve online vs offline (cron vs instance) behaviour at the object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 | 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 json
7 import os 7 import os
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
11 from appengine_blobstore import AppEngineBlobstore 11 from appengine_blobstore import AppEngineBlobstore
12 from appengine_url_fetcher import AppEngineUrlFetcher 12 from appengine_url_fetcher import AppEngineUrlFetcher
13 from appengine_wrappers import files 13 from appengine_wrappers import files
14 from fake_fetchers import ConfigureFakeFetchers 14 from fake_fetchers import ConfigureFakeFetchers
15 from github_file_system import GithubFileSystem 15 from github_file_system import GithubFileSystem
16 from object_store_creator import ObjectStoreCreator
16 import url_constants 17 import url_constants
17 18
18 class GithubFileSystemTest(unittest.TestCase): 19 class GithubFileSystemTest(unittest.TestCase):
19 def setUp(self): 20 def setUp(self):
20 ConfigureFakeFetchers(os.path.join(sys.path[0], os.pardir)) 21 ConfigureFakeFetchers()
21 self._base_path = os.path.join(sys.path[0], 22 self._base_path = os.path.join(sys.path[0],
22 'test_data', 23 'test_data',
23 'github_file_system') 24 'github_file_system')
24 self._file_system = GithubFileSystem( 25 self._file_system = GithubFileSystem(
25 AppEngineUrlFetcher(url_constants.GITHUB_URL), 26 AppEngineUrlFetcher(url_constants.GITHUB_URL),
26 AppEngineBlobstore()) 27 AppEngineBlobstore(),
28 ObjectStoreCreator.TestFactory())
27 29
28 def _ReadLocalFile(self, filename): 30 def _ReadLocalFile(self, filename):
29 with open(os.path.join(self._base_path, filename), 'r') as f: 31 with open(os.path.join(self._base_path, filename), 'r') as f:
30 return f.read() 32 return f.read()
31 33
32 def testList(self): 34 def testList(self):
33 self.assertEqual(json.loads(self._ReadLocalFile('expected_list.json')), 35 self.assertEqual(json.loads(self._ReadLocalFile('expected_list.json')),
34 self._file_system.Read(['/']).Get()) 36 self._file_system.Read(['/']).Get())
35 37
36 def testRead(self): 38 def testRead(self):
37 self.assertEqual(self._ReadLocalFile('expected_read.txt'), 39 self.assertEqual(self._ReadLocalFile('expected_read.txt'),
38 self._file_system.ReadSingle('/analytics/launch.js')) 40 self._file_system.ReadSingle('/analytics/launch.js'))
39 41
40 def testStat(self): 42 def testStat(self):
41 self.assertEqual(0, self._file_system.Stat('zipball').version) 43 self.assertEqual(0, self._file_system.Stat('zipball').version)
42 44
43 def testKeyGeneration(self): 45 def testKeyGeneration(self):
44 self.assertEqual(0, len(files.GetBlobKeys())) 46 self.assertEqual(0, len(files.GetBlobKeys()))
45 self._file_system.ReadSingle('/analytics/launch.js') 47 self._file_system.ReadSingle('/analytics/launch.js')
46 self.assertEqual(1, len(files.GetBlobKeys())) 48 self.assertEqual(1, len(files.GetBlobKeys()))
47 self._file_system.ReadSingle('/analytics/main.css') 49 self._file_system.ReadSingle('/analytics/main.css')
48 self.assertEqual(1, len(files.GetBlobKeys())) 50 self.assertEqual(1, len(files.GetBlobKeys()))
49 51
50 if __name__ == '__main__': 52 if __name__ == '__main__':
51 unittest.main() 53 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698