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

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

Issue 10825067: Extensions Docs Server: Apps samples page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: less is_apps and fixes 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 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 # This should be tested though: http://crbug.com/141910.
19 'apps/samples.html',
15 ] 20 ]
16 21
17 class _MockResponse(object): 22 class _MockResponse(object):
18 def __init__(self): 23 def __init__(self):
19 self.status = 200 24 self.status = 200
20 self.out = StringIO() 25 self.out = StringIO()
21 26
22 def set_status(self, status): 27 def set_status(self, status):
23 self.status = status 28 self.status = status
24 29
25 class _MockRequest(object): 30 class _MockRequest(object):
26 def __init__(self, path): 31 def __init__(self, path):
27 self.headers = {} 32 self.headers = {}
28 self.path = path 33 self.path = path
29 34
30 class IntegrationTest(unittest.TestCase): 35 class IntegrationTest(unittest.TestCase):
31 def testAll(self): 36 def testAll(self):
37 logging.getLogger().setLevel(logging.ERROR)
32 base_path = os.path.join('templates', 'public') 38 base_path = os.path.join('templates', 'public')
33 for path, dirs, files in os.walk(base_path): 39 for path, dirs, files in os.walk(base_path):
34 for name in files: 40 for name in files:
35 filename = os.path.join(path, name) 41 filename = os.path.join(path, name)
36 if name in KNOWN_FAILURES or '.' in path or name.startswith('.'): 42 if (filename.split('/', 2)[-1] in KNOWN_FAILURES or
43 '.' in path or
44 name.startswith('.')):
37 continue 45 continue
38 request = _MockRequest(filename.split('/', 2)[-1]) 46 request = _MockRequest(filename.split('/', 2)[-1])
39 response = _MockResponse() 47 response = _MockResponse()
40 Handler(request, response, local_path='../..').get() 48 Handler(request, response, local_path='../..').get()
41 self.assertEqual(200, response.status) 49 self.assertEqual(200, response.status)
42 self.assertTrue(response.out.getvalue()) 50 self.assertTrue(response.out.getvalue())
43 51
44 def test404(self): 52 def test404(self):
45 request = _MockRequest('junk.html') 53 request = _MockRequest('junk.html')
46 bad_response = _MockResponse() 54 bad_response = _MockResponse()
47 Handler(request, bad_response, local_path='../..').get() 55 Handler(request, bad_response, local_path='../..').get()
48 self.assertEqual(404, bad_response.status) 56 self.assertEqual(404, bad_response.status)
49 self.assertTrue(bad_response.out.getvalue()) 57 self.assertTrue(bad_response.out.getvalue())
50 58
51 def testLocales(self): 59 def testLocales(self):
52 # Use US English, Spanish, and Arabic. 60 # Use US English, Spanish, and Arabic.
53 for lang in ['en-US', 'es', 'ar']: 61 for lang in ['en-US', 'es', 'ar']:
54 request = _MockRequest('extensions/samples.html') 62 request = _MockRequest('extensions/samples.html')
55 request.headers['Accept-Language'] = lang + ';q=0.8' 63 request.headers['Accept-Language'] = lang + ';q=0.8'
56 response = _MockResponse() 64 response = _MockResponse()
57 Handler(request, response, local_path='../..').get() 65 Handler(request, response, local_path='../..').get()
58 self.assertEqual(200, response.status) 66 self.assertEqual(200, response.status)
59 self.assertTrue(response.out.getvalue()) 67 self.assertTrue(response.out.getvalue())
60 68
61 def testWarmupRequest(self): 69 def testWarmupRequest(self):
62 for branch in ['dev', 'trunk', 'beta', 'stable']: 70 for branch in ['dev', 'trunk', 'beta', 'stable']:
63 handler.BRANCH_UTILITY_MEMCACHE.Set( 71 handler.BRANCH_UTILITY_MEMCACHE.Set(
64 branch + '.' + handler.OMAHA_PROXY_URL, 72 branch + '.' + url_constants.OMAHA_PROXY_URL,
65 'local', 73 'local',
66 memcache.MEMCACHE_BRANCH_UTILITY) 74 memcache.MEMCACHE_BRANCH_UTILITY)
67 request = _MockRequest('_ah/warmup') 75 request = _MockRequest('_ah/warmup')
68 response = _MockResponse() 76 response = _MockResponse()
69 Handler(request, response, local_path='../..').get() 77 Handler(request, response, local_path='../..').get()
70 self.assertEqual(200, response.status) 78 self.assertEqual(200, response.status)
71 # Test that the pages were rendered by checking the size of the output. 79 # Test that the pages were rendered by checking the size of the output.
72 # In python 2.6 there is no 'assertGreater' method. 80 # In python 2.6 there is no 'assertGreater' method.
73 self.assertTrue(len(response.out.getvalue()) > 500000) 81 self.assertTrue(len(response.out.getvalue()) > 100000)
not at google - send to devlin 2012/08/13 01:51:11 Oh is it possible to put a failure message here? L
cduvall 2012/08/13 17:47:06 Done.
74 82
75 if __name__ == '__main__': 83 if __name__ == '__main__':
76 unittest.main() 84 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698