Skip to content

Commit

Permalink
Merge pull request #100 from MindscapeHQ/cm/apl-123/resolve-crash-on-…
Browse files Browse the repository at this point in the history
…logging-post-requests

Resolve crash reports not logging post requests in Django
  • Loading branch information
Callum-McKay authored Nov 5, 2021
2 parents ac5b5d0 + da067a3 commit 8428779
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion python2/tests/middleware/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ class DjangoProviderTests(SimpleTestCase):
def setUp(self):
request_factory = RequestFactory()
self.get_request = request_factory.get('/foo')
self.post_request = request_factory.post('/foo')

def test_map_request(self):
def test_get_map_request(self):
provider = Provider()
request_payload = provider._mapRequest(self.get_request)
self.assertEqual(request_payload['url'], '/foo')
self.assertEqual(request_payload['httpMethod'], 'GET')

def test_post_map_request(self):
provider = Provider()
request_payload = provider._mapRequest(self.post_request)
self.assertEqual(request_payload['url'], '/foo')
self.assertEqual(request_payload['httpMethod'], 'POST')

def test_get_django_environment(self):
provider = Provider()
environment_payload = provider._get_django_environment()
Expand Down
2 changes: 1 addition & 1 deletion python3/raygun4py/middleware/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _mapRequest(self, request):
'queryString': dict((key, request.GET[key]) for key in request.GET),
'form': dict((key, request.POST[key]) for key in request.POST),
'headers': _headers,
'rawData': request.body if hasattr(request, 'body') else getattr(request, 'raw_post_data', {})
'rawData': request.data if hasattr(request, 'data') else getattr(request, 'raw_post_data', {})
}

def _get_django_environment(self):
Expand Down
9 changes: 8 additions & 1 deletion python3/tests/middleware/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ class DjangoProviderTests(SimpleTestCase):
def setUp(self):
request_factory = RequestFactory()
self.get_request = request_factory.get('/foo')
self.post_request = request_factory.post('/foo')

def test_map_request(self):
def test_get_map_request(self):
provider = Provider()
request_payload = provider._mapRequest(self.get_request)
self.assertEqual(request_payload['url'], '/foo')
self.assertEqual(request_payload['httpMethod'], 'GET')

def test_post_map_request(self):
provider = Provider()
request_payload = provider._mapRequest(self.post_request)
self.assertEqual(request_payload['url'], '/foo')
self.assertEqual(request_payload['httpMethod'], 'POST')

def test_get_django_environment(self):
provider = Provider()
environment_payload = provider._get_django_environment()
Expand Down

0 comments on commit 8428779

Please sign in to comment.