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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 def set_status(self, status): | 23 def set_status(self, status): |
24 self.status = status | 24 self.status = status |
25 | 25 |
26 class _MockRequest(object): | 26 class _MockRequest(object): |
27 def __init__(self, path): | 27 def __init__(self, path): |
28 self.headers = {} | 28 self.headers = {} |
29 self.path = path | 29 self.path = path |
30 | 30 |
31 class IntegrationTest(unittest.TestCase): | 31 class IntegrationTest(unittest.TestCase): |
32 def testAll(self): | 32 def testAll(self): |
33 for filename in os.listdir(os.path.join('templates', 'public')): | 33 for doc_type in ['apps', 'extensions']: |
34 if filename in KNOWN_FAILURES or filename.startswith('.'): | 34 for filename in os.listdir(os.path.join('templates', doc_type)): |
35 continue | 35 if filename in KNOWN_FAILURES or filename.startswith('.'): |
36 request = _MockRequest(filename) | 36 continue |
37 response = _MockResponse() | 37 request = _MockRequest(doc_type + '/' + filename) |
38 Handler(request, response, local_path='../..').get() | 38 response = _MockResponse() |
39 self.assertEqual(200, response.status) | 39 Handler(request, response, local_path='../..').get() |
40 self.assertTrue(response.out.getvalue()) | 40 self.assertEqual(200, response.status) |
| 41 self.assertTrue(response.out.getvalue()) |
41 | 42 |
42 def test404(self): | 43 def test404(self): |
43 request = _MockRequest('junk.html') | 44 request = _MockRequest('junk.html') |
44 bad_response = _MockResponse() | 45 bad_response = _MockResponse() |
45 Handler(request, bad_response, local_path='../..').get() | 46 Handler(request, bad_response, local_path='../..').get() |
46 self.assertEqual(404, bad_response.status) | 47 self.assertEqual(404, bad_response.status) |
47 self.assertTrue(bad_response.out.getvalue()) | 48 self.assertTrue(bad_response.out.getvalue()) |
48 | 49 |
49 def testLocales(self): | 50 def testLocales(self): |
50 # Use US English, Spanish, and Arabic. | 51 # Use US English, Spanish, and Arabic. |
(...skipping 14 matching lines...) Expand all Loading... |
65 request = _MockRequest('_ah/warmup') | 66 request = _MockRequest('_ah/warmup') |
66 response = _MockResponse() | 67 response = _MockResponse() |
67 Handler(request, response, local_path='../..').get() | 68 Handler(request, response, local_path='../..').get() |
68 self.assertEqual(200, response.status) | 69 self.assertEqual(200, response.status) |
69 # Test that the pages were rendered by checking the size of the output. | 70 # Test that the pages were rendered by checking the size of the output. |
70 # In python 2.6 there is no 'assertGreater' method. | 71 # In python 2.6 there is no 'assertGreater' method. |
71 self.assertTrue(len(response.out.getvalue()) > 500000) | 72 self.assertTrue(len(response.out.getvalue()) > 500000) |
72 | 73 |
73 if __name__ == '__main__': | 74 if __name__ == '__main__': |
74 unittest.main() | 75 unittest.main() |
OLD | NEW |