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

Unified Diff: chrome/common/extensions/docs/server2/features_utility_test.py

Issue 16410002: Docserver manifest follow up (rewrite) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gen-manifest-try-2
Patch Set: codereview Created 7 years, 5 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/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..014eb44f0724a5ff69a71692f4e0c26835312c93
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/features_utility_test.py
@@ -0,0 +1,171 @@
+#!/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.
+
+from copy import deepcopy
+import unittest
+
+from features_utility import FeatureFile
+
+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']
+ }
+}
+
+class FeaturesUtilityTest(unittest.TestCase):
+ def testFeatureFile(self):
+ init_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'
+ }
+ }
+
+ feature_file = FeatureFile(raw_features_json)
+ self.assertEqual(init_json, feature_file._features)
+
+ additional_dict = {
+ 'doc1': {
+ 'documentation': 'http://documentation'
+ },
+ 'doc2': {
+ 'subdocs': {
+ 'sub': {
+ 'name': 'sub'
+ }
+ }
+ },
+ 'doc5': {
+ 'example': {}
+ }
+ }
+
+ expected_merge_result = {
+ 'doc1': {
+ 'documentation': 'http://documentation',
+ 'platform': ['extension', 'app'],
+ 'name': 'doc1'
+ },
+ 'doc2': {
+ 'platform': [],
+ 'name': 'doc2',
+ 'subdocs': {
+ 'sub': {
+ 'name': 'sub'
+ }
+ }
+ },
+ 'doc4': {
+ 'platform': ['extension', 'app'],
+ 'name': 'doc4'
+ },
+ 'doc5': {
+ 'platform': ['extension'],
+ 'name': 'doc5',
+ 'example': {}
+ },
+ 'doc1.sub1': {
+ 'platform': ['app'],
+ 'name': 'doc1.sub1'
+ }
+ }
+
+ self.assertEqual(
+ expected_merge_result,
+ feature_file.MergeWith(additional_dict)._features)
+
+ expected_filter = {
+ 'doc1': {
+ 'documentation': 'http://documentation',
+ 'platform': ['extension', 'app'],
+ 'name': 'doc1'
+ },
+ 'doc4': {
+ 'platform': ['extension', 'app'],
+ 'name': 'doc4'
+ },
+ 'doc5': {
+ 'platform': ['extension'],
+ 'name': 'doc5',
+ 'example': {}
+ }
+ }
+
+ self.assertEqual(
+ expected_filter, deepcopy(feature_file).Filter('extension')._features)
+
+ expected_with_subdocs = {
+ 'doc1': {
+ 'documentation': 'http://documentation',
+ 'platform': ['extension', 'app'],
+ 'name': 'doc1',
+ 'subdocs': {
+ 'sub1': {
+ 'name': 'sub1',
+ 'platform': ['app']
+ }
+ }
+ },
+ 'doc2': {
+ 'platform': [],
+ 'name': 'doc2',
+ 'subdocs': {
+ 'sub': {
+ 'name': 'sub'
+ }
+ }
+ },
+ 'doc4': {
+ 'platform': ['extension', 'app'],
+ 'name': 'doc4'
+ },
+ 'doc5': {
+ 'platform': ['extension'],
+ 'name': 'doc5',
+ 'example': {}
+ }
+ }
+
+ self.assertEqual(expected_with_subdocs, feature_file.InsertSubDocs())
+ self.assertTrue(feature_file._features is None)
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698