OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 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 os |
| 7 from StringIO import StringIO |
| 8 import unittest |
| 9 |
| 10 from handler import Handler |
| 11 |
| 12 KNOWN_FAILURES = [ |
| 13 'webstore.html', |
| 14 ] |
| 15 |
| 16 class _MockResponse: |
| 17 def __init__(self): |
| 18 self.status = 200 |
| 19 self.out = StringIO() |
| 20 |
| 21 def set_status(self, status): |
| 22 self.status = status |
| 23 |
| 24 class _MockRequest: |
| 25 def __init__(self, path): |
| 26 self.headers = {} |
| 27 self.path = path |
| 28 |
| 29 class IntegrationTest(unittest.TestCase): |
| 30 def testAll(self): |
| 31 for filename in os.listdir(os.path.join('templates', 'public')): |
| 32 if filename in KNOWN_FAILURES: |
| 33 continue |
| 34 request = _MockRequest(filename) |
| 35 response = _MockResponse() |
| 36 Handler(request, response, local_path='../..').get() |
| 37 self.assertEqual(200, response.status) |
| 38 self.assertTrue(response.out.getvalue()) |
| 39 |
| 40 def test404(self): |
| 41 request = _MockRequest('junk.html') |
| 42 bad_response = _MockResponse() |
| 43 Handler(request, bad_response, local_path='../..').get() |
| 44 self.assertEqual(404, bad_response.status) |
| 45 self.assertTrue(bad_response.out.getvalue()) |
| 46 |
| 47 if __name__ == '__main__': |
| 48 unittest.main() |
OLD | NEW |