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', 'public', doc_type)): |
not at google - send to devlin
2012/08/06 08:38:33
can you do a recursive search for .html files rath
cduvall
2012/08/06 18:36:16
Done.
| |
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. |
51 for lang in ['en-US', 'es', 'ar']: | 52 for lang in ['en-US', 'es', 'ar']: |
52 request = _MockRequest('samples.html') | 53 request = _MockRequest('extensions/samples.html') |
53 request.headers['Accept-Language'] = lang + ';q=0.8' | 54 request.headers['Accept-Language'] = lang + ';q=0.8' |
54 response = _MockResponse() | 55 response = _MockResponse() |
55 Handler(request, response, local_path='../..').get() | 56 Handler(request, response, local_path='../..').get() |
56 self.assertEqual(200, response.status) | 57 self.assertEqual(200, response.status) |
57 self.assertTrue(response.out.getvalue()) | 58 self.assertTrue(response.out.getvalue()) |
58 | 59 |
59 def testWarmupRequest(self): | 60 def testWarmupRequest(self): |
60 for branch in ['dev', 'trunk', 'beta', 'stable']: | 61 for branch in ['dev', 'trunk', 'beta', 'stable']: |
61 handler.BRANCH_UTILITY_MEMCACHE.Set( | 62 handler.BRANCH_UTILITY_MEMCACHE.Set( |
62 branch + '.' + handler.OMAHA_PROXY_URL, | 63 branch + '.' + handler.OMAHA_PROXY_URL, |
63 'local', | 64 'local', |
64 memcache.MEMCACHE_BRANCH_UTILITY) | 65 memcache.MEMCACHE_BRANCH_UTILITY) |
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 |