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 import url_constants |
13 | 14 |
14 KNOWN_FAILURES = [ | 15 KNOWN_FAILURES = [ |
15 'webstore.html', | 16 'webstore.html', |
| 17 'apps_samples.html' |
16 ] | 18 ] |
17 | 19 |
18 class _MockResponse(object): | 20 class _MockResponse(object): |
19 def __init__(self): | 21 def __init__(self): |
20 self.status = 200 | 22 self.status = 200 |
21 self.out = StringIO() | 23 self.out = StringIO() |
22 | 24 |
23 def set_status(self, status): | 25 def set_status(self, status): |
24 self.status = status | 26 self.status = status |
25 | 27 |
(...skipping 16 matching lines...) Expand all Loading... |
42 def test404(self): | 44 def test404(self): |
43 request = _MockRequest('junk.html') | 45 request = _MockRequest('junk.html') |
44 bad_response = _MockResponse() | 46 bad_response = _MockResponse() |
45 Handler(request, bad_response, local_path='../..').get() | 47 Handler(request, bad_response, local_path='../..').get() |
46 self.assertEqual(404, bad_response.status) | 48 self.assertEqual(404, bad_response.status) |
47 self.assertTrue(bad_response.out.getvalue()) | 49 self.assertTrue(bad_response.out.getvalue()) |
48 | 50 |
49 def testWarmupRequest(self): | 51 def testWarmupRequest(self): |
50 for branch in ['dev', 'trunk', 'beta', 'stable']: | 52 for branch in ['dev', 'trunk', 'beta', 'stable']: |
51 handler.BRANCH_UTILITY_MEMCACHE.Set( | 53 handler.BRANCH_UTILITY_MEMCACHE.Set( |
52 branch + '.' + handler.OMAHA_PROXY_URL, | 54 branch + '.' + url_constants.OMAHA_PROXY_URL, |
53 'local', | 55 'local', |
54 memcache.MEMCACHE_BRANCH_UTILITY) | 56 memcache.MEMCACHE_BRANCH_UTILITY) |
55 request = _MockRequest('_ah/warmup') | 57 request = _MockRequest('_ah/warmup') |
56 response = _MockResponse() | 58 response = _MockResponse() |
57 Handler(request, response, local_path='../..').get() | 59 Handler(request, response, local_path='../..').get() |
58 self.assertEqual(200, response.status) | 60 self.assertEqual(200, response.status) |
59 # Test that the pages were rendered by checking the size of the output. | 61 # Test that the pages were rendered by checking the size of the output. |
60 # In python 2.6 there is no 'assertGreater' method. | 62 # In python 2.6 there is no 'assertGreater' method. |
61 self.assertTrue(len(response.out.getvalue()) > 500000) | 63 self.assertTrue(len(response.out.getvalue()) > 500000) |
62 | 64 |
63 if __name__ == '__main__': | 65 if __name__ == '__main__': |
64 unittest.main() | 66 unittest.main() |
OLD | NEW |