1#!/usr/bin/env python 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 4# found in the LICENSE file. 5 6import unittest 7 8from empty_dir_file_system import EmptyDirFileSystem 9from host_file_system_provider import HostFileSystemProvider 10from servlet import Request 11from test_branch_utility import TestBranchUtility 12from fail_on_access_file_system import FailOnAccessFileSystem 13from test_servlet import TestServlet 14 15class _TestDelegate(object): 16 def CreateBranchUtility(self, object_store_creator): 17 return TestBranchUtility.CreateWithCannedData() 18 19 def CreateAppSamplesFileSystem(self, object_store_creator): 20 return EmptyDirFileSystem() 21 22 def CreateHostFileSystemProvider(self, object_store_creator): 23 return HostFileSystemProvider.ForTest( 24 FailOnAccessFileSystem(), object_store_creator) 25 26# This test can't really be useful. The set of valid tests is changing and 27# there is no reason to test the tests themselves, they are already tested in 28# their respective modules. The only testable behavior TestServlet adds is 29# returning a 404 if a test does not exist. 30class TestServletTest(unittest.TestCase): 31 def testTestServlet(self): 32 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