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

Unified Diff: chrome/common/extensions/docs/server2/features_model_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: subdoc rename 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_model_test.py
diff --git a/chrome/common/extensions/docs/server2/features_model_test.py b/chrome/common/extensions/docs/server2/features_model_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..352e7752e7474ff5727a8b5bdbb8663cb1fa4d3c
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/features_model_test.py
@@ -0,0 +1,170 @@
+#!/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_model import FeaturesModel
+
+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'
+ }
+ }
+
+ features_model = FeaturesModel().LoadFeaturesJson(raw_features_json)
+ self.assertEqual(init_json, features_model.Get())
+
+ additional_dict = {
+ 'doc1': {
+ 'documentation': 'http://documentation'
+ },
+ 'doc2': {
+ 'children': {
+ 'sub': {
+ 'name': 'sub'
+ }
+ }
+ },
+ 'doc5': {
+ 'example': {}
+ }
+ }
+
+ expected_merge_result = {
+ 'doc1': {
+ 'documentation': 'http://documentation',
+ 'platform': ['extension', 'app'],
+ 'name': 'doc1'
+ },
+ 'doc2': {
+ 'platform': [],
+ 'name': 'doc2',
+ 'children': {
+ 'sub': {
+ 'name': 'sub'
+ }
+ }
+ },
+ 'doc4': {
+ 'platform': ['extension', 'app'],
+ 'name': 'doc4'
+ },
+ 'doc5': {
+ 'platform': ['extension'],
+ 'name': 'doc5',
+ 'example': {}
+ },
+ 'doc1.sub1': {
+ 'platform': ['app'],
+ 'name': 'doc1.sub1'
+ }
+ }
+
+ features_model = features_model.MergeWith(additional_dict)
+ self.assertEqual(expected_merge_result, features_model.Get())
+
+ 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, features_model.Filter('extension').Get())
+
+ expecting = {
+ 'doc1': {
+ 'documentation': 'http://documentation',
+ 'platform': ['extension', 'app'],
+ 'name': 'doc1',
+ 'children': {
+ 'sub1': {
+ 'name': 'sub1',
+ 'platform': ['app']
+ }
+ }
+ },
+ 'doc2': {
+ 'platform': [],
+ 'name': 'doc2',
+ 'children': {
+ 'sub': {
+ 'name': 'sub'
+ }
+ }
+ },
+ 'doc4': {
+ 'platform': ['extension', 'app'],
+ 'name': 'doc4'
+ },
+ 'doc5': {
+ 'platform': ['extension'],
+ 'name': 'doc5',
+ 'example': {}
+ }
+ }
+
+ self.assertEqual(
+ expecting, features_model.RestructureChildren())
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698