From 66cbb7cbe3cfe408fe84d5a4d5d4403f48171557 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 27 Feb 2024 11:07:24 -0800 Subject: [PATCH] Additional coverage and related bug fix --- primed/dbgap/tests/test_views.py | 8 ++++---- primed/dbgap/views.py | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/primed/dbgap/tests/test_views.py b/primed/dbgap/tests/test_views.py index 9953cc4d..e345cbaf 100644 --- a/primed/dbgap/tests/test_views.py +++ b/primed/dbgap/tests/test_views.py @@ -4986,17 +4986,17 @@ def test_access_without_user_permission(self): self.get_view()(request) def test_dbgap_application_does_not_exist(self): + """Raises a 404 error with an invalid object dbgap_application_pk.""" dbgap_workspace = factories.dbGaPWorkspaceFactory.create() - request = self.factory.get( + self.client.force_login(self.user) + response = self.client.get( self.get_url( 1, dbgap_workspace.workspace.billing_project.name, dbgap_workspace.workspace.name, ) ) - request.user = self.user - with self.assertRaises(Http404): - self.get_view()(request) + self.assertEqual(response.status_code, 404) def test_billing_project_does_not_exist(self): dbgap_application = factories.dbGaPApplicationFactory.create() diff --git a/primed/dbgap/views.py b/primed/dbgap/views.py index c02a1e0b..f9f59185 100644 --- a/primed/dbgap/views.py +++ b/primed/dbgap/views.py @@ -693,10 +693,7 @@ def get_dbgap_application(self, queryset=None): dbgap_project_id=self.kwargs.get("dbgap_project_id") ) except models.dbGaPApplication.DoesNotExist: - raise Http404( - "No %(verbose_name)s found matching the query" - % {"verbose_name": queryset.model._meta.verbose_name} - ) + raise Http404("No dbGaPApplications found matching the query") return obj def get_audit_result(self):