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

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
11 from empty_dir_file_system import EmptyDirFileSystem 11 from empty_dir_file_system import EmptyDirFileSystem
12 from environment import GetAppVersion 12 from environment import GetAppVersion
13 from extensions_paths import ( 13 from extensions_paths import (
14 APP_YAML, CONTENT_PROVIDERS, CHROME_EXTENSIONS, PUBLIC_TEMPLATES, SERVER2, 14 APP_YAML, CONTENT_PROVIDERS, CHROME_EXTENSIONS, PUBLIC_TEMPLATES, SERVER2,
15 STATIC_DOCS) 15 STATIC_DOCS)
16 from fake_fetchers import ConfigureFakeFetchers
16 from gcs_file_system_provider import CloudStorageFileSystemProvider 17 from gcs_file_system_provider import CloudStorageFileSystemProvider
17 from github_file_system_provider import GithubFileSystemProvider 18 from github_file_system_provider import GithubFileSystemProvider
18 from host_file_system_provider import HostFileSystemProvider 19 from host_file_system_provider import HostFileSystemProvider
19 from local_file_system import LocalFileSystem 20 from local_file_system import LocalFileSystem
20 from mock_file_system import MockFileSystem 21 from mock_file_system import MockFileSystem
21 from servlet import Request 22 from servlet import Request
22 from test_branch_utility import TestBranchUtility 23 from test_branch_utility import TestBranchUtility
23 from test_file_system import MoveTo, TestFileSystem 24 from test_file_system import MoveTo, TestFileSystem
24 from test_util import EnableLogging, ReadFile 25 from test_util import EnableLogging, ReadFile
25 26
(...skipping 29 matching lines...) Expand all
55 return CloudStorageFileSystemProvider.ForEmpty() 56 return CloudStorageFileSystemProvider.ForEmpty()
56 57
57 def GetAppVersion(self): 58 def GetAppVersion(self):
58 return self._app_version 59 return self._app_version
59 60
60 # (non-Delegate method). 61 # (non-Delegate method).
61 def SetAppVersion(self, app_version): 62 def SetAppVersion(self, app_version):
62 self._app_version = app_version 63 self._app_version = app_version
63 64
64 class CronServletTest(unittest.TestCase): 65 class CronServletTest(unittest.TestCase):
66 def setUp(self):
67 ConfigureFakeFetchers()
not at google - send to devlin 2014/08/21 21:39:58 Hm, why do you need this? I've tried very hard to
68
65 @EnableLogging('info') 69 @EnableLogging('info')
66 def testEverything(self): 70 def testEverything(self):
67 # All these tests are dependent (see above comment) so lump everything in 71 # All these tests are dependent (see above comment) so lump everything in
68 # the one test. 72 # the one test.
69 delegate = _TestDelegate(lambda _: MockFileSystem(LocalFileSystem.Create())) 73 delegate = _TestDelegate(lambda _: MockFileSystem(LocalFileSystem.Create()))
70 74
71 # Test that the cron runs successfully. 75 # Test that the cron runs successfully.
72 response = CronServlet(Request.ForTest('trunk'), 76 response = CronServlet(Request.ForTest('trunk'),
73 delegate_for_test=delegate).Get() 77 delegate_for_test=delegate).Get()
74 self.assertEqual(200, response.status) 78 self.assertEqual(200, response.status)
(...skipping 11 matching lines...) Expand all
86 90
87 self.assertEqual(len(first_run_file_systems), len(delegate.file_systems)) 91 self.assertEqual(len(first_run_file_systems), len(delegate.file_systems))
88 for i, second_run_file_system in enumerate(delegate.file_systems): 92 for i, second_run_file_system in enumerate(delegate.file_systems):
89 self.assertTrue(*second_run_file_system.CheckAndReset( 93 self.assertTrue(*second_run_file_system.CheckAndReset(
90 read_count=0, 94 read_count=0,
91 stat_count=first_run_file_systems[i].GetStatCount())) 95 stat_count=first_run_file_systems[i].GetStatCount()))
92 96
93 @IgnoreMissingContentProviders 97 @IgnoreMissingContentProviders
94 def testSafeRevision(self): 98 def testSafeRevision(self):
95 test_data = { 99 test_data = {
96 'api': { 100 'extensions': {
97 '_api_features.json': '{}', 101 'browser': {
98 '_manifest_features.json': '{}', 102 'api': {}
99 '_permission_features.json': '{}', 103 }
100 }, 104 },
101 'docs': { 105 'chrome': {
102 'examples': { 106 'browser': {
103 'examples.txt': 'examples.txt contents' 107 'extensions': {
108 'OWNERS': '',
109 'api': {}
110 }
104 }, 111 },
105 'server2': { 112 'common': {
106 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') 113 'extensions': {
107 }, 114 'api': {
108 'static': { 115 '_api_features.json': '{}',
109 'static.txt': 'static.txt contents' 116 '_manifest_features.json': '{}',
110 }, 117 '_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 }, 118 },
125 'extensions': { 119 'docs': {
126 'storage.html': '<h1>storage.html</h1> contents' 120 'examples': {
127 }, 121 'examples.txt': 'examples.txt contents'
128 }, 122 },
129 'json': { 123 'server2': {
130 'chrome_sidenav.json': '{}', 124 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8')
131 'content_providers.json': ReadFile(CONTENT_PROVIDERS), 125 },
132 'manifest.json': '{}', 126 'static': {
133 'permissions.json': '{}', 127 'static.txt': 'static.txt contents'
134 'strings.json': '{}', 128 },
135 'whats_new.json': '{}', 129 'templates': {
136 }, 130 'articles': {
131 'activeTab.html': 'activeTab.html contents'
132 },
133 'intros': {
134 'browserAction.html': 'activeTab.html contents'
135 },
136 'private': {
137 'table_of_contents.html': 'table_of_contents.html contents',
138 },
139 'public': {
140 'apps': {
141 'storage.html': '<h1>storage.html</h1> contents'
142 },
143 'extensions': {
144 'storage.html': '<h1>storage.html</h1> contents'
145 },
146 },
147 'json': {
148 'chrome_sidenav.json': '{}',
149 'content_providers.json': ReadFile(CONTENT_PROVIDERS),
150 'manifest.json': '{}',
151 'permissions.json': '{}',
152 'strings.json': '{}',
153 'whats_new.json': '{}',
154 },
155 }
156 }
157 }
137 } 158 }
138 } 159 }
139 } 160 }
140 161
141 updates = [] 162 updates = []
142 163
143 def app_yaml_update(version): 164 def app_yaml_update(version):
144 return MoveTo(SERVER2, { 165 return MoveTo(SERVER2, {
145 'app.yaml': AppYamlHelper.GenerateAppYaml(version) 166 'app.yaml': AppYamlHelper.GenerateAppYaml(version)
146 }) 167 })
147 def storage_html_update(update): 168 def storage_html_update(update):
148 return MoveTo(PUBLIC_TEMPLATES, { 169 return MoveTo(PUBLIC_TEMPLATES, {
149 'apps': {'storage.html': update} 170 'apps': {'storage.html': update}
150 }) 171 })
151 def static_txt_update(update): 172 def static_txt_update(update):
152 return MoveTo(STATIC_DOCS, { 173 return MoveTo(STATIC_DOCS, {
153 'static.txt': update 174 'static.txt': update
154 }) 175 })
155 176
156 storage_html_path = PUBLIC_TEMPLATES + 'apps/storage.html' 177 storage_html_path = PUBLIC_TEMPLATES + 'apps/storage.html'
157 static_txt_path = STATIC_DOCS + 'static.txt' 178 static_txt_path = STATIC_DOCS + 'static.txt'
158 179
159 def create_file_system(revision=None): 180 def create_file_system(revision=None):
160 '''Creates a MockFileSystem at |revision| by applying that many |updates| 181 '''Creates a MockFileSystem at |revision| by applying that many |updates|
161 to it. 182 to it.
162 ''' 183 '''
163 mock_file_system = MockFileSystem( 184 mock_file_system = MockFileSystem(TestFileSystem(test_data))
164 TestFileSystem(test_data, relative_to=CHROME_EXTENSIONS))
165 updates_for_revision = ( 185 updates_for_revision = (
166 updates if revision is None else updates[:int(revision)]) 186 updates if revision is None else updates[:int(revision)])
167 for update in updates_for_revision: 187 for update in updates_for_revision:
168 mock_file_system.Update(update) 188 mock_file_system.Update(update)
169 return mock_file_system 189 return mock_file_system
170 190
171 delegate = _TestDelegate(create_file_system) 191 delegate = _TestDelegate(create_file_system)
172 delegate.SetAppVersion('2-0-8') 192 delegate.SetAppVersion('2-0-8')
173 193
174 file_systems = delegate.file_systems 194 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'), 262 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'),
243 file_systems[-1].ReadSingle(APP_YAML).Get()) 263 file_systems[-1].ReadSingle(APP_YAML).Get())
244 self.assertEqual('<h1>y</h1> u not update!', 264 self.assertEqual('<h1>y</h1> u not update!',
245 file_systems[-1].ReadSingle(storage_html_path).Get()) 265 file_systems[-1].ReadSingle(storage_html_path).Get())
246 self.assertEqual('important content!', 266 self.assertEqual('important content!',
247 file_systems[-1].ReadSingle(static_txt_path).Get()) 267 file_systems[-1].ReadSingle(static_txt_path).Get())
248 268
249 269
250 if __name__ == '__main__': 270 if __name__ == '__main__':
251 unittest.main() 271 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698