get logging test endpoint to work again

The handler and formatter classes are expecting an object
and the previous method passed a dict, so this change converts
the data into a mock settings object.
This commit is contained in:
AlanCoding
2017-06-28 14:17:46 -04:00
parent 7d283f1dfd
commit c1ff41fa45
3 changed files with 14 additions and 18 deletions

View File

@@ -152,7 +152,12 @@ class SettingLoggingTest(GenericAPIView):
serializer = self.get_serializer(obj, data=request.data)
serializer.is_valid(raise_exception=True)
try:
BaseHTTPSHandler.perform_test(serializer.validated_data)
class MockSettings:
pass
mock_settings = MockSettings()
for k, v in serializer.validated_data.items():
setattr(mock_settings, k, v)
BaseHTTPSHandler.perform_test(mock_settings)
except LoggingConnectivityException as e:
return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
return Response(status=status.HTTP_200_OK)