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.
8 from features_utility
import Parse
, Filtered
, MergedWith
10 class FeaturesUtilityTest(unittest
.TestCase
):
11 def testFromJson(self
):
14 'extension_types': ['extension', 'platform_app']
17 'extension_types': ['hosted_app', 'packaged_app']
20 'whitelist': 'hashhashashhashashhashashhash'
23 { 'extension_types': 'all' },
24 { 'whitelist': 'hashhashashhashashhashashhash' }
27 'extension_types': ['extension']
30 'extension_types': ['platform_app', 'hosted_app', 'packaged_app']
36 'platforms': ['apps', 'extensions'],
44 'platforms': ['apps', 'extensions'],
48 'platforms': ['extensions'],
52 'platforms': ['apps'],
57 self
.assertEqual(expected
, Parse(raw_features_json
))
61 'doc1': { 'platforms': ['apps'] },
62 'doc2': { 'platforms': ['extensions'] },
63 'doc3': { 'platforms': ['apps', 'extensions'] },
64 'doc4': { 'platforms': [] }
67 apps_names
= set(('doc1', 'doc3'))
68 extension_names
= set(('doc2', 'doc3'))
71 apps_names
, set(Filtered(unfiltered
, 'apps').keys()))
73 extension_names
, set(Filtered(unfiltered
, 'extensions').keys()))
75 def testMergeFeatures(self
):
88 'platforms': ['extensions']
94 'platforms': ['extensions', 'apps']
101 'platforms': ['extensions']
109 'platforms': ['extensions', 'apps']
113 self
.assertEqual(expected
, MergedWith(features
, other
))
115 if __name__
== '__main__':