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

Unified Diff: chrome/common/extensions/docs/server2/cron_servlet_test.py

Issue 15009006: Docserver: refactor Servlet, ObjectStore, and ServerInstance architecture to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cduvall, redirect fix Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/cron_servlet_test.py
diff --git a/chrome/common/extensions/docs/server2/cron_servlet_test.py b/chrome/common/extensions/docs/server2/cron_servlet_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..16f41b6a04fd69499893f617a49510727ab3614e
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/cron_servlet_test.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+
+from cron_servlet import CronServlet
+from empty_dir_file_system import EmptyDirFileSystem
+from local_file_system import LocalFileSystem
+from mock_file_system import MockFileSystem
+from servlet import Request
+from test_branch_utility import TestBranchUtility
+from test_file_system import TestFileSystem
+from test_util import EnableLogging
+
+# NOTE(kalman): The ObjectStore created by the CronServlet is backed onto our
+# fake AppEngine memcache/datastore, so the tests aren't isolated.
+class _TestDelegate(CronServlet.Delegate):
+ def __init__(self):
+ self.host_file_systems = []
+
+ def CreateBranchUtility(self, object_store_creator):
+ return TestBranchUtility()
+
+ def CreateHostFileSystemForBranch(self, branch):
+ host_file_system = MockFileSystem(LocalFileSystem.Create())
+ self.host_file_systems.append(host_file_system)
+ return host_file_system
+
+ def CreateAppSamplesFileSystem(self, object_store_creator):
+ return EmptyDirFileSystem()
+
+class CronServletTest(unittest.TestCase):
+ @EnableLogging('info')
+ def testEverything(self):
+ # All these tests are dependent (see above comment) so lump everything in
+ # the one test.
+ delegate = _TestDelegate()
+
+ # Test that the cron runs successfully.
+ response = CronServlet(Request.ForTest('trunk'),
+ delegate_for_test=delegate).Get()
+ self.assertEqual(1, len(delegate.host_file_systems))
+ self.assertEqual(200, response.status)
+
+ # When re-running, all file systems should be Stat()d the same number of
+ # times, but the second round shouldn't have been re-Read() since the
+ # Stats haven't changed.
+ response = CronServlet(Request.ForTest('trunk'),
+ delegate_for_test=delegate).Get()
+ self.assertEqual(2, len(delegate.host_file_systems))
+ self.assertTrue(*delegate.host_file_systems[1].CheckAndReset(
+ read_count=0,
+ stat_count=delegate.host_file_systems[0].GetStatCount()))
+
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698