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

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: More Generic Templates 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 29 matching lines...) Expand all
50 self._app_version = app_version 49 self._app_version = app_version
51 50
52 class CronServletTest(unittest.TestCase): 51 class CronServletTest(unittest.TestCase):
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
59 # A file system will be created for the server instance, and one
60 # will also be created by AvailabilityFinder for each version from trunk, to
61 # version 28 (dev), down to and including version 17. This amounts to 14
62 # total. The dev version is determined by the test data that
63 # TestBranchUtility has access to. Version 17 is where AvailabilityFinder
64 # halts during tests.
65 num_file_systems = 14
epeterson 2013/07/16 00:28:23 This is a pretty magical number. I mean, anything
not at google - send to devlin 2013/07/16 22:25:00 Ok maybe the answer here is just the test isn't me
epeterson 2013/07/17 23:48:23 That seems ok.
60 # Test that the cron runs successfully. 66 # Test that the cron runs successfully.
61 response = CronServlet(Request.ForTest('trunk'), 67 response = CronServlet(Request.ForTest('trunk'),
62 delegate_for_test=delegate).Get() 68 delegate_for_test=delegate).Get()
63 self.assertEqual(1, len(delegate.file_systems)) 69 self.assertEqual(num_file_systems, len(delegate.file_systems))
64 self.assertEqual(200, response.status) 70 self.assertEqual(200, response.status)
65 71
66 # When re-running, all file systems should be Stat()d the same number of 72 # 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 73 # times, but the second round shouldn't have been re-Read() since the
68 # Stats haven't changed. 74 # Stats haven't changed.
69 response = CronServlet(Request.ForTest('trunk'), 75 response = CronServlet(Request.ForTest('trunk'),
70 delegate_for_test=delegate).Get() 76 delegate_for_test=delegate).Get()
71 self.assertEqual(2, len(delegate.file_systems)) 77 self.assertEqual(num_file_systems * 2, len(delegate.file_systems))
72 self.assertTrue(*delegate.file_systems[1].CheckAndReset( 78 for x in range (0, num_file_systems):
73 read_count=0, 79 self.assertTrue(*delegate.file_systems[x + num_file_systems]
74 stat_count=delegate.file_systems[0].GetStatCount())) 80 .CheckAndReset(read_count=0,
81 stat_count=delegate.file_systems[x].GetStatCount()))
75 82
76 def testSafeRevision(self): 83 def testSafeRevision(self):
77 test_data = { 84 test_data = {
78 'docs': { 85 'docs': {
79 'examples': { 86 'examples': {
80 'examples.txt': 'examples.txt contents' 87 'examples.txt': 'examples.txt contents'
81 }, 88 },
82 'server2': { 89 'server2': {
83 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8') 90 'app.yaml': AppYamlHelper.GenerateAppYaml('2-0-8')
84 }, 91 },
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() 206 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get()
200 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), 207 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'),
201 file_systems[-1].ReadSingle(app_yaml_path)) 208 file_systems[-1].ReadSingle(app_yaml_path))
202 self.assertEqual('y u not update!', 209 self.assertEqual('y u not update!',
203 file_systems[-1].ReadSingle(storage_html_path)) 210 file_systems[-1].ReadSingle(storage_html_path))
204 self.assertEqual('important content!', 211 self.assertEqual('important content!',
205 file_systems[-1].ReadSingle(static_txt_path)) 212 file_systems[-1].ReadSingle(static_txt_path))
206 213
207 if __name__ == '__main__': 214 if __name__ == '__main__':
208 unittest.main() 215 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698