diff --git a/onadata/apps/main/service_health.py b/onadata/apps/main/service_health.py index ebbda26a7..1e79f76a7 100644 --- a/onadata/apps/main/service_health.py +++ b/onadata/apps/main/service_health.py @@ -48,3 +48,5 @@ def service_health(request): output, status=(500 if any_failure else 200), content_type='text/plain' ) +def service_health_minimal(request): + return HttpResponse("ok", content_type="text/plain") diff --git a/onadata/apps/main/tests/test_service_health_minimal.py b/onadata/apps/main/tests/test_service_health_minimal.py new file mode 100644 index 000000000..f4d49eed4 --- /dev/null +++ b/onadata/apps/main/tests/test_service_health_minimal.py @@ -0,0 +1,13 @@ +from django.test import TestCase +from django.urls import reverse + + +class ServiceHealthMinimalTestCase(TestCase): + url = reverse("service-health-minimal") + + def test_service_health_minimal(self): + with self.assertNumQueries(0): + res = self.client.get(self.url) + + # Check that the response content contains "ok" + self.assertContains(res, "ok") diff --git a/onadata/apps/main/urls.py b/onadata/apps/main/urls.py index 5c310443b..92130dcc4 100644 --- a/onadata/apps/main/urls.py +++ b/onadata/apps/main/urls.py @@ -2,7 +2,7 @@ from django.conf import settings from django.contrib import admin -from django.urls import include, re_path +from django.urls import include, re_path, path from django.views.generic import RedirectView from django.views.i18n import JavaScriptCatalog @@ -11,7 +11,7 @@ from onadata.apps.api.urls import XFormListApi from onadata.apps.api.urls import XFormSubmissionApi from onadata.apps.api.urls import router, router_with_patch_list -from onadata.apps.main.service_health import service_health +from onadata.apps.main.service_health import service_health, service_health_minimal # exporting stuff from onadata.apps.viewer.views import ( @@ -37,6 +37,7 @@ re_path('^api/v1/', include(router.urls)), re_path('^api/v1/', include(router_with_patch_list.urls)), re_path(r'^service_health/$', service_health), + path(r'service_health/minimal/', service_health_minimal, name='service-health-minimal'), re_path(r'^api/', RedirectView.as_view(url='/api/v1/')), re_path(r'^api/v1', RedirectView.as_view(url='/api/v1/')),