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

Side by Side 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: manifest follow up (rewrite) Created 7 years, 4 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import unittest
7
8 from features_utility import ProcessFeaturesFile, MergeDictionaries
9
10 class FeaturesUtilityTest(unittest.TestCase):
11 def testProcessFeaturesFile(self):
12 raw_features_json = {
13 'doc1': {
14 'extension_types': ['extension', 'platform_app']
15 },
16 'doc2': {
17 'extension_types': ['hosted_app', 'packaged_app']
18 },
19 'doc3': {
20 'whitelist': 'hashhashashhashashhashashhash'
21 },
22 'doc4': [
23 {
24 'extension_types': 'all'
25 },
26 {
27 'whitelist': 'hashhashashhashashhashashhash'
28 }
29 ],
30 'doc5': {
31 'extension_types': ['extension']
32 },
33 'doc1.sub1': {
34 'extension_types': ['platform_app', 'hosted_app', 'packaged_app']
35 }
36 }
37
38 expected_json = {
39 'doc1': {
40 'platform': ['extension', 'app'],
41 'name': 'doc1'
42 },
43 'doc2': {
44 'platform': [],
45 'name': 'doc2'
46 },
47 'doc4': {
48 'platform': ['extension', 'app'],
49 'name': 'doc4'
50 },
51 'doc5': {
52 'platform': ['extension'],
53 'name': 'doc5'
54 },
55 'doc1.sub1': {
56 'platform': ['app'],
57 'name': 'doc1.sub1'
58 }
59 }
60
61 self.assertEqual(expected_json, ProcessFeaturesFile(raw_features_json))
62
63 def testMergeDictionaries(self):
64 master_dict = {
65 'doc1': {
66 'platform': ['app'],
67 'name': 'doc1'
68 },
69 'doc2': {
70 'platform': ['app', 'extension'],
71 'name': 'doc2'
72 },
73 'doc4': {
74 'platform': [],
75 'name': 'doc4'
76 }
77 }
78
79 additional_dict = {
80 'doc1': {
81 'documentation': '/documentation',
82 'example': {
83 'value': 'hello world'
84 }
85 },
86 'doc3': {
87 'documentation': '/documentation',
88 'platform': ['app']
89 },
90 'doc4': {
91 'platform': ['app', 'extension'],
92 'documentation': '/documentation'
93 }
94 }
95
96 expected = {
97 'doc1': {
98 'documentation': '/documentation',
99 'platform': ['app'],
100 'name': 'doc1',
101 'example': {
102 'value': 'hello world'
103 }
104 },
105 'doc2': {
106 'platform': ['app', 'extension'],
107 'name': 'doc2'
108 },
109 'doc3': {
110 'documentation': '/documentation',
111 'platform': ['app']
112 },
113 'doc4': {
114 'documentation': '/documentation',
115 'platform': ['app', 'extension'],
116 'name': 'doc4'
117 }
118
119 }
120
121 MergeDictionaries(master_dict, additional_dict)
122 self.assertEqual(expected, master_dict)
123
124 if __name__ == '__main__':
125 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698