1cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#!/usr/bin/env python
2cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com# Copyright 2013 The Chromium Authors. All rights reserved.
3cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com# Use of this source code is governed by a BSD-style license that can be
4cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com# found in the LICENSE file.
5cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com
6cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.comimport unittest
7cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com
8cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.comfrom empty_dir_file_system import EmptyDirFileSystem
9cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.comfrom host_file_system_provider import HostFileSystemProvider
108cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comfrom servlet import Request
118cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comfrom test_branch_utility import TestBranchUtility
128cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comfrom fail_on_access_file_system import FailOnAccessFileSystem
138cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comfrom test_servlet import TestServlet
148cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
158cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comclass _TestDelegate(object):
168cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  def CreateBranchUtility(self, object_store_creator):
178cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com    return TestBranchUtility.CreateWithCannedData()
188cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
198cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  def CreateAppSamplesFileSystem(self, object_store_creator):
208cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com    return EmptyDirFileSystem()
218cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
228cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  def CreateHostFileSystemProvider(self, object_store_creator):
238cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com    return HostFileSystemProvider.ForTest(
248cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com        FailOnAccessFileSystem(), object_store_creator)
258cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
268cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com# This test can't really be useful. The set of valid tests is changing and
278cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com# there is no reason to test the tests themselves, they are already tested in
288cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com# their respective modules. The only testable behavior TestServlet adds is
298cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com# returning a 404 if a test does not exist.
308cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comclass TestServletTest(unittest.TestCase):
318cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  def testTestServlet(self):
32cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com    request = Request('not_a_real_test_url', 'localhost', {})
33    test_servlet = TestServlet(request, _TestDelegate())
34    response = test_servlet.Get()
35
36    self.assertEqual(404, response.status)
37
38if __name__ == '__main__':
39  unittest.main()
40