OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 from StringIO import StringIO | 7 from StringIO import StringIO |
8 import unittest | 8 import unittest |
9 | 9 |
10 import appengine_memcache as memcache | 10 import appengine_memcache as memcache |
11 import handler | 11 import handler |
12 from handler import Handler | 12 from handler import Handler |
13 | 13 |
14 KNOWN_FAILURES = [ | 14 KNOWN_FAILURES = [ |
15 'webstore.html', | 15 # Exception in schema compiler (model.py). See http://crbug.com/141279. |
| 16 'app.html', |
16 ] | 17 ] |
17 | 18 |
18 class _MockResponse(object): | 19 class _MockResponse(object): |
19 def __init__(self): | 20 def __init__(self): |
20 self.status = 200 | 21 self.status = 200 |
21 self.out = StringIO() | 22 self.out = StringIO() |
22 | 23 |
23 def set_status(self, status): | 24 def set_status(self, status): |
24 self.status = status | 25 self.status = status |
25 | 26 |
26 class _MockRequest(object): | 27 class _MockRequest(object): |
27 def __init__(self, path): | 28 def __init__(self, path): |
28 self.headers = {} | 29 self.headers = {} |
29 self.path = path | 30 self.path = path |
30 | 31 |
31 class IntegrationTest(unittest.TestCase): | 32 class IntegrationTest(unittest.TestCase): |
32 def testAll(self): | 33 def testAll(self): |
33 base_path = os.path.join('templates', 'public') | 34 base_path = os.path.join('templates', 'public') |
34 for path, dirs, files in os.walk(base_path): | 35 for path, dirs, files in os.walk(base_path): |
35 for name in files: | 36 for name in files: |
36 filename = os.path.join(path, name) | 37 filename = os.path.join(path, name) |
37 if filename in KNOWN_FAILURES or filename.startswith('.'): | 38 if name in KNOWN_FAILURES or '.' in path or name.startswith('.'): |
38 continue | 39 continue |
39 request = _MockRequest(filename.split('/', 2)[-1]) | 40 request = _MockRequest(filename.split('/', 2)[-1]) |
40 response = _MockResponse() | 41 response = _MockResponse() |
41 Handler(request, response, local_path='../..').get() | 42 Handler(request, response, local_path='../..').get() |
42 self.assertEqual(200, response.status) | 43 self.assertEqual(200, response.status) |
43 self.assertTrue(response.out.getvalue()) | 44 self.assertTrue(response.out.getvalue()) |
44 | 45 |
45 def test404(self): | 46 def test404(self): |
46 request = _MockRequest('junk.html') | 47 request = _MockRequest('junk.html') |
47 bad_response = _MockResponse() | 48 bad_response = _MockResponse() |
(...skipping 20 matching lines...) Expand all Loading... |
68 request = _MockRequest('_ah/warmup') | 69 request = _MockRequest('_ah/warmup') |
69 response = _MockResponse() | 70 response = _MockResponse() |
70 Handler(request, response, local_path='../..').get() | 71 Handler(request, response, local_path='../..').get() |
71 self.assertEqual(200, response.status) | 72 self.assertEqual(200, response.status) |
72 # Test that the pages were rendered by checking the size of the output. | 73 # Test that the pages were rendered by checking the size of the output. |
73 # In python 2.6 there is no 'assertGreater' method. | 74 # In python 2.6 there is no 'assertGreater' method. |
74 self.assertTrue(len(response.out.getvalue()) > 500000) | 75 self.assertTrue(len(response.out.getvalue()) > 500000) |
75 | 76 |
76 if __name__ == '__main__': | 77 if __name__ == '__main__': |
77 unittest.main() | 78 unittest.main() |
OLD | NEW |