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

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

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments - Patch currently being broken up Created 7 years, 6 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 (c) 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 json
7 import os
8 import unittest
9
10 from availability_finder import AvailabilityFinder
11 from branch_utility import BranchUtility
12 from compiled_file_system import CompiledFileSystem
13 from fake_fetchers import ConfigureFakeFetchers
14 from object_store_creator import ObjectStoreCreator
15 from test_file_system import TestFileSystem
16 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES)
17
18 def _LoadJSON(name, mode='rb'):
19 return json.load(
20 open(os.path.join('test_data', 'availability_finder', name), mode))
21
22 def _CreateFileSystem(version):
23 branch = _GetBranchForVersion(version)
24 return TestFileSystem(CANNED_API_FILE_SYSTEM_DATA[str(branch)])
25
26 def _GetBranchForVersion(version):
27 return CANNED_BRANCHES[version]
28
29 class AvailabilityFinderTest(unittest.TestCase):
30 def setUp(self):
31 ConfigureFakeFetchers()
32 self._avail_ds_factory = AvailabilityFinder.Factory(
33 ObjectStoreCreator.ForTest(),
34 CompiledFileSystem.Factory(
35 TestFileSystem(CANNED_API_FILE_SYSTEM_DATA['trunk']),
36 ObjectStoreCreator.ForTest()),
37 BranchUtility.Create(ObjectStoreCreator.ForTest()),
38 _CreateFileSystem)
39 self._avail_ds = self._avail_ds_factory.Create()
40
41 def testGetApiAvailability(self):
42 self.assertEqual('stable',
43 self._avail_ds.GetApiAvailability('earlyAPI1').channel)
44 self.assertEqual('10',
45 self._avail_ds.GetApiAvailability('earlyAPI1').version)
46 self.assertEqual('trunk',
47 self._avail_ds.GetApiAvailability('earlyAPI2').channel)
48 self.assertEqual(None,
49 self._avail_ds.GetApiAvailability('earlyAPI2').version)
50 self.assertEquals('stable',
51 self._avail_ds.GetApiAvailability('tabs').channel)
52 self.assertEquals(18,
53 self._avail_ds.GetApiAvailability('tabs').version)
54 self.assertEquals('stable',
55 self._avail_ds.GetApiAvailability('bookmarks').channel)
56 self.assertEquals(21,
57 self._avail_ds.GetApiAvailability('bookmarks').version)
58 self.assertEquals('stable',
59 self._avail_ds.GetApiAvailability('windows').channel)
60 self.assertEquals(23,
61 self._avail_ds.GetApiAvailability('windows').version)
62 self.assertEquals('dev',
63 self._avail_ds.GetApiAvailability('storage').channel)
64 self.assertEquals(28,
65 self._avail_ds.GetApiAvailability('storage').version)
66 self.assertEquals('stable',
67 self._avail_ds.GetApiAvailability('alarms').channel)
68 self.assertEquals(24,
69 self._avail_ds.GetApiAvailability('alarms').version)
70 self.assertEquals('trunk',
71 self._avail_ds.GetApiAvailability('sync').channel)
72 self.assertEquals('trunk',
73 self._avail_ds.GetApiAvailability('sync').version)
74 self.assertEquals('dev',
75 self._avail_ds.GetApiAvailability('cookies').channel)
76 self.assertEquals(28,
77 self._avail_ds.GetApiAvailability('cookies').version)
78 self.assertEquals('trunk',
79 self._avail_ds.GetApiAvailability('notReallyBetaAPI').version)
80 self.assertEquals('trunk',
81 self._avail_ds.GetApiAvailability('trunkAPI').channel)
82 self.assertEquals('trunk',
83 self._avail_ds.GetApiAvailability('trunkAPI').version)
84 self.assertEquals('dev',
85 self._avail_ds.GetApiAvailability('notifications').channel)
86 self.assertEquals(28,
87 self._avail_ds.GetApiAvailability('notifications').version)
88 self.assertEquals('trunk',
89 self._avail_ds.GetApiAvailability('contextMenus').channel)
90 self.assertEquals('trunk',
91 self._avail_ds.GetApiAvailability('contextMenus').version)
92 self.assertEquals('beta',
93 self._avail_ds.GetApiAvailability('systemInfo.cpu').channel)
94 self.assertEquals(27,
95 self._avail_ds.GetApiAvailability('systemInfo.cpu').version)
96 self.assertEquals('stable',
97 self._avail_ds.GetApiAvailability('systemInfo.display').channel)
98 self.assertEquals(23,
99 self._avail_ds.GetApiAvailability('systemInfo.display').version)
100 self.assertEquals('stable',
101 self._avail_ds.GetApiAvailability('menus').channel)
102 self.assertEquals(6,
103 self._avail_ds.GetApiAvailability('menus').version)
104 self.assertEquals('stable',
105 self._avail_ds.GetApiAvailability('idle').channel)
106 self.assertEquals(5,
107 self._avail_ds.GetApiAvailability('idle').version)
108
109 if __name__ == '__main__':
110 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/availability_finder.py ('k') | chrome/common/extensions/docs/server2/branch_utility.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698