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

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

Issue 26418002: Docserver: Pull knowledge of host file systems into a single (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: jeffrey 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 | Annotate | Revision Log
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 import json 5 import json
6 6
7 import os 7 import os
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
11 from availability_finder import AvailabilityFinder 11 from availability_finder import AvailabilityFinder
12 from api_schema_graph import LookupResult 12 from api_schema_graph import LookupResult
13 from branch_utility import BranchUtility 13 from branch_utility import BranchUtility
14 from compiled_file_system import CompiledFileSystem 14 from compiled_file_system import CompiledFileSystem
15 from fake_url_fetcher import FakeUrlFetcher 15 from fake_url_fetcher import FakeUrlFetcher
16 from host_file_system_iterator import HostFileSystemIterator 16 from host_file_system_iterator import HostFileSystemIterator
17 from object_store_creator import ObjectStoreCreator 17 from object_store_creator import ObjectStoreCreator
18 from test_file_system import TestFileSystem 18 from test_file_system import TestFileSystem
19 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES) 19 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES)
20 from test_data.object_level_availability.tabs import TABS_SCHEMA_BRANCHES 20 from test_data.object_level_availability.tabs import TABS_SCHEMA_BRANCHES
21 21
22 22
23 class FakeHostFileSystemCreator(object): 23 class FakeHostFileSystemProvider(object):
24 24
25 def __init__(self, file_system_data): 25 def __init__(self, file_system_data):
26 self._file_system_data = file_system_data 26 self._file_system_data = file_system_data
27 27
28 def Create(self, branch): 28 def GetTrunk(self):
29 return self.GetBranch('trunk')
30
31 def GetBranch(self, branch):
29 return TestFileSystem(self._file_system_data[str(branch)]) 32 return TestFileSystem(self._file_system_data[str(branch)])
30 33
31 34
32 class AvailabilityFinderTest(unittest.TestCase): 35 class AvailabilityFinderTest(unittest.TestCase):
33 36
34 def setUp(self): 37 def setUp(self):
35 self._branch_utility = BranchUtility( 38 self._branch_utility = BranchUtility(
36 os.path.join('branch_utility', 'first.json'), 39 os.path.join('branch_utility', 'first.json'),
37 os.path.join('branch_utility', 'second.json'), 40 os.path.join('branch_utility', 'second.json'),
38 FakeUrlFetcher(os.path.join(sys.path[0], 'test_data')), 41 FakeUrlFetcher(os.path.join(sys.path[0], 'test_data')),
39 ObjectStoreCreator.ForTest()) 42 ObjectStoreCreator.ForTest())
40 43
41 def create_availability_finder(file_system_data): 44 def create_availability_finder(file_system_data):
42 fake_host_fs_creator = FakeHostFileSystemCreator(file_system_data) 45 fake_host_fs_creator = FakeHostFileSystemProvider(file_system_data)
43 fake_host_fs = fake_host_fs_creator.Create('trunk') 46 return AvailabilityFinder(HostFileSystemIterator(fake_host_fs_creator,
44 return AvailabilityFinder(HostFileSystemIterator( 47 self._branch_utility),
45 fake_host_fs_creator,
46 fake_host_fs,
47 self._branch_utility),
48 ObjectStoreCreator.ForTest(), 48 ObjectStoreCreator.ForTest(),
49 self._branch_utility, 49 self._branch_utility,
50 fake_host_fs) 50 fake_host_fs_creator.GetTrunk())
51 51
52 self._avail_finder = create_availability_finder(CANNED_API_FILE_SYSTEM_DATA) 52 self._avail_finder = create_availability_finder(CANNED_API_FILE_SYSTEM_DATA)
53 self._node_avail_finder = create_availability_finder(TABS_SCHEMA_BRANCHES) 53 self._node_avail_finder = create_availability_finder(TABS_SCHEMA_BRANCHES)
54 54
55 def testGetApiAvailability(self): 55 def testGetApiAvailability(self):
56 # Key: Using 'channel' (i.e. 'beta') to represent an availability listing 56 # Key: Using 'channel' (i.e. 'beta') to represent an availability listing
57 # for an API in a _features.json file, and using |channel| (i.e. |dev|) to 57 # for an API in a _features.json file, and using |channel| (i.e. |dev|) to
58 # represent the development channel, or phase of development, where an API's 58 # represent the development channel, or phase of development, where an API's
59 # availability is being checked. 59 # availability is being checked.
60 60
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 self.assertEqual(LookupResult(False, None), 284 self.assertEqual(LookupResult(False, None),
285 availability_graph.Lookup('functions')) 285 availability_graph.Lookup('functions'))
286 self.assertEqual(LookupResult(False, None), 286 self.assertEqual(LookupResult(False, None),
287 availability_graph.Lookup('events', 'onActivated', 287 availability_graph.Lookup('events', 'onActivated',
288 'parameters', 'activeInfo', 288 'parameters', 'activeInfo',
289 'tabId')) 289 'tabId'))
290 290
291 291
292 if __name__ == '__main__': 292 if __name__ == '__main__':
293 unittest.main() 293 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698