Skip to content

Commit

Permalink
Merge pull request #910 from kobotoolbox/health-endpoint
Browse files Browse the repository at this point in the history
Add endpoint to test kobocat health
  • Loading branch information
jnm authored Feb 8, 2024
2 parents 40736fd + 034e2bd commit 9c3ebe0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions onadata/apps/main/service_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
13 changes: 13 additions & 0 deletions onadata/apps/main/tests/test_service_health_minimal.py
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 3 additions & 2 deletions onadata/apps/main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 (
Expand All @@ -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/')),

Expand Down

0 comments on commit 9c3ebe0

Please sign in to comment.