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

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

Issue 23867003: Docserver: Consolidate features caching and access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: let's try this again, shall we? Created 7 years, 2 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 7
8 from manifest_features import CreateManifestFeatures, ConvertDottedKeysToNested 8 from manifest_features import ConvertDottedKeysToNested
9 9
10 class ManifestFeaturesTest(unittest.TestCase): 10 class ManifestFeaturesTest(unittest.TestCase):
11 def testConvertDottedKeysToNested(self): 11 def testConvertDottedKeysToNested(self):
12 docs = { 12 docs = {
13 'doc1.sub2': { 13 'doc1.sub2': {
14 'name': 'doc1.sub2' 14 'name': 'doc1.sub2'
15 }, 15 },
16 'doc1': { 16 'doc1': {
17 'name': 'doc1' 17 'name': 'doc1'
18 }, 18 },
(...skipping 25 matching lines...) Expand all
44 } 44 }
45 } 45 }
46 }, 46 },
47 'doc2': { 47 'doc2': {
48 'name': 'doc2' 48 'name': 'doc2'
49 } 49 }
50 } 50 }
51 51
52 self.assertEqual(expected_docs, ConvertDottedKeysToNested(docs)) 52 self.assertEqual(expected_docs, ConvertDottedKeysToNested(docs))
53 53
54 def testCreateManifestFeatures(self):
55 features_json = {
56 'doc1': { 'extension_types': 'all' },
57 'doc2': { 'extension_types': ['extension', 'package_app'] }
58 }
59
60 manifest_json = {
61 'doc1': { 'example': {} },
62 'doc1.sub1': { 'example': [] }
63 }
64
65 expected = {
66 'doc1': {
67 'name': 'doc1',
68 'example': {},
69 'platforms': ['app', 'extension']
70 },
71 'doc1.sub1': {
72 'example': [],
73 'name': 'doc1.sub1',
74 'platforms': []
75 },
76 'doc2': {
77 'name': 'doc2',
78 'platforms': ['extension']
79 }
80 }
81
82 expected_filtered = {
83 'doc1': {
84 'example': {},
85 'name': 'doc1',
86 'platforms': ['app', 'extension']
87 }
88 }
89
90 self.assertEqual(expected, CreateManifestFeatures(
91 features_json=features_json,
92 manifest_json=manifest_json,
93 filter_platform=None))
94
95 self.assertEqual(expected_filtered, CreateManifestFeatures(
96 features_json=features_json,
97 manifest_json=manifest_json,
98 filter_platform='app'))
99
100 if __name__ == '__main__': 54 if __name__ == '__main__':
101 unittest.main() 55 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698