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

Side by Side Diff: chromium-shortener/www-crbug/app_test.py

Issue 12208137: Add code for www.crbug and new.crbug appengine apps. (Closed) Base URL: https://src.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « chromium-shortener/www-crbug/app.yaml ('k') | chromium-shortener/www-crbug/redirect.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import unittest
7
8 import redirect as app
9
10
11 class GaeTestCase(unittest.TestCase):
12 def setUp(self, *args, **kwargs):
13 self.clear_datastore()
14 super(GaeTestCase, self).setUp(*args, **kwargs)
15
16 @staticmethod
17 def clear_datastore():
18 from google.appengine.api import apiproxy_stub_map, datastore_file_stub
19 from google.appengine.api import memcache
20
21 # See http://code.google.com/p/gaeunit/issues/detail?id=15 for clue.
22 for key in ['datastore', 'datastore_v3']:
23 # W0212: 23,16:GaeTestCase.clear_datastore: Access to a protected member
24 # _APIProxyStubMap__stub_map of a client class
25 # pylint: disable=W0212
26 # E1101: 50,16:GaeTestCase.clear_datastore: Instance of 'APIProxyStubMap'
27 # has no '_APIProxyStubMap__stub_map' member
28 # pylint: disable=E1101
29 if key in apiproxy_stub_map.apiproxy._APIProxyStubMap__stub_map:
30 # W0212: 24,12:GaeTestCase.clear_datastore: Access to a protected
31 # member _APIProxyStubMap__stub_map of a client class
32 # pylint: disable=W0212
33 # E1101: 54,12:GaeTestCase.clear_datastore: Instance of
34 # 'APIProxyStubMap' has no '_APIProxyStubMap__stub_map' member
35 # pylint: disable=E1101
36 del apiproxy_stub_map.apiproxy._APIProxyStubMap__stub_map[key]
37
38 # Use a fresh stub datastore.
39 stub = datastore_file_stub.DatastoreFileStub(
40 app.APP_NAME, '/dev/null', '/dev/null')
41 apiproxy_stub_map.apiproxy.RegisterStub('datastore', stub)
42
43 # Flush memcache.
44 memcache.flush_all()
45
46
47 class RedirectTestCase(GaeTestCase):
48 def redirect_helper(self, path):
49 from webtest import TestApp
50 testapp = TestApp(app.application)
51 response = testapp.get(path)
52 self.assertEquals('302 Moved Temporarily', response.status)
53 self.assertEquals('', response.body)
54 return response
55
56 def test_main_page_redirect(self):
57 page = self.redirect_helper('/')
58 self.assertEquals(page.headers['Location'],
59 'http://code.google.com/p/chromium/issues/list')
60
61 def test_issue_page_redirect(self):
62 page = self.redirect_helper('/123456')
63 self.assertEquals(page.headers['Location'],
64 'http://code.google.com/p/chromium/issues/detail?id=123456')
65
66 def test_username_page_redirect(self):
67 page = self.redirect_helper('/~agable')
68 self.assertEquals(page.headers['Location'],
69 'http://code.google.com/p/chromium/issues/list?'
70 'can=2&q=owner:agable&cells=tiles&colspec='
71 'ID+Pri+Mstone+ReleaseBlock+OS+Area+Feature+Status+Owner+Summary')
OLDNEW
« no previous file with comments | « chromium-shortener/www-crbug/app.yaml ('k') | chromium-shortener/www-crbug/redirect.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698