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

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

Issue 13470005: Refactor the devserver to make it easier to control caching (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cduvall, rebase Created 7 years, 8 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 in_memory_object_store import InMemoryObjectStore 16 from in_memory_object_store import InMemoryObjectStore
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(os.path.join(sys.path[0], os.pardir)) 21 ConfigureFakeFetchers(os.path.join(sys.path[0], os.pardir))
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(
26 AppEngineUrlFetcher(url_constants.GITHUB_URL), 26 AppEngineUrlFetcher(url_constants.GITHUB_URL),
27 InMemoryObjectStore('github'),
28 AppEngineBlobstore()) 27 AppEngineBlobstore())
29 28
30 def _ReadLocalFile(self, filename): 29 def _ReadLocalFile(self, filename):
31 with open(os.path.join(self._base_path, filename), 'r') as f: 30 with open(os.path.join(self._base_path, filename), 'r') as f:
32 return f.read() 31 return f.read()
33 32
34 def testList(self): 33 def testList(self):
35 self.assertEqual(json.loads(self._ReadLocalFile('expected_list.json')), 34 self.assertEqual(json.loads(self._ReadLocalFile('expected_list.json')),
36 self._file_system.Read(['/']).Get()) 35 self._file_system.Read(['/']).Get())
37 36
38 def testRead(self): 37 def testRead(self):
39 self.assertEqual(self._ReadLocalFile('expected_read.txt'), 38 self.assertEqual(self._ReadLocalFile('expected_read.txt'),
40 self._file_system.ReadSingle('/analytics/launch.js')) 39 self._file_system.ReadSingle('/analytics/launch.js'))
41 40
42 def testStat(self): 41 def testStat(self):
43 self.assertEqual(0, self._file_system.Stat('zipball').version) 42 self.assertEqual(0, self._file_system.Stat('zipball').version)
44 43
45 def testKeyGeneration(self): 44 def testKeyGeneration(self):
46 self.assertEqual(0, len(files.GetBlobKeys())) 45 self.assertEqual(0, len(files.GetBlobKeys()))
47 self._file_system.ReadSingle('/analytics/launch.js') 46 self._file_system.ReadSingle('/analytics/launch.js')
48 self.assertEqual(1, len(files.GetBlobKeys())) 47 self.assertEqual(1, len(files.GetBlobKeys()))
49 self._file_system.ReadSingle('/analytics/main.css') 48 self._file_system.ReadSingle('/analytics/main.css')
50 self.assertEqual(1, len(files.GetBlobKeys())) 49 self.assertEqual(1, len(files.GetBlobKeys()))
51 50
52 if __name__ == '__main__': 51 if __name__ == '__main__':
53 unittest.main() 52 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/github_file_system.py ('k') | chrome/common/extensions/docs/server2/handler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698