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 logging | |
6 import os | 7 import os |
7 from StringIO import StringIO | 8 from StringIO import StringIO |
8 import unittest | 9 import unittest |
9 | 10 |
10 import appengine_memcache as memcache | 11 import appengine_memcache as memcache |
11 import handler | 12 import handler |
12 from handler import Handler | 13 from handler import Handler |
14 import url_constants | |
13 | 15 |
14 KNOWN_FAILURES = [ | 16 KNOWN_FAILURES = [ |
17 # Apps samples fails because it requires fetching data from github.com. | |
18 'samples.html', | |
not at google - send to devlin
2012/08/09 07:52:36
... except now we're not testing the extensions ei
cduvall
2012/08/09 19:20:08
Done.
not at google - send to devlin
2012/08/10 06:02:18
It would be nice to actually test this... and for
cduvall
2012/08/10 21:17:47
Done. Bug is: http://crbug.com/141910
| |
15 # Exception in schema compiler (model.py). See http://crbug.com/141279. | 19 # Exception in schema compiler (model.py). See http://crbug.com/141279. |
16 'app.html', | 20 'app.html' |
17 ] | 21 ] |
18 | 22 |
19 class _MockResponse(object): | 23 class _MockResponse(object): |
20 def __init__(self): | 24 def __init__(self): |
21 self.status = 200 | 25 self.status = 200 |
22 self.out = StringIO() | 26 self.out = StringIO() |
23 | 27 |
24 def set_status(self, status): | 28 def set_status(self, status): |
25 self.status = status | 29 self.status = status |
26 | 30 |
27 class _MockRequest(object): | 31 class _MockRequest(object): |
28 def __init__(self, path): | 32 def __init__(self, path): |
29 self.headers = {} | 33 self.headers = {} |
30 self.path = path | 34 self.path = path |
31 | 35 |
32 class IntegrationTest(unittest.TestCase): | 36 class IntegrationTest(unittest.TestCase): |
33 def testAll(self): | 37 def testAll(self): |
38 logging.getLogger().setLevel(logging.ERROR) | |
not at google - send to devlin
2012/08/09 07:52:36
remove logging
cduvall
2012/08/09 19:20:08
This isn't a log, it just sets the logging level s
| |
34 base_path = os.path.join('templates', 'public') | 39 base_path = os.path.join('templates', 'public') |
35 for path, dirs, files in os.walk(base_path): | 40 for path, dirs, files in os.walk(base_path): |
36 for name in files: | 41 for name in files: |
37 filename = os.path.join(path, name) | 42 filename = os.path.join(path, name) |
38 if name in KNOWN_FAILURES or '.' in path or name.startswith('.'): | 43 if name in KNOWN_FAILURES or '.' in path or name.startswith('.'): |
39 continue | 44 continue |
40 request = _MockRequest(filename.split('/', 2)[-1]) | 45 request = _MockRequest(filename.split('/', 2)[-1]) |
41 response = _MockResponse() | 46 response = _MockResponse() |
42 Handler(request, response, local_path='../..').get() | 47 Handler(request, response, local_path='../..').get() |
43 self.assertEqual(200, response.status) | 48 self.assertEqual(200, response.status) |
(...skipping 12 matching lines...) Expand all Loading... | |
56 request = _MockRequest('extensions/samples.html') | 61 request = _MockRequest('extensions/samples.html') |
57 request.headers['Accept-Language'] = lang + ';q=0.8' | 62 request.headers['Accept-Language'] = lang + ';q=0.8' |
58 response = _MockResponse() | 63 response = _MockResponse() |
59 Handler(request, response, local_path='../..').get() | 64 Handler(request, response, local_path='../..').get() |
60 self.assertEqual(200, response.status) | 65 self.assertEqual(200, response.status) |
61 self.assertTrue(response.out.getvalue()) | 66 self.assertTrue(response.out.getvalue()) |
62 | 67 |
63 def testWarmupRequest(self): | 68 def testWarmupRequest(self): |
64 for branch in ['dev', 'trunk', 'beta', 'stable']: | 69 for branch in ['dev', 'trunk', 'beta', 'stable']: |
65 handler.BRANCH_UTILITY_MEMCACHE.Set( | 70 handler.BRANCH_UTILITY_MEMCACHE.Set( |
66 branch + '.' + handler.OMAHA_PROXY_URL, | 71 branch + '.' + url_constants.OMAHA_PROXY_URL, |
67 'local', | 72 'local', |
68 memcache.MEMCACHE_BRANCH_UTILITY) | 73 memcache.MEMCACHE_BRANCH_UTILITY) |
69 request = _MockRequest('_ah/warmup') | 74 request = _MockRequest('_ah/warmup') |
70 response = _MockResponse() | 75 response = _MockResponse() |
71 Handler(request, response, local_path='../..').get() | 76 Handler(request, response, local_path='../..').get() |
72 self.assertEqual(200, response.status) | 77 self.assertEqual(200, response.status) |
73 # Test that the pages were rendered by checking the size of the output. | 78 # Test that the pages were rendered by checking the size of the output. |
74 # In python 2.6 there is no 'assertGreater' method. | 79 # In python 2.6 there is no 'assertGreater' method. |
75 self.assertTrue(len(response.out.getvalue()) > 500000) | 80 self.assertTrue(len(response.out.getvalue()) > 500000) |
76 | 81 |
77 if __name__ == '__main__': | 82 if __name__ == '__main__': |
78 unittest.main() | 83 unittest.main() |
OLD | NEW |