Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 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 | |
| 6 | import unittest |
| 7 | |
| 8 | from empty_dir_file_system import EmptyDirFileSystem |
| 9 | from host_file_system_creator import HostFileSystemCreator |
| 10 | from servlet import Request |
| 11 | from test_branch_utility import TestBranchUtility |
| 12 | from fail_on_access_file_system import FailOnAccessFileSystem |
| 13 | from test_servlet import TestServlet |
| 14 | |
| 15 | class _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 CreateHostFileSystemCreator(self, object_store_creator): |
| 23 | return HostFileSystemCreator.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. |
| 30 | class 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 | |
| 38 | if __name__ == '__main__': |
| 39 | unittest.main() |