[tor-commits] [bridgedb/master] Add unittests for HTTPServer.WebResourceOptions.

isis at torproject.org isis at torproject.org
Wed Mar 26 05:49:32 UTC 2014


commit 27280d9fc6aa527eb7a80708df1b25195840567a
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed Mar 26 05:10:26 2014 +0000

    Add unittests for HTTPServer.WebResourceOptions.
---
 lib/bridgedb/test/test_HTTPServer.py |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/lib/bridgedb/test/test_HTTPServer.py b/lib/bridgedb/test/test_HTTPServer.py
index 872be3c..c7308a3 100644
--- a/lib/bridgedb/test/test_HTTPServer.py
+++ b/lib/bridgedb/test/test_HTTPServer.py
@@ -641,3 +641,29 @@ class WebResourceBridgesTests(unittest.TestCase):
             self.assertIsInstance(int(port), int)
             self.assertGreater(int(port), 0)
             self.assertLessEqual(int(port), 65535)
+
+
+class WebResourceOptionsTests(unittest.TestCase):
+    """Tests for :class:`bridgedb.HTTPServer.WebResourceOptions`."""
+
+    def setUp(self):
+        """Create a :class:`HTTPServer.WebResourceOptions`."""
+        # Set up our resources to fake a minimal HTTP(S) server:
+        self.pagename = b'options.html'
+        self.root = Resource()
+        self.optionsResource = HTTPServer.WebResourceOptions()
+        self.root.putChild(self.pagename, self.optionsResource)
+
+    def test_render_GET_RTLlang(self):
+        """Test rendering a request for obfs3 bridges in Arabic."""
+        request = DummyRequest(["bridges?transport=obfs3"])
+        request.method = b'GET'
+        request.getClientIP = lambda: '3.3.3.3'
+        request.headers.update({'accept-language': 'he'})
+        # We actually have to set the request args manually when using a
+        # DummyRequest:
+        request.args.update({'transport': 'obfs2'})
+
+        page = self.optionsResource.render(request)
+        self.assertSubstring("direction: rtl", page)
+        self.assertSubstring("מהם גשרים?", page)





More information about the tor-commits mailing list