diff --git a/backend/api/test_views.py b/backend/api/test_views.py index b9b74a7c62..2246d33045 100644 --- a/backend/api/test_views.py +++ b/backend/api/test_views.py @@ -8,7 +8,6 @@ from rest_framework.test import APIClient from api.test_uei import valid_uei_results -from api.views import SACViewSet from audit.models import Access, SingleAuditChecklist User = get_user_model() @@ -18,7 +17,6 @@ ACCESS_AND_SUBMISSION_PATH = reverse("api-accessandsubmission") SUBMISSIONS_PATH = reverse("submissions") ACCESS_LIST_PATH = reverse("access-list") -SAC_LIST_PATH = reverse("sac-list") VALID_AUDITEE_INFO_DATA = { @@ -910,106 +908,6 @@ def test_deleted_access_not_returned(self): self.assertEqual(data_2[0]["report_id"], access_1.sac.report_id) -class SACViewSetTests(TestCase): - def setUp(self): - self.client = APIClient() - - def test_list_no_auth_required(self): - """ - The SACViewSet should not require authentication or permissions - """ - self.assertEqual(SACViewSet.authentication_classes, []) - self.assertEqual(SACViewSet.permission_classes, []) - - def test_list_no_audits_returns_empty_list(self): - """ - If there are no SACs in the database, the list endpoint should return no results - """ - response = self.client.get(SAC_LIST_PATH) - data = response.json() - - self.assertEqual(response.status_code, 200) - self.assertEqual(data, []) - - def test_list_none_submitted_returns_empty_list(self): - """ - If there are SACs in the database, but none which have a status of submitted, the list endpoint shoul return no results - """ - for status in SingleAuditChecklist.STATUS_CHOICES: - if status[0] != SingleAuditChecklist.STATUS.SUBMITTED: - baker.make( - SingleAuditChecklist, _quantity=100, submission_status=status[0] - ) - - response = self.client.get(SAC_LIST_PATH) - data = response.json() - - self.assertEqual(response.status_code, 200) - self.assertEqual(data, []) - - def test_list_returns_only_submitted(self): - """ - If there are SACs in the database, only those with a submission_status of "submitted" should be returned - """ - for status in SingleAuditChecklist.STATUS_CHOICES: - baker.make(SingleAuditChecklist, _quantity=100, submission_status=status[0]) - - response = self.client.get(SAC_LIST_PATH) - data = response.json() - - self.assertEqual(len(data), 100) - self.assertTrue( - all(audit["submission_status"] == "submitted" for audit in data) - ) - - def test_detail_no_match_returns_404(self): - """ - If there is no SAC matching the provided report_id, the detail endpoint should return 404 - """ - url = reverse("sac-detail", kwargs={"report_id": "not-a-real-report-id"}) - - response = self.client.get(url) - - self.assertEqual(response.status_code, 404) - - def test_detail_match_submitted_returns_sac(self): - """ - If there is a SAC matching the provided report_id, and the SAC has a submission_status of submitted, the detail endpoint should return the SAC - """ - report_id = "test-report-id" - sac = baker.make( - SingleAuditChecklist, report_id=report_id, submission_status="submitted" - ) - - url = reverse("sac-detail", kwargs={"report_id": report_id}) - - response = self.client.get(url) - data = response.json() - - self.assertEqual(response.status_code, 200) - self.assertTrue(data, sac) - - def test_detail_match_unsubmitted_returns_404(self): - """ - If there is a SAC matching the provided report_id, and the SAC has a submission_status other than submitted, the detail endpoint should return a 404 - """ - for status in SingleAuditChecklist.STATUS_CHOICES: - with self.subTest(): - if status[0] != SingleAuditChecklist.STATUS.SUBMITTED: - report_id = f"id-{status[0]}"[:17] - baker.make( - SingleAuditChecklist, - report_id=report_id, - submission_status=status[0], - ) - - url = reverse("sac-detail", kwargs={"report_id": report_id}) - - response = self.client.get(url) - - self.assertEqual(response.status_code, 404) - - class SchemaViewTests(TestCase): def setUp(self): self.fiscal_years = [ diff --git a/backend/api/views.py b/backend/api/views.py index 4805dbbdd6..24ca4d45a1 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -3,9 +3,8 @@ from django.http import Http404, HttpResponse, JsonResponse from django.urls import reverse -from django.views import View, generic +from django.views import generic from django.contrib.auth import get_user_model -from rest_framework import viewsets from rest_framework.authentication import BaseAuthentication from rest_framework.permissions import BasePermission, IsAuthenticated from rest_framework.response import Response @@ -199,33 +198,6 @@ def get(self, _request): ) -class IndexView(View): - def get(self, request, *args, **kwargs): - fpath = BASE_DIR / "static" / "index.html" - return HttpResponse(content=fpath.read_text(encoding="utf-8")) - - -class SACViewSet(viewsets.ModelViewSet): - """ - API endpoint that allows SACs to be viewed. - """ - - # this is a public endpoint - no authentication or permission required - authentication_classes: List[BaseAuthentication] = [] - permission_classes: List[BasePermission] = [] - - allowed_methods = ["GET"] - - # lookup SACs with report_id rather than the default pk - lookup_field = "report_id" - - queryset = SingleAuditChecklist.objects.filter(submission_status="submitted") - serializer_class = SingleAuditChecklistSerializer - - def get_view_name(self): - return "SF-SAC" - - class EligibilityFormView(APIView): """ Accepts information from Step 1 (Submission criteria check) of the "Create New Audit" diff --git a/backend/config/urls.py b/backend/config/urls.py index 79e5a8eae8..f7ffc17b70 100644 --- a/backend/config/urls.py +++ b/backend/config/urls.py @@ -18,14 +18,7 @@ ) urlpatterns = [ - # path("", IndexView.as_view(), name="index"), path("api/schema.json", schema_view), - path("public/api/sac", views.SACViewSet.as_view({"get": "list"}), name="sac-list"), - path( - "public/api/sac/", - views.SACViewSet.as_view({"get": "retrieve"}), - name="sac-detail", - ), path( "api/sac/eligibility", views.EligibilityFormView.as_view(),