Ejemplo n.º 1
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({
         'PATH_INFO': '/somepath/',
         'REQUEST_METHOD': 'get',
         'wsgi.input': BytesIO(b'')
     })
     request.GET = {'get-key': 'get-value'}
     request.POST = {'post-key': 'post-value'}
     request.COOKIES = {'post-key': 'post-value'}
     request.META = {'post-key': 'post-value'}
     self.assertEqual(
         repr(request),
         str_prefix(
             "<WSGIRequest\npath:/somepath/,\nGET:{%(_)s'get-key': %(_)s'get-value'},\nPOST:{%(_)s'post-key': %(_)s'post-value'},\nCOOKIES:{%(_)s'post-key': %(_)s'post-value'},\nMETA:{%(_)s'post-key': %(_)s'post-value'}>"
         ))
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(
         build_request_repr(request,
                            path_override='/otherpath/',
                            GET_override={'a': 'b'},
                            POST_override={'c': 'd'},
                            COOKIES_override={'e': 'f'},
                            META_override={'g': 'h'}),
         str_prefix(
             "<WSGIRequest\npath:/otherpath/,\nGET:{%(_)s'a': %(_)s'b'},\nPOST:{%(_)s'c': %(_)s'd'},\nCOOKIES:{%(_)s'e': %(_)s'f'},\nMETA:{%(_)s'g': %(_)s'h'}>"
         ))
Ejemplo n.º 2
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({"PATH_INFO": "/somepath/", "REQUEST_METHOD": "get", "wsgi.input": BytesIO(b"")})
     request.GET = {"get-key": "get-value"}
     request.POST = {"post-key": "post-value"}
     request.COOKIES = {"post-key": "post-value"}
     request.META = {"post-key": "post-value"}
     self.assertEqual(
         repr(request),
         str_prefix(
             "<WSGIRequest\npath:/somepath/,\nGET:{%(_)s'get-key': %(_)s'get-value'},\nPOST:{%(_)s'post-key': %(_)s'post-value'},\nCOOKIES:{%(_)s'post-key': %(_)s'post-value'},\nMETA:{%(_)s'post-key': %(_)s'post-value'}>"
         ),
     )
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(
         build_request_repr(
             request,
             path_override="/otherpath/",
             GET_override={"a": "b"},
             POST_override={"c": "d"},
             COOKIES_override={"e": "f"},
             META_override={"g": "h"},
         ),
         str_prefix(
             "<WSGIRequest\npath:/otherpath/,\nGET:{%(_)s'a': %(_)s'b'},\nPOST:{%(_)s'c': %(_)s'd'},\nCOOKIES:{%(_)s'e': %(_)s'f'},\nMETA:{%(_)s'g': %(_)s'h'}>"
         ),
     )
Ejemplo n.º 3
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     self.assertEqual(repr(request), "<WSGIRequest: GET '/'>")
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     request.GET = {'get-key': 'get-value'}
     request.POST = {'post-key': 'post-value'}
     request.COOKIES = {'post-key': 'post-value'}
     request.META = {'post-key': 'post-value'}
     self.assertEqual(repr(request), "<WSGIRequest: GET '/somepath/'>")
Ejemplo n.º 4
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     self.assertEqual(repr(request), str_prefix("<WSGIRequest: GET '/'>"))
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     request.GET = {'get-key': 'get-value'}
     request.POST = {'post-key': 'post-value'}
     request.COOKIES = {'post-key': 'post-value'}
     request.META = {'post-key': 'post-value'}
     self.assertEqual(repr(request), str_prefix("<WSGIRequest: GET '/somepath/'>"))
Ejemplo n.º 5
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({"REQUEST_METHOD": "get", "wsgi.input": BytesIO(b"")})
     self.assertEqual(repr(request), str_prefix("<WSGIRequest: GET '/'>"))
     request = WSGIRequest({"PATH_INFO": "/somepath/", "REQUEST_METHOD": "get", "wsgi.input": BytesIO(b"")})
     request.GET = {"get-key": "get-value"}
     request.POST = {"post-key": "post-value"}
     request.COOKIES = {"post-key": "post-value"}
     request.META = {"post-key": "post-value"}
     self.assertEqual(repr(request), str_prefix("<WSGIRequest: GET '/somepath/'>"))
Ejemplo n.º 6
0
Archivo: tests.py Proyecto: 10sr/hue
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     request.GET = {'get-key': 'get-value'}
     request.POST = {'post-key': 'post-value'}
     request.COOKIES = {'post-key': 'post-value'}
     request.META = {'post-key': 'post-value'}
     self.assertEqual(repr(request), str_prefix("<WSGIRequest\npath:/somepath/,\nGET:{%(_)s'get-key': %(_)s'get-value'},\nPOST:{%(_)s'post-key': %(_)s'post-value'},\nCOOKIES:{%(_)s'post-key': %(_)s'post-value'},\nMETA:{%(_)s'post-key': %(_)s'post-value'}>"))
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={'a': 'b'}, POST_override={'c': 'd'}, COOKIES_override={'e': 'f'}, META_override={'g': 'h'}),
                      str_prefix("<WSGIRequest\npath:/otherpath/,\nGET:{%(_)s'a': %(_)s'b'},\nPOST:{%(_)s'c': %(_)s'd'},\nCOOKIES:{%(_)s'e': %(_)s'f'},\nMETA:{%(_)s'g': %(_)s'h'}>"))
Ejemplo n.º 7
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': StringIO('')})
     request.GET = {u'get-key': u'get-value'}
     request.POST = {u'post-key': u'post-value'}
     request.COOKIES = {u'post-key': u'post-value'}
     request.META = {u'post-key': u'post-value'}
     self.assertEqual(repr(request), u"<WSGIRequest\npath:/somepath/,\nGET:{u'get-key': u'get-value'},\nPOST:{u'post-key': u'post-value'},\nCOOKIES:{u'post-key': u'post-value'},\nMETA:{u'post-key': u'post-value'}>")
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={u'a': u'b'}, POST_override={u'c': u'd'}, COOKIES_override={u'e': u'f'}, META_override={u'g': u'h'}),
                      u"<WSGIRequest\npath:/otherpath/,\nGET:{u'a': u'b'},\nPOST:{u'c': u'd'},\nCOOKIES:{u'e': u'f'},\nMETA:{u'g': u'h'}>")
Ejemplo n.º 8
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': StringIO('')})
     request.GET = {u'get-key': u'get-value'}
     request.POST = {u'post-key': u'post-value'}
     request.COOKIES = {u'post-key': u'post-value'}
     request.META = {u'post-key': u'post-value'}
     self.assertEqual(repr(request), u"<WSGIRequest\npath:/somepath/,\nGET:{u'get-key': u'get-value'},\nPOST:{u'post-key': u'post-value'},\nCOOKIES:{u'post-key': u'post-value'},\nMETA:{u'post-key': u'post-value'}>")
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={u'a': u'b'}, POST_override={u'c': u'd'}, COOKIES_override={u'e': u'f'}, META_override={u'g': u'h'}),
                      u"<WSGIRequest\npath:/otherpath/,\nGET:{u'a': u'b'},\nPOST:{u'c': u'd'},\nCOOKIES:{u'e': u'f'},\nMETA:{u'g': u'h'}>")
Ejemplo n.º 9
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({
         "REQUEST_METHOD": "get",
         "wsgi.input": BytesIO(b"")
     })
     self.assertEqual(repr(request), "<WSGIRequest: GET '/'>")
     request = WSGIRequest({
         "PATH_INFO": "/somepath/",
         "REQUEST_METHOD": "get",
         "wsgi.input": BytesIO(b""),
     })
     request.GET = {"get-key": "get-value"}
     request.POST = {"post-key": "post-value"}
     request.COOKIES = {"post-key": "post-value"}
     request.META = {"post-key": "post-value"}
     self.assertEqual(repr(request), "<WSGIRequest: GET '/somepath/'>")
Ejemplo n.º 10
0
def test_post_data(django_elasticapm_client):
    request = WSGIRequest(environ={
        'wsgi.input': compat.BytesIO(),
        'REQUEST_METHOD': 'POST',
        'SERVER_NAME': 'testserver',
        'SERVER_PORT': '80',
        'CONTENT_TYPE': 'application/json',
        'ACCEPT': 'application/json',
    })
    request.POST = QueryDict("x=1&y=2")
    django_elasticapm_client.capture('Message', message='foo', request=request)

    assert len(django_elasticapm_client.events) == 1
    event = django_elasticapm_client.events.pop(0)['errors'][0]

    assert 'request' in event['context']
    request = event['context']['request']
    assert request['method'] == 'POST'
    assert request['body'] == {'x': '1', 'y': '2'}
Ejemplo n.º 11
0
    def test_post_data(self):
        request = WSGIRequest(environ={
            'wsgi.input': six.BytesIO(),
            'REQUEST_METHOD': 'POST',
            'SERVER_NAME': 'testserver',
            'SERVER_PORT': '80',
            'CONTENT_TYPE': 'application/octet-stream',
            'ACCEPT': 'application/json',
        })
        request.POST = QueryDict("x=1&y=2")
        self.opbeat.capture('Message', message='foo', request=request)

        self.assertEquals(len(self.opbeat.events), 1)
        event = self.opbeat.events.pop(0)

        self.assertTrue('http' in event)
        http = event['http']
        self.assertEquals(http['method'], 'POST')
        self.assertEquals(http['data'], {'x': '1', 'y': '2'})