Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: chrome/common/extensions/docs/server2/integration_test.py

Issue 10834144: Extensions Docs Server: Split apps from extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 base_path = os.path.join('templates', 'public')
34 if filename in KNOWN_FAILURES or filename.startswith('.'): 34 for path, dirs, files in os.walk(base_path):
35 continue 35 for name in files:
36 request = _MockRequest(filename) 36 filename = os.path.join(path, name)
37 response = _MockResponse() 37 if filename in KNOWN_FAILURES or filename.startswith('.'):
38 Handler(request, response, local_path='../..').get() 38 continue
39 self.assertEqual(200, response.status) 39 request = _MockRequest(filename.split('/', 2)[-1])
40 self.assertTrue(response.out.getvalue()) 40 response = _MockResponse()
41 Handler(request, response, local_path='../..').get()
42 self.assertEqual(200, response.status)
43 self.assertTrue(response.out.getvalue())
41 44
42 def test404(self): 45 def test404(self):
43 request = _MockRequest('junk.html') 46 request = _MockRequest('junk.html')
44 bad_response = _MockResponse() 47 bad_response = _MockResponse()
45 Handler(request, bad_response, local_path='../..').get() 48 Handler(request, bad_response, local_path='../..').get()
46 self.assertEqual(404, bad_response.status) 49 self.assertEqual(404, bad_response.status)
47 self.assertTrue(bad_response.out.getvalue()) 50 self.assertTrue(bad_response.out.getvalue())
48 51
49 def testLocales(self): 52 def testLocales(self):
50 # Use US English, Spanish, and Arabic. 53 # Use US English, Spanish, and Arabic.
51 for lang in ['en-US', 'es', 'ar']: 54 for lang in ['en-US', 'es', 'ar']:
52 request = _MockRequest('samples.html') 55 request = _MockRequest('extensions/samples.html')
53 request.headers['Accept-Language'] = lang + ';q=0.8' 56 request.headers['Accept-Language'] = lang + ';q=0.8'
54 response = _MockResponse() 57 response = _MockResponse()
55 Handler(request, response, local_path='../..').get() 58 Handler(request, response, local_path='../..').get()
56 self.assertEqual(200, response.status) 59 self.assertEqual(200, response.status)
57 self.assertTrue(response.out.getvalue()) 60 self.assertTrue(response.out.getvalue())
58 61
59 def testWarmupRequest(self): 62 def testWarmupRequest(self):
60 for branch in ['dev', 'trunk', 'beta', 'stable']: 63 for branch in ['dev', 'trunk', 'beta', 'stable']:
61 handler.BRANCH_UTILITY_MEMCACHE.Set( 64 handler.BRANCH_UTILITY_MEMCACHE.Set(
62 branch + '.' + handler.OMAHA_PROXY_URL, 65 branch + '.' + handler.OMAHA_PROXY_URL,
63 'local', 66 'local',
64 memcache.MEMCACHE_BRANCH_UTILITY) 67 memcache.MEMCACHE_BRANCH_UTILITY)
65 request = _MockRequest('_ah/warmup') 68 request = _MockRequest('_ah/warmup')
66 response = _MockResponse() 69 response = _MockResponse()
67 Handler(request, response, local_path='../..').get() 70 Handler(request, response, local_path='../..').get()
68 self.assertEqual(200, response.status) 71 self.assertEqual(200, response.status)
69 # Test that the pages were rendered by checking the size of the output. 72 # Test that the pages were rendered by checking the size of the output.
70 # In python 2.6 there is no 'assertGreater' method. 73 # In python 2.6 there is no 'assertGreater' method.
71 self.assertTrue(len(response.out.getvalue()) > 500000) 74 self.assertTrue(len(response.out.getvalue()) > 500000)
72 75
73 if __name__ == '__main__': 76 if __name__ == '__main__':
74 unittest.main() 77 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/handler.py ('k') | chrome/common/extensions/docs/server2/template_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698