Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 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 fake_fetchers import ConfigureFakeFetchers | |
| 12 from local_file_system import LocalFileSystem | 13 from local_file_system import LocalFileSystem |
| 13 from mock_file_system import MockFileSystem | 14 from mock_file_system import MockFileSystem |
| 14 from servlet import Request | 15 from servlet import Request |
| 15 from test_branch_utility import TestBranchUtility | 16 from test_branch_utility import TestBranchUtility |
| 16 from test_file_system import TestFileSystem | 17 from test_file_system import TestFileSystem |
| 17 from test_util import EnableLogging | 18 from test_util import EnableLogging |
| 18 | 19 |
| 19 # NOTE(kalman): The ObjectStore created by the CronServlet is backed onto our | 20 # NOTE(kalman): The ObjectStore created by the CronServlet is backed onto our |
| 20 # fake AppEngine memcache/datastore, so the tests aren't isolated. Of course, | 21 # fake AppEngine memcache/datastore, so the tests aren't isolated. Of course, |
| 21 # if the host file systems have different identities, they will be, sort of. | 22 # if the host file systems have different identities, they will be, sort of. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 38 return EmptyDirFileSystem() | 39 return EmptyDirFileSystem() |
| 39 | 40 |
| 40 def GetAppVersion(self): | 41 def GetAppVersion(self): |
| 41 return self._app_version | 42 return self._app_version |
| 42 | 43 |
| 43 # (non-Delegate method). | 44 # (non-Delegate method). |
| 44 def SetAppVersion(self, app_version): | 45 def SetAppVersion(self, app_version): |
| 45 self._app_version = app_version | 46 self._app_version = app_version |
| 46 | 47 |
| 47 class CronServletTest(unittest.TestCase): | 48 class CronServletTest(unittest.TestCase): |
| 49 def setUp(self): | |
| 50 ConfigureFakeFetchers() | |
|
epeterson
2013/05/13 02:38:10
*Should this need to be here? It prevents errors w
not at google - send to devlin
2013/05/13 21:26:41
no it shouldn't be here. The only thing allowed to
epeterson
2013/05/15 07:38:34
Done.
| |
| 51 | |
| 48 @EnableLogging('info') | 52 @EnableLogging('info') |
| 49 def testEverything(self): | 53 def testEverything(self): |
| 50 # 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 |
| 51 # the one test. | 55 # the one test. |
| 52 delegate = _TestDelegate(lambda _: MockFileSystem(LocalFileSystem.Create())) | 56 delegate = _TestDelegate(lambda _: MockFileSystem(LocalFileSystem.Create())) |
| 53 | 57 |
| 54 # Test that the cron runs successfully. | 58 # Test that the cron runs successfully. |
| 55 response = CronServlet(Request.ForTest('trunk'), | 59 response = CronServlet(Request.ForTest('trunk'), |
| 56 delegate_for_test=delegate).Get() | 60 delegate_for_test=delegate).Get() |
| 57 self.assertEqual(1, len(delegate.file_systems)) | 61 self.assertEqual(1, len(delegate.file_systems)) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() | 197 CronServlet(Request.ForTest('trunk'), delegate_for_test=delegate).Get() |
| 194 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), | 198 self.assertEqual(AppYamlHelper.GenerateAppYaml('2-1-0'), |
| 195 file_systems[-1].ReadSingle(app_yaml_path)) | 199 file_systems[-1].ReadSingle(app_yaml_path)) |
| 196 self.assertEqual('y u not update!', | 200 self.assertEqual('y u not update!', |
| 197 file_systems[-1].ReadSingle(storage_html_path)) | 201 file_systems[-1].ReadSingle(storage_html_path)) |
| 198 self.assertEqual('important content!', | 202 self.assertEqual('important content!', |
| 199 file_systems[-1].ReadSingle(static_txt_path)) | 203 file_systems[-1].ReadSingle(static_txt_path)) |
| 200 | 204 |
| 201 if __name__ == '__main__': | 205 if __name__ == '__main__': |
| 202 unittest.main() | 206 unittest.main() |
| OLD | NEW |