Enable Enterprise enrollment on desktop builds.
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / api_categorizer_test.py
blobbdbbc51c69c269a3678e8da68a3a9b16b03da7c3
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 import unittest
7 from api_categorizer import APICategorizer
8 from compiled_file_system import CompiledFileSystem
9 from extensions_paths import CHROME_EXTENSIONS
10 from object_store_creator import ObjectStoreCreator
11 from test_file_system import TestFileSystem
14 def _ToTestData(obj):
15 '''Transforms |obj| into test data by turning a list of files into an object
16 mapping that file to its contents (derived from its name).
17 '''
18 return dict((name, name) for name in obj)
21 _TEST_DATA = {
22 'api': {
23 '_api_features.json': '{}',
24 '_manifest_features.json': '{}',
25 '_permission_features.json': '{}',
27 'docs': {
28 'templates': {
29 'json': {
30 'api_availabilities.json': '{}',
31 'manifest.json': '{}',
32 'permissions.json': '{}',
34 'public': {
35 'apps': _ToTestData([
36 'alarms.html',
37 'app_window.html',
38 'experimental_bluetooth.html',
39 'experimental_power.html',
40 'storage.html',
41 'sockets_udp.html'
42 ]),
43 'extensions': _ToTestData([
44 'alarms.html',
45 'browserAction.html',
46 'experimental_history.html',
47 'experimental_power.html',
48 'infobars.html',
49 'storage.html',
50 'sockets_udp.html'
51 ]),
58 class APICategorizerTest(unittest.TestCase):
59 def setUp(self):
60 self._api_categorizer = APICategorizer(
61 TestFileSystem(_TEST_DATA, relative_to=CHROME_EXTENSIONS),
62 CompiledFileSystem.Factory(ObjectStoreCreator.ForTest()))
64 def testGetAPICategory(self):
65 get_category = self._api_categorizer.GetCategory
66 self.assertEqual('chrome', get_category('apps', 'alarms'))
67 self.assertEqual('chrome', get_category('extensions', 'alarms'))
68 self.assertEqual('private', get_category('apps', 'musicManagerPrivate'))
69 self.assertEqual('private', get_category('extensions', 'notDocumentedApi'))
70 self.assertEqual('experimental',
71 get_category('apps', 'experimental.bluetooth'))
72 self.assertEqual('experimental',
73 get_category('extensions', 'experimental.history'))
76 if __name__ == '__main__':
77 unittest.main()