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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better redirects Created 7 years, 7 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 # Run build_server so that files needed by tests are copied to the local 6 # Run build_server so that files needed by tests are copied to the local
7 # third_party directory. 7 # third_party directory.
8 import build_server 8 import build_server
9 build_server.main() 9 build_server.main()
10 10
11 import logging 11 import logging
12 import optparse 12 import optparse
13 import os 13 import os
14 import posixpath
14 import sys 15 import sys
15 import time 16 import time
16 import unittest 17 import unittest
17 18
19 from branch_utility import BranchUtility
18 from local_renderer import LocalRenderer 20 from local_renderer import LocalRenderer
19 from fake_fetchers import ConfigureFakeFetchers 21 from fake_fetchers import ConfigureFakeFetchers
20 from handler import Handler 22 from handler import Handler
21 from servlet import Request 23 from servlet import Request
22 from test_util import EnableLogging, DisableLogging 24 from test_util import EnableLogging, DisableLogging
23 25
24 # Arguments set up if __main__ specifies them. 26 # Arguments set up if __main__ specifies them.
25 _EXPLICIT_TEST_FILES = None 27 _EXPLICIT_TEST_FILES = None
26 28
27 def _ToPosixPath(os_path): 29 def _ToPosixPath(os_path):
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 start_time = time.time() 69 start_time = time.time()
68 try: 70 try:
69 for path, content in public_files.iteritems(): 71 for path, content in public_files.iteritems():
70 def check_result(response): 72 def check_result(response):
71 self.assertEqual(200, response.status, 73 self.assertEqual(200, response.status,
72 'Got %s when rendering %s' % (response.status, path)) 74 'Got %s when rendering %s' % (response.status, path))
73 # This is reaaaaally rough since usually these will be tiny templates 75 # This is reaaaaally rough since usually these will be tiny templates
74 # that render large files. At least it'll catch zero-length responses. 76 # that render large files. At least it'll catch zero-length responses.
75 self.assertTrue(len(response.content) >= len(content), 77 self.assertTrue(len(response.content) >= len(content),
76 'Content was "%s" when rendering %s' % (response.content, path)) 78 'Content was "%s" when rendering %s' % (response.content, path))
79
77 check_result(Handler(Request.ForTest(path)).Get()) 80 check_result(Handler(Request.ForTest(path)).Get())
81
82 # Make sure that leaving out the .html will temporarily redirect to the
83 # path with the .html.
84 if path != '/404.html':
85 redirect_result = Handler(
86 Request.ForTest(posixpath.splitext(path)[0])).Get()
87 self.assertEqual((path, False), redirect_result.GetRedirect())
88
89 # Make sure including a channel will permanently redirect to the same
90 # path without a channel.
91 for channel in BranchUtility.GetAllChannelNames():
92 redirect_result = Handler(
93 Request.ForTest('%s/%s' % (channel, path))).Get()
94 self.assertEqual((path, True), redirect_result.GetRedirect())
95
78 # Samples are internationalized, test some locales. 96 # Samples are internationalized, test some locales.
79 if path.endswith('/samples.html'): 97 if path.endswith('/samples.html'):
80 for lang in ['en-US', 'es', 'ar']: 98 for lang in ['en-US', 'es', 'ar']:
81 check_result(Handler(Request.ForTest( 99 check_result(Handler(Request.ForTest(
82 path, 100 path,
83 headers={'Accept-Language': '%s;q=0.8' % lang})).Get()) 101 headers={'Accept-Language': '%s;q=0.8' % lang})).Get())
84 finally: 102 finally:
85 print('Took %s seconds' % (time.time() - start_time)) 103 print('Took %s seconds' % (time.time() - start_time))
86 104
87 # TODO(kalman): Move this test elsewhere, it's not an integration test. 105 # TODO(kalman): Move this test elsewhere, it's not an integration test.
(...skipping 20 matching lines...) Expand all
108 126
109 if __name__ == '__main__': 127 if __name__ == '__main__':
110 parser = optparse.OptionParser() 128 parser = optparse.OptionParser()
111 parser.add_option('-a', '--all', action='store_true', default=False) 129 parser.add_option('-a', '--all', action='store_true', default=False)
112 (opts, args) = parser.parse_args() 130 (opts, args) = parser.parse_args()
113 if not opts.all: 131 if not opts.all:
114 _EXPLICIT_TEST_FILES = args 132 _EXPLICIT_TEST_FILES = args
115 # Kill sys.argv because we have our own flags. 133 # Kill sys.argv because we have our own flags.
116 sys.argv = [sys.argv[0]] 134 sys.argv = [sys.argv[0]]
117 unittest.main() 135 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698