| 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 logging |
| 7 import os | 7 import os |
| 8 from StringIO import StringIO | 8 from StringIO import StringIO |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| 11 from fake_fetchers import ConfigureFakeFetchers | 11 from fake_fetchers import ConfigureFakeFetchers |
| 12 | 12 |
| 13 KNOWN_FAILURES = [ | 13 KNOWN_FAILURES = [ |
| 14 # Apps samples fails because it requires fetching data from github.com. | |
| 15 # This should be tested though: http://crbug.com/141910. | |
| 16 'apps/samples.html', | |
| 17 ] | 14 ] |
| 18 | 15 |
| 19 ConfigureFakeFetchers() | 16 ConfigureFakeFetchers() |
| 20 | 17 |
| 21 # Import Handler later because it immediately makes a request to github. We need | 18 # Import Handler later because it immediately makes a request to github. We need |
| 22 # the fake urlfetch to be in place first. | 19 # the fake urlfetch to be in place first. |
| 23 from handler import Handler | 20 from handler import Handler |
| 24 | 21 |
| 25 class _MockResponse(object): | 22 class _MockResponse(object): |
| 26 def __init__(self): | 23 def __init__(self): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 def testLocales(self): | 59 def testLocales(self): |
| 63 # Use US English, Spanish, and Arabic. | 60 # Use US English, Spanish, and Arabic. |
| 64 for lang in ['en-US', 'es', 'ar']: | 61 for lang in ['en-US', 'es', 'ar']: |
| 65 request = _MockRequest('extensions/samples.html') | 62 request = _MockRequest('extensions/samples.html') |
| 66 request.headers['Accept-Language'] = lang + ';q=0.8' | 63 request.headers['Accept-Language'] = lang + ';q=0.8' |
| 67 response = _MockResponse() | 64 response = _MockResponse() |
| 68 Handler(request, response, local_path='../..').get() | 65 Handler(request, response, local_path='../..').get() |
| 69 self.assertEqual(200, response.status) | 66 self.assertEqual(200, response.status) |
| 70 self.assertTrue(response.out.getvalue()) | 67 self.assertTrue(response.out.getvalue()) |
| 71 | 68 |
| 69 def testCron(self): |
| 70 request = _MockRequest('/cron/trunk') |
| 71 response = _MockResponse() |
| 72 Handler(request, response, local_path='../..').get() |
| 73 self.assertEqual(200, response.status) |
| 74 self.assertEqual('Success', response.out.getvalue()) |
| 75 |
| 72 if __name__ == '__main__': | 76 if __name__ == '__main__': |
| 73 unittest.main() | 77 unittest.main() |
| OLD | NEW |