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

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

Issue 10823105: Extensions Docs Server: Preview server and more integration tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: previewserver -> preview + 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 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
11 import handler
10 from handler import Handler 12 from handler import Handler
11 13
12 KNOWN_FAILURES = [ 14 KNOWN_FAILURES = [
13 'webstore.html', 15 'webstore.html',
14 ] 16 ]
15 17
16 class _MockResponse: 18 class _MockResponse(object):
17 def __init__(self): 19 def __init__(self):
18 self.status = 200 20 self.status = 200
19 self.out = StringIO() 21 self.out = StringIO()
20 22
21 def set_status(self, status): 23 def set_status(self, status):
22 self.status = status 24 self.status = status
23 25
24 class _MockRequest: 26 class _MockRequest(object):
25 def __init__(self, path): 27 def __init__(self, path):
26 self.headers = {} 28 self.headers = {}
27 self.path = path 29 self.path = path
28 30
29 class IntegrationTest(unittest.TestCase): 31 class IntegrationTest(unittest.TestCase):
30 def testAll(self): 32 def testAll(self):
31 for filename in os.listdir(os.path.join('templates', 'public')): 33 for filename in os.listdir(os.path.join('templates', 'public')):
32 if filename in KNOWN_FAILURES or filename.startswith('.'): 34 if filename in KNOWN_FAILURES or filename.startswith('.'):
33 continue 35 continue
34 request = _MockRequest(filename) 36 request = _MockRequest(filename)
35 response = _MockResponse() 37 response = _MockResponse()
36 Handler(request, response, local_path='../..').get() 38 Handler(request, response, local_path='../..').get()
37 self.assertEqual(200, response.status) 39 self.assertEqual(200, response.status)
38 self.assertTrue(response.out.getvalue()) 40 self.assertTrue(response.out.getvalue())
39 41
40 def test404(self): 42 def test404(self):
41 request = _MockRequest('junk.html') 43 request = _MockRequest('junk.html')
42 bad_response = _MockResponse() 44 bad_response = _MockResponse()
43 Handler(request, bad_response, local_path='../..').get() 45 Handler(request, bad_response, local_path='../..').get()
44 self.assertEqual(404, bad_response.status) 46 self.assertEqual(404, bad_response.status)
45 self.assertTrue(bad_response.out.getvalue()) 47 self.assertTrue(bad_response.out.getvalue())
46 48
49 def testWarmupRequest(self):
50 for branch in ['dev', 'trunk', 'beta', 'stable']:
51 handler.BRANCH_UTILITY_MEMCACHE.Set(
52 branch + '.' + handler.OMAHA_PROXY_URL,
53 'local',
54 memcache.MEMCACHE_BRANCH_UTILITY)
55 request = _MockRequest('_ah/warmup')
56 response = _MockResponse()
57 Handler(request, response, local_path='../..').get()
58 self.assertEqual(200, response.status)
59 # Test that the pages were rendered by checking the size of the output.
60 # In python 2.6 there is no 'assertGreater' method.
61 self.assertTrue(len(response.out.getvalue()) > 500000)
62
47 if __name__ == '__main__': 63 if __name__ == '__main__':
48 unittest.main() 64 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/in_memory_memcache.py ('k') | chrome/common/extensions/docs/server2/preview.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698