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

Unified Diff: appengine/monorail/framework/test/registerpages_helpers_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: appengine/monorail/framework/test/registerpages_helpers_test.py
diff --git a/appengine/monorail/framework/test/registerpages_helpers_test.py b/appengine/monorail/framework/test/registerpages_helpers_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..8b2daee069fd02debc02474e1df628fd3872d4c3
--- /dev/null
+++ b/appengine/monorail/framework/test/registerpages_helpers_test.py
@@ -0,0 +1,49 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Tests for URL handler registration helper functions."""
+
+import unittest
+
+import webapp2
+
+from framework import registerpages_helpers
+
+
+class SendRedirectInScopeTest(unittest.TestCase):
+
+ def testMakeRedirectInScope_Error(self):
+ self.assertRaises(
+ AssertionError,
+ registerpages_helpers.MakeRedirectInScope, 'no/initial/slash', 'p')
+ self.assertRaises(
+ AssertionError,
+ registerpages_helpers.MakeRedirectInScope, '', 'p')
+
+ def testMakeRedirectInScope_Normal(self):
+ factory = registerpages_helpers.MakeRedirectInScope('/', 'p')
+ # Non-dasher, normal case
+ request = webapp2.Request.blank(
+ path='/p/foo', headers={'Host': 'example.com'})
+ response = webapp2.Response()
+ redirector = factory(request, response)
+ redirector.get()
+ self.assertEqual(response.location, '//example.com/p/foo/')
+ self.assertEqual(response.status, '301 Moved Permanently')
+
+ def testMakeRedirectInScope_Temporary(self):
+ factory = registerpages_helpers.MakeRedirectInScope(
+ '/', 'p', permanent=False)
+ request = webapp2.Request.blank(
+ path='/p/foo', headers={'Host': 'example.com'})
+ response = webapp2.Response()
+ redirector = factory(request, response)
+ redirector.get()
+ self.assertEqual(response.location, '//example.com/p/foo/')
+ self.assertEqual(response.status, '302 Moved Temporarily')
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « appengine/monorail/framework/test/reap_test.py ('k') | appengine/monorail/framework/test/servlet_helpers_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698