[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/develop] Add class wrapper for requesthelper.DummyRequest to support redirects.



commit ad774181faa5cd367e4173ce14a4449a3164abeb
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Wed Mar 19 17:57:09 2014 +0000

    Add class wrapper for requesthelper.DummyRequest to support redirects.
---
 lib/bridgedb/test/test_HTTPServer.py |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/bridgedb/test/test_HTTPServer.py b/lib/bridgedb/test/test_HTTPServer.py
index e2856c7..73297de 100644
--- a/lib/bridgedb/test/test_HTTPServer.py
+++ b/lib/bridgedb/test/test_HTTPServer.py
@@ -445,3 +445,23 @@ class DummyIPBasedDistributor(object):
         :meth:`WebResourceBridges.getBridgesForIP`.
         """
         return [DummyBridge() for _ in xrange(N)]
+
+
+class DummyRequest(requesthelper.DummyRequest):
+    """Wrapper for :api:`twisted.test.requesthelper.DummyRequest` to add
+    redirect support.
+    """
+
+    def __init__(self, *args, **kwargs):
+        requesthelper.DummyRequest.__init__(self, *args, **kwargs)
+        self.redirect = self._redirect(self)
+
+    def URLPath(self):
+        """Fake the missing Request.URLPath too."""
+        return self.uri
+
+    def _redirect(self, request):
+        """Stub method to add a redirect() method to DummyResponse."""
+        newRequest = type(request)
+        newRequest.uri = request.uri
+        return newRequest



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits