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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better redirects 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 from object_store_creator import ObjectStoreCreator
17 import url_constants 17 import url_constants
18 18
19 class GithubFileSystemTest(unittest.TestCase): 19 class GithubFileSystemTest(unittest.TestCase):
20 def setUp(self): 20 def setUp(self):
21 ConfigureFakeFetchers() 21 ConfigureFakeFetchers()
22 self._base_path = os.path.join(sys.path[0], 22 self._base_path = os.path.join(sys.path[0],
23 'test_data', 23 'test_data',
24 'github_file_system') 24 'github_file_system')
25 self._file_system = GithubFileSystem( 25 self._file_system = GithubFileSystem.Create(ObjectStoreCreator.ForTest())
26 AppEngineUrlFetcher(url_constants.GITHUB_URL),
27 AppEngineBlobstore(),
28 ObjectStoreCreator.ForTest())
29 26
30 def _ReadLocalFile(self, filename): 27 def _ReadLocalFile(self, filename):
31 with open(os.path.join(self._base_path, filename), 'r') as f: 28 with open(os.path.join(self._base_path, filename), 'r') as f:
32 return f.read() 29 return f.read()
33 30
34 def testList(self): 31 def testList(self):
35 self.assertEqual(json.loads(self._ReadLocalFile('expected_list.json')), 32 self.assertEqual(json.loads(self._ReadLocalFile('expected_list.json')),
36 self._file_system.Read(['/']).Get()) 33 self._file_system.Read(['/']).Get())
37 34
38 def testRead(self): 35 def testRead(self):
39 self.assertEqual(self._ReadLocalFile('expected_read.txt'), 36 self.assertEqual(self._ReadLocalFile('expected_read.txt'),
40 self._file_system.ReadSingle('/analytics/launch.js')) 37 self._file_system.ReadSingle('/analytics/launch.js'))
41 38
42 def testStat(self): 39 def testStat(self):
43 self.assertEqual(0, self._file_system.Stat('zipball').version) 40 self.assertEqual(0, self._file_system.Stat('zipball').version)
44 41
45 def testKeyGeneration(self): 42 def testKeyGeneration(self):
46 self.assertEqual(0, len(files.GetBlobKeys())) 43 self.assertEqual(0, len(files.GetBlobKeys()))
47 self._file_system.ReadSingle('/analytics/launch.js') 44 self._file_system.ReadSingle('/analytics/launch.js')
48 self.assertEqual(1, len(files.GetBlobKeys())) 45 self.assertEqual(1, len(files.GetBlobKeys()))
49 self._file_system.ReadSingle('/analytics/main.css') 46 self._file_system.ReadSingle('/analytics/main.css')
50 self.assertEqual(1, len(files.GetBlobKeys())) 47 self.assertEqual(1, len(files.GetBlobKeys()))
51 48
52 if __name__ == '__main__': 49 if __name__ == '__main__':
53 unittest.main() 50 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698