Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/penndata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.shortcuts import get_object_or_404
from django.utils import timezone
from requests.exceptions import ConnectionError
from rest_framework import generics
from rest_framework import generics, status
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
Expand All @@ -31,6 +31,11 @@
from pennmobile.analytics import LabsAnalytics


class Health(APIView):
def get(self, request):
return Response({"message": "OK"}, status=status.HTTP_200_OK)


class News(APIView):
"""
GET: Get's news article from the DP
Expand Down
3 changes: 3 additions & 0 deletions backend/pennmobile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.views.generic import TemplateView
from rest_framework.schemas import get_schema_view

from penndata.views import Health


urlpatterns = [
path("gsr/", include("gsr_booking.urls")),
Expand Down Expand Up @@ -56,6 +58,7 @@ def universal_identifier_link(request):
urlpatterns = [
path("api/", include(urlpatterns)),
path("", include((urlpatterns, "apex"))),
path("health/", Health.as_view(), name="health"),
path(
".well-known/apple-app-site-association", universal_identifier_link, name="universal-links"
),
Expand Down
9 changes: 9 additions & 0 deletions backend/tests/penndata/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
from rest_framework import status
from rest_framework.test import APIClient

from dining.models import Venue
Expand Down Expand Up @@ -36,6 +37,14 @@ def fakeFitnessGet(url, *args, **kwargs):
User = get_user_model()


class HealthTestCase(TestCase):
def test_health_check(self):
url = reverse("health")
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, {"message": "OK"})


class TestNews(TestCase):
def test_response(self):
response = self.client.get(reverse("news"))
Expand Down
Loading