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

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

Issue 214843006: Docserver: Support //apps APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no copy, API->EXTENSIONS_API Created 6 years, 9 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 5
6 import json 6 import json
7 import unittest 7 import unittest
8 8
9 from api_models import APIModels 9 from api_models import APIModels
10 from compiled_file_system import CompiledFileSystem 10 from compiled_file_system import CompiledFileSystem
11 from extensions_paths import CHROME_API, CHROME_EXTENSIONS 11 from extensions_paths import API_PATHS, CHROME_API, CHROME_EXTENSIONS
12 from features_bundle import FeaturesBundle 12 from features_bundle import FeaturesBundle
13 from file_system import FileNotFoundError 13 from file_system import FileNotFoundError
14 from mock_file_system import MockFileSystem 14 from mock_file_system import MockFileSystem
15 from object_store_creator import ObjectStoreCreator 15 from object_store_creator import ObjectStoreCreator
16 from test_file_system import TestFileSystem 16 from test_file_system import TestFileSystem
17 from test_util import ReadFile 17 from test_util import ReadFile
18 18
19 19
20 _TEST_DATA = { 20 _TEST_DATA = {
21 'api': { 21 'api': {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 self.assertRaises(FileNotFoundError, 121 self.assertRaises(FileNotFoundError,
122 self._api_models.GetModel('storage').Get) 122 self._api_models.GetModel('storage').Get)
123 self.assertRaises(FileNotFoundError, 123 self.assertRaises(FileNotFoundError,
124 self._api_models.GetModel(CHROME_API + 124 self._api_models.GetModel(CHROME_API +
125 'storage.json').Get) 125 'storage.json').Get)
126 self.assertRaises(FileNotFoundError, 126 self.assertRaises(FileNotFoundError,
127 self._api_models.GetModel(CHROME_API + 127 self._api_models.GetModel(CHROME_API +
128 'storage.idl').Get) 128 'storage.idl').Get)
129 129
130 def testSingleFile(self): 130 def testSingleFile(self):
131 # 4 stats (1 for JSON and 1 for IDL, in both possible API path), 131 # 2 stats (1 for JSON and 1 for IDL) for each available API path.
132 # 1 read (for IDL file which existed). 132 # 1 read (for IDL file which existed).
133 future = self._api_models.GetModel('alarms') 133 future = self._api_models.GetModel('alarms')
134 self.assertTrue(*self._mock_file_system.CheckAndReset( 134 self.assertTrue(*self._mock_file_system.CheckAndReset(
135 read_count=1, stat_count=4)) 135 read_count=1, stat_count=len(API_PATHS)*2))
136 136
137 # 1 read-resolve (for the IDL file). 137 # 1 read-resolve (for the IDL file).
138 # 138 #
139 # The important part here and above is that it's only doing a single read; 139 # The important part here and above is that it's only doing a single read;
140 # any more would break the contract that only a single file is accessed - 140 # any more would break the contract that only a single file is accessed -
141 # see the SingleFile annotation in api_models._CreateAPIModel. 141 # see the SingleFile annotation in api_models._CreateAPIModel.
142 future.Get() 142 future.Get()
143 self.assertTrue(*self._mock_file_system.CheckAndReset( 143 self.assertTrue(*self._mock_file_system.CheckAndReset(
144 read_resolve_count=1)) 144 read_resolve_count=1))
145 145
146 # 4 stats (1 for JSON and 1 for IDL, in both possible API paths) 146 # 2 stats (1 for JSON and 1 for IDL) for each available API path.
147 # no reads (still cached). 147 # No reads (still cached).
148 future = self._api_models.GetModel('alarms') 148 future = self._api_models.GetModel('alarms')
149 self.assertTrue(*self._mock_file_system.CheckAndReset(stat_count=4)) 149 self.assertTrue(*self._mock_file_system.CheckAndReset(
150 stat_count=len(API_PATHS)*2))
150 future.Get() 151 future.Get()
151 self.assertTrue(*self._mock_file_system.CheckAndReset()) 152 self.assertTrue(*self._mock_file_system.CheckAndReset())
152 153
153 154
154 if __name__ == '__main__': 155 if __name__ == '__main__':
155 unittest.main() 156 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/api_models.py ('k') | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698