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

Unified 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: FetcherCache 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/api_data_source_test.py
diff --git a/chrome/common/extensions/docs/server2/api_data_source_test.py b/chrome/common/extensions/docs/server2/api_data_source_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..3724140f57704b0a9e4615372adf6745f24594c5
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/api_data_source_test.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import os
+import unittest
+
+from fetcher_cache import FetcherCache
+from local_fetcher import LocalFetcher
+from api_data_source import APIDataSource
+
+class APIDataSourceTest(unittest.TestCase):
+ def setUp(self):
+ self._base_path = os.path.join('test_data', 'api_data_source')
+
+ def _ReadLocalFile(self, filename):
+ with open(os.path.join(self._base_path, filename), 'r') as f:
+ return f.read()
+
+ def testSimple(self):
+ self._base_path = os.path.join(self._base_path, 'simple')
+ fetcher = LocalFetcher(self._base_path)
+ cache_builder = FetcherCache.Builder(fetcher, 0)
+ data_source = APIDataSource(cache_builder, ['./'])
+
+ # Take the dict out of the list.
+ expected = json.loads(self._ReadLocalFile('test_file.json'))[0]
+ self.assertEqual(expected, data_source['test_file'])
+ self.assertEqual(expected, data_source['testFile'])
+ self.assertEqual(expected, data_source['testFile.html'])
+
+ self.assertEqual(None, data_source['junk'])
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698