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 28 matching lines...) Expand all Loading... |
39 self.assertEqual(200, response.status) | 39 self.assertEqual(200, response.status) |
40 self.assertTrue(response.out.getvalue()) | 40 self.assertTrue(response.out.getvalue()) |
41 | 41 |
42 def test404(self): | 42 def test404(self): |
43 request = _MockRequest('junk.html') | 43 request = _MockRequest('junk.html') |
44 bad_response = _MockResponse() | 44 bad_response = _MockResponse() |
45 Handler(request, bad_response, local_path='../..').get() | 45 Handler(request, bad_response, local_path='../..').get() |
46 self.assertEqual(404, bad_response.status) | 46 self.assertEqual(404, bad_response.status) |
47 self.assertTrue(bad_response.out.getvalue()) | 47 self.assertTrue(bad_response.out.getvalue()) |
48 | 48 |
| 49 def testLocales(self): |
| 50 # Use US English, Spanish, and Arabic. |
| 51 for lang in ['en-US', 'es', 'ar']: |
| 52 request = _MockRequest('samples.html') |
| 53 request.headers['Accept-Language'] = lang + ';q=0.8' |
| 54 response = _MockResponse() |
| 55 Handler(request, response, local_path='../..').get() |
| 56 self.assertEqual(200, response.status) |
| 57 self.assertTrue(response.out.getvalue()) |
| 58 |
49 def testWarmupRequest(self): | 59 def testWarmupRequest(self): |
50 for branch in ['dev', 'trunk', 'beta', 'stable']: | 60 for branch in ['dev', 'trunk', 'beta', 'stable']: |
51 handler.BRANCH_UTILITY_MEMCACHE.Set( | 61 handler.BRANCH_UTILITY_MEMCACHE.Set( |
52 branch + '.' + handler.OMAHA_PROXY_URL, | 62 branch + '.' + handler.OMAHA_PROXY_URL, |
53 'local', | 63 'local', |
54 memcache.MEMCACHE_BRANCH_UTILITY) | 64 memcache.MEMCACHE_BRANCH_UTILITY) |
55 request = _MockRequest('_ah/warmup') | 65 request = _MockRequest('_ah/warmup') |
56 response = _MockResponse() | 66 response = _MockResponse() |
57 Handler(request, response, local_path='../..').get() | 67 Handler(request, response, local_path='../..').get() |
58 self.assertEqual(200, response.status) | 68 self.assertEqual(200, response.status) |
59 # Test that the pages were rendered by checking the size of the output. | 69 # Test that the pages were rendered by checking the size of the output. |
60 # In python 2.6 there is no 'assertGreater' method. | 70 # In python 2.6 there is no 'assertGreater' method. |
61 self.assertTrue(len(response.out.getvalue()) > 500000) | 71 self.assertTrue(len(response.out.getvalue()) > 500000) |
62 | 72 |
63 if __name__ == '__main__': | 73 if __name__ == '__main__': |
64 unittest.main() | 74 unittest.main() |
OLD | NEW |