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

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

Issue 18323018: Linking AvailabilityFinder with APIDataSource and intro-table templates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase with master Created 7 years, 5 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 appengine_wrappers import GetAppVersion 8 from appengine_wrappers import GetAppVersion
9 from app_yaml_helper import AppYamlHelper 9 from app_yaml_helper import AppYamlHelper
10 from caching_file_system import CachingFileSystem
11 from cron_servlet import CronServlet 10 from cron_servlet import CronServlet
12 from empty_dir_file_system import EmptyDirFileSystem 11 from empty_dir_file_system import EmptyDirFileSystem
13 from host_file_system_creator import HostFileSystemCreator 12 from host_file_system_creator import HostFileSystemCreator
14 from local_file_system import LocalFileSystem 13 from local_file_system import LocalFileSystem
15 from mock_file_system import MockFileSystem 14 from mock_file_system import MockFileSystem
16 from servlet import Request 15 from servlet import Request
17 from test_branch_utility import TestBranchUtility 16 from test_branch_utility import TestBranchUtility
18 from test_file_system import TestFileSystem 17 from test_file_system import TestFileSystem
19 from test_util import EnableLogging 18 from test_util import EnableLogging
20 19
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 @EnableLogging('info') 52 @EnableLogging('info')
54 def testEverything(self): 53 def testEverything(self):
55 # All these tests are dependent (see above comment) so lump everything in 54 # All these tests are dependent (see above comment) so lump everything in
56 # the one test. 55 # the one test.
57 delegate = _TestDelegate( 56 delegate = _TestDelegate(
58 lambda _, __: MockFileSystem(LocalFileSystem.Create())) 57 lambda _, __: MockFileSystem(LocalFileSystem.Create()))
59 58
60 # Test that the cron runs successfully. 59 # Test that the cron runs successfully.
61 response = CronServlet(Request.ForTest('trunk'), 60 response = CronServlet(Request.ForTest('trunk'),
62 delegate_for_test=delegate).Get() 61 delegate_for_test=delegate).Get()
63 self.assertEqual(1, len(delegate.file_systems))
64 self.assertEqual(200, response.status) 62 self.assertEqual(200, response.status)
65 63
64 # Save the file systems created, start with a fresh set for the next run.
65 first_run_file_systems = delegate.file_systems[:]
66 delegate.file_systems[:] = []
67
66 # When re-running, all file systems should be Stat()d the same number of 68 # When re-running, all file systems should be Stat()d the same number of
67 # times, but the second round shouldn't have been re-Read() since the 69 # times, but the second round shouldn't have been re-Read() since the
68 # Stats haven't changed. 70 # Stats haven't changed.
69 response = CronServlet(Request.ForTest('trunk'), 71 response = CronServlet(Request.ForTest('trunk'),
70 delegate_for_test=delegate).Get() 72 delegate_for_test=delegate).Get()
71 self.assertEqual(2, len(delegate.file_systems)) 73 self.assertEqual(200, response.status)
72 self.assertTrue(*delegate.file_systems[1].CheckAndReset( 74
73 read_count=0, 75 self.assertEqual(len(first_run_file_systems), len(delegate.file_systems))
74 stat_count=delegate.file_systems[0].GetStatCount())) 76 for i, second_run_file_system in enumerate(delegate.file_systems):
77 self.assertTrue(*second_run_file_system.CheckAndReset(
78 read_count=0,
79 stat_count=first_run_file_systems[i].GetStatCount()))
75 80
76 def testSafeRevision(self): 81 def testSafeRevision(self):
77 test_data = { 82 test_data = {
78 'docs': { 83 'docs': {
79 'examples': { 84 'examples': {
80 'examples.txt': 'examples.txt contents' 85 'examples.txt': 'examples.txt contents'
81 }, 86 },
82 'server2': { 87 'server2': {
83 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') 88 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8')
84 }, 89 },
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() 204 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get()
200 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), 205 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'),
201 file_systems[-1].ReadSingle(app_yaml_path)) 206 file_systems[-1].ReadSingle(app_yaml_path))
202 self.assertEqual('y u not update!', 207 self.assertEqual('y u not update!',
203 file_systems[-1].ReadSingle(storage_html_path)) 208 file_systems[-1].ReadSingle(storage_html_path))
204 self.assertEqual('important content!', 209 self.assertEqual('important content!',
205 file_systems[-1].ReadSingle(static_txt_path)) 210 file_systems[-1].ReadSingle(static_txt_path))
206 211
207 if __name__ == '__main__': 212 if __name__ == '__main__':
208 unittest.main() 213 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/cron.yaml ('k') | chrome/common/extensions/docs/server2/intro_data_source_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698