Index: chrome/common/extensions/docs/server2/features_utility_test.py |
diff --git a/chrome/common/extensions/docs/server2/features_utility_test.py b/chrome/common/extensions/docs/server2/features_utility_test.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..d04c382524b24e5d34adf1f7379a23e39c06ddf5 |
--- /dev/null |
+++ b/chrome/common/extensions/docs/server2/features_utility_test.py |
@@ -0,0 +1,125 @@ |
+#!/usr/bin/env python |
+# Copyright 2013 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 unittest |
+ |
+from features_utility import ProcessFeaturesFile, MergeDictionaries |
+ |
+class FeaturesUtilityTest(unittest.TestCase): |
+ def testProcessFeaturesFile(self): |
+ raw_features_json = { |
+ 'doc1': { |
+ 'extension_types': ['extension', 'platform_app'] |
+ }, |
+ 'doc2': { |
+ 'extension_types': ['hosted_app', 'packaged_app'] |
+ }, |
+ 'doc3': { |
+ 'whitelist': 'hashhashashhashashhashashhash' |
+ }, |
+ 'doc4': [ |
+ { |
+ 'extension_types': 'all' |
+ }, |
+ { |
+ 'whitelist': 'hashhashashhashashhashashhash' |
+ } |
+ ], |
+ 'doc5': { |
+ 'extension_types': ['extension'] |
+ }, |
+ 'doc1.sub1': { |
+ 'extension_types': ['platform_app', 'hosted_app', 'packaged_app'] |
+ } |
+ } |
+ |
+ expected_json = { |
+ 'doc1': { |
+ 'platform': ['extension', 'app'], |
+ 'name': 'doc1' |
+ }, |
+ 'doc2': { |
+ 'platform': [], |
+ 'name': 'doc2' |
+ }, |
+ 'doc4': { |
+ 'platform': ['extension', 'app'], |
+ 'name': 'doc4' |
+ }, |
+ 'doc5': { |
+ 'platform': ['extension'], |
+ 'name': 'doc5' |
+ }, |
+ 'doc1.sub1': { |
+ 'platform': ['app'], |
+ 'name': 'doc1.sub1' |
+ } |
+ } |
+ |
+ self.assertEqual(expected_json, ProcessFeaturesFile(raw_features_json)) |
+ |
+ def testMergeDictionaries(self): |
+ master_dict = { |
+ 'doc1': { |
+ 'platform': ['app'], |
+ 'name': 'doc1' |
+ }, |
+ 'doc2': { |
+ 'platform': ['app', 'extension'], |
+ 'name': 'doc2' |
+ }, |
+ 'doc4': { |
+ 'platform': [], |
+ 'name': 'doc4' |
+ } |
+ } |
+ |
+ additional_dict = { |
+ 'doc1': { |
+ 'documentation': '/documentation', |
+ 'example': { |
+ 'value': 'hello world' |
+ } |
+ }, |
+ 'doc3': { |
+ 'documentation': '/documentation', |
+ 'platform': ['app'] |
+ }, |
+ 'doc4': { |
+ 'platform': ['app', 'extension'], |
+ 'documentation': '/documentation' |
+ } |
+ } |
+ |
+ expected = { |
+ 'doc1': { |
+ 'documentation': '/documentation', |
+ 'platform': ['app'], |
+ 'name': 'doc1', |
+ 'example': { |
+ 'value': 'hello world' |
+ } |
+ }, |
+ 'doc2': { |
+ 'platform': ['app', 'extension'], |
+ 'name': 'doc2' |
+ }, |
+ 'doc3': { |
+ 'documentation': '/documentation', |
+ 'platform': ['app'] |
+ }, |
+ 'doc4': { |
+ 'documentation': '/documentation', |
+ 'platform': ['app', 'extension'], |
+ 'name': 'doc4' |
+ } |
+ |
+ } |
+ |
+ MergeDictionaries(master_dict, additional_dict) |
+ self.assertEqual(expected, master_dict) |
+ |
+if __name__ == '__main__': |
+ unittest.main() |