Ejemplo n.º 1
0
    def test_unicode_request(self):
        """Make sure the request uses Unicode."""
        env = {'QUERY_STRING': 'q=ü'}
        def __endpoint__(request):
            self.assertTrue(isinstance(request.GET, webob.UnicodeMultiDict))

        _wrap_endpoint(__endpoint__)(env)
Ejemplo n.º 2
0
    def test_preserves_docstring(self):
        """Make sure the docstring is preserved in the wrapper function."""
        def endpoint(request):
            """This a test endpoint with some documentation."""
            pass

        endpoint_prime = _wrap_endpoint(endpoint)
        self.assert_(endpoint_prime.__doc__ == endpoint.__doc__)
Ejemplo n.º 3
0
    def test_exceptions_returned(self):
        """Make sure non-HTTPExceptions are returned."""
        ex = Exception("Test exception")

        def test_f(request):
            raise ex

        test_f_prime = _wrap_endpoint(test_f)
        resp = test_f_prime({'HTTP_X_SIMPLEGEO_USER': '******'})
        self.assert_(resp is ex)
Ejemplo n.º 4
0
    def test_http_exceptions_returned(self):
        """Make sure HTTPExceptions are returned."""
        ex = exc.HTTPException(000, "Test exception")

        def test_f(request):
            raise ex

        test_f_prime = _wrap_endpoint(test_f)
        output = test_f_prime({'HTTP_X_SIMPLEGEO_USER': '******'})
        self.assert_(output is ex)
Ejemplo n.º 5
0
    def test_generates_request(self):
        """Make sure request objects are generated."""
        runs = []

        def test_f(request):
            runs.append(True)
            self.assert_(isinstance(request, Request))
            return Response()

        test_f_prime = _wrap_endpoint(test_f)
        output = test_f_prime({'HTTP_X_SIMPLEGEO_USER': '******'})
        self.assert_(len(runs) == 1)
Ejemplo n.º 6
0
 def test_bad_request_missing_header(self):
     """Ensure BadRequest is not returned when user is missing on GETs."""
     endpoint_prime = _wrap_endpoint(lambda req: "test")
     resp = endpoint_prime({'REQUEST_METHOD': 'GET'})
     self.assertEquals(resp, "test")
Ejemplo n.º 7
0
 def test_bad_request_missing_header(self):
     """Ensure BadRequest is returned when X-Simplegeo-User is missing"""
     endpoint_prime = _wrap_endpoint(lambda req: None)
     resp = endpoint_prime({'REQUEST_METHOD': 'POST'})
     self.assertTrue(isinstance(resp, exc.HTTPBadRequest))