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

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

Issue 10546078: Extension docs server: APIDataSource (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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import json
7 import os
8 import unittest
9
10 from local_fetcher import LocalFetcher
11 from api_data_source import APIDataSource
12
13 class APIDataSourceTest(unittest.TestCase):
14 def setUp(self):
15 self._base_path = os.path.join('test_data', 'api_data_source')
16
17 def _ReadLocalFile(self, filename):
18 with open(os.path.join(self._base_path, filename), 'r') as f:
19 return f.read()
20
21 def testSimple(self):
22 self._base_path = os.path.join(self._base_path, 'simple')
23 fetcher = LocalFetcher(self._base_path)
24 data_source = APIDataSource(fetcher, ['./'], 0)
25
26 # Take the dict out of the list.
27 expected = json.loads(self._ReadLocalFile('test_file.json'))[0]
28 self.assertEqual(expected, data_source['test_file'])
29 self.assertEqual(expected, data_source['testFile'])
30 self.assertEqual(expected, data_source['testFile.html'])
31
32 self.assertEqual(None, data_source['junk'])
33
34 if __name__ == '__main__':
35 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698