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

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

Issue 10577022: Extensions Docs Server: HandlebarDictGenerator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 unittest 8 import unittest
9 9
10 from fetcher_cache import FetcherCache 10 from fetcher_cache import FetcherCache
11 from local_fetcher import LocalFetcher 11 from local_fetcher import LocalFetcher
12 from api_data_source import APIDataSource 12 from api_data_source import APIDataSource
13 13
14 class TestAPIDataSource(APIDataSource):
15 def _LoadAPI(self, api):
16 return json.loads(api)[0]
17
14 class APIDataSourceTest(unittest.TestCase): 18 class APIDataSourceTest(unittest.TestCase):
15 def setUp(self): 19 def setUp(self):
16 self._base_path = os.path.join('test_data', 'api_data_source') 20 self._base_path = os.path.join('test_data', 'api_data_source')
17 21
18 def _ReadLocalFile(self, filename): 22 def _ReadLocalFile(self, filename):
19 with open(os.path.join(self._base_path, filename), 'r') as f: 23 with open(os.path.join(self._base_path, filename), 'r') as f:
20 return f.read() 24 return f.read()
21 25
22 def testSimple(self): 26 def testSimple(self):
23 self._base_path = os.path.join(self._base_path, 'simple') 27 self._base_path = os.path.join(self._base_path, 'simple')
24 fetcher = LocalFetcher(self._base_path) 28 fetcher = LocalFetcher(self._base_path)
25 cache_builder = FetcherCache.Builder(fetcher, 0) 29 cache_builder = FetcherCache.Builder(fetcher, 0)
26 data_source = APIDataSource(cache_builder, ['./']) 30 data_source = TestAPIDataSource(cache_builder, ['./'])
27 31
28 # Take the dict out of the list. 32 # Take the dict out of the list.
29 expected = json.loads(self._ReadLocalFile('test_file.json'))[0] 33 expected = json.loads(self._ReadLocalFile('test_file.json'))[0]
not at google - send to devlin 2012/06/19 20:33:10 Could you modify "expected" here rather than overr
cduvall 2012/06/19 22:21:02 Done.
30 self.assertEqual(expected, data_source['test_file']) 34 self.assertEqual(expected, data_source['test_file'])
31 self.assertEqual(expected, data_source['testFile']) 35 self.assertEqual(expected, data_source['testFile'])
32 self.assertEqual(expected, data_source['testFile.html']) 36 self.assertEqual(expected, data_source['testFile.html'])
33 37
34 self.assertEqual(None, data_source['junk']) 38 self.assertEqual(None, data_source['junk'])
35 39
36 if __name__ == '__main__': 40 if __name__ == '__main__':
37 unittest.main() 41 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698