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

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

Issue 453713002: Docserver: Generate a table of extension/app API owners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
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 unittest 6 import unittest
7 7
8 from app_yaml_helper import AppYamlHelper 8 from app_yaml_helper import AppYamlHelper
9 from content_providers import IgnoreMissingContentProviders 9 from content_providers import IgnoreMissingContentProviders
10 from cron_servlet import CronServlet 10 from cron_servlet import CronServlet
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 # When re-running, all file systems should be Stat()d the same number of 80 # When re-running, all file systems should be Stat()d the same number of
81 # times, but the second round shouldn't have been re-Read() since the 81 # times, but the second round shouldn't have been re-Read() since the
82 # Stats haven't changed. 82 # Stats haven't changed.
83 response = CronServlet(Request.ForTest('trunk'), 83 response = CronServlet(Request.ForTest('trunk'),
84 delegate_for_test=delegate).Get() 84 delegate_for_test=delegate).Get()
85 self.assertEqual(200, response.status) 85 self.assertEqual(200, response.status)
86 86
87 self.assertEqual(len(first_run_file_systems), len(delegate.file_systems)) 87 self.assertEqual(len(first_run_file_systems), len(delegate.file_systems))
88 for i, second_run_file_system in enumerate(delegate.file_systems): 88 for i, second_run_file_system in enumerate(delegate.file_systems):
89 self.assertTrue(*second_run_file_system.CheckAndReset( 89 self.assertTrue(*second_run_file_system.CheckAndReset(
90 read_count=0, 90 read_count=0,
ahernandez 2014/08/13 23:24:28 I'm not sure what to do about this test. One of th
not at google - send to devlin 2014/08/14 00:05:05 This test is supposed to catch anything that doesn
91 stat_count=first_run_file_systems[i].GetStatCount())) 91 stat_count=first_run_file_systems[i].GetStatCount()))
92 92
93 @IgnoreMissingContentProviders 93 @IgnoreMissingContentProviders
94 def testSafeRevision(self): 94 def testSafeRevision(self):
95 test_data = { 95 test_data = {
96 'api': { 96 'extensions': {
97 '_api_features.json': '{}', 97 'browser': {
98 '_manifest_features.json': '{}', 98 'api': {}
99 '_permission_features.json': '{}', 99 }
100 }, 100 },
101 'docs': { 101 'chrome': {
102 'examples': { 102 'browser': {
103 'examples.txt': 'examples.txt contents' 103 'extensions': {
104 'OWNERS': '',
105 'api': {}
106 }
104 }, 107 },
105 'server2': { 108 'common': {
106 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') 109 'extensions': {
107 }, 110 'api': {
108 'static': { 111 '_api_features.json': '{}',
109 'static.txt': 'static.txt contents' 112 '_manifest_features.json': '{}',
110 }, 113 '_permission_features.json': '{}',
111 'templates': {
112 'articles': {
113 'activeTab.html': 'activeTab.html contents'
114 },
115 'intros': {
116 'browserAction.html': 'activeTab.html contents'
117 },
118 'private': {
119 'table_of_contents.html': 'table_of_contents.html contents',
120 },
121 'public': {
122 'apps': {
123 'storage.html': '<h1>storage.html</h1> contents'
124 }, 114 },
125 'extensions': { 115 'docs': {
126 'storage.html': '<h1>storage.html</h1> contents' 116 'examples': {
127 }, 117 'examples.txt': 'examples.txt contents'
128 }, 118 },
129 'json': { 119 'server2': {
130 'chrome_sidenav.json': '{}', 120 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8')
131 'content_providers.json': ReadFile(CONTENT_PROVIDERS), 121 },
132 'manifest.json': '{}', 122 'static': {
133 'permissions.json': '{}', 123 'static.txt': 'static.txt contents'
134 'strings.json': '{}', 124 },
135 'whats_new.json': '{}', 125 'templates': {
136 }, 126 'articles': {
127 'activeTab.html': 'activeTab.html contents'
128 },
129 'intros': {
130 'browserAction.html': 'activeTab.html contents'
131 },
132 'private': {
133 'table_of_contents.html': 'table_of_contents.html contents',
134 },
135 'public': {
136 'apps': {
137 'storage.html': '<h1>storage.html</h1> contents'
138 },
139 'extensions': {
140 'storage.html': '<h1>storage.html</h1> contents'
141 },
142 },
143 'json': {
144 'chrome_sidenav.json': '{}',
145 'content_providers.json': ReadFile(CONTENT_PROVIDERS),
146 'manifest.json': '{}',
147 'permissions.json': '{}',
148 'strings.json': '{}',
149 'whats_new.json': '{}',
150 },
151 }
152 }
153 }
137 } 154 }
138 } 155 }
139 } 156 }
140 157
141 updates = [] 158 updates = []
142 159
143 def app_yaml_update(version): 160 def app_yaml_update(version):
144 return MoveTo(SERVER2, { 161 return MoveTo(SERVER2, {
145 'app.yaml': AppYamlHelper.GenerateAppYaml(version) 162 'app.yaml': AppYamlHelper.GenerateAppYaml(version)
146 }) 163 })
147 def storage_html_update(update): 164 def storage_html_update(update):
148 return MoveTo(PUBLIC_TEMPLATES, { 165 return MoveTo(PUBLIC_TEMPLATES, {
149 'apps': {'storage.html': update} 166 'apps': {'storage.html': update}
150 }) 167 })
151 def static_txt_update(update): 168 def static_txt_update(update):
152 return MoveTo(STATIC_DOCS, { 169 return MoveTo(STATIC_DOCS, {
153 'static.txt': update 170 'static.txt': update
154 }) 171 })
155 172
156 storage_html_path = PUBLIC_TEMPLATES + 'apps/storage.html' 173 storage_html_path = PUBLIC_TEMPLATES + 'apps/storage.html'
157 static_txt_path = STATIC_DOCS + 'static.txt' 174 static_txt_path = STATIC_DOCS + 'static.txt'
158 175
159 def create_file_system(revision=None): 176 def create_file_system(revision=None):
160 '''Creates a MockFileSystem at |revision| by applying that many |updates| 177 '''Creates a MockFileSystem at |revision| by applying that many |updates|
161 to it. 178 to it.
162 ''' 179 '''
163 mock_file_system = MockFileSystem( 180 mock_file_system = MockFileSystem(TestFileSystem(test_data))
164 TestFileSystem(test_data, relative_to=CHROME_EXTENSIONS))
165 updates_for_revision = ( 181 updates_for_revision = (
166 updates if revision is None else updates[:int(revision)]) 182 updates if revision is None else updates[:int(revision)])
167 for update in updates_for_revision: 183 for update in updates_for_revision:
168 mock_file_system.Update(update) 184 mock_file_system.Update(update)
169 return mock_file_system 185 return mock_file_system
170 186
171 delegate = _TestDelegate(create_file_system) 187 delegate = _TestDelegate(create_file_system)
172 delegate.SetAppVersion('2-0-8') 188 delegate.SetAppVersion('2-0-8')
173 189
174 file_systems = delegate.file_systems 190 file_systems = delegate.file_systems
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), 258 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'),
243 file_systems[-1].ReadSingle(APP_YAML).Get()) 259 file_systems[-1].ReadSingle(APP_YAML).Get())
244 self.assertEqual('<h1>y</h1> u not update!', 260 self.assertEqual('<h1>y</h1> u not update!',
245 file_systems[-1].ReadSingle(storage_html_path).Get()) 261 file_systems[-1].ReadSingle(storage_html_path).Get())
246 self.assertEqual('important content!', 262 self.assertEqual('important content!',
247 file_systems[-1].ReadSingle(static_txt_path).Get()) 263 file_systems[-1].ReadSingle(static_txt_path).Get())
248 264
249 265
250 if __name__ == '__main__': 266 if __name__ == '__main__':
251 unittest.main() 267 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698