From c190299ccf4db193a31d5fe84457cddc2a3f56a8 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 19 Dec 2024 15:10:36 -0800 Subject: [PATCH] Improve coverage for auditor app --- .../auditor/tests/test_views.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/anvil_consortium_manager/auditor/tests/test_views.py b/anvil_consortium_manager/auditor/tests/test_views.py index a493fbdb..cd4db9d7 100644 --- a/anvil_consortium_manager/auditor/tests/test_views.py +++ b/anvil_consortium_manager/auditor/tests/test_views.py @@ -1452,6 +1452,27 @@ def test_post_blank_data_note(self): self.assertIn("required", form.errors["note"][0]) self.assertEqual(models.IgnoredManagedGroupMembership.objects.count(), 0) + def test_get_object_exists(self): + obj = factories.IgnoredManagedGroupMembershipFactory.create() + self.client.force_login(self.user) + response = self.client.get(self.get_url(obj.group.name, obj.ignored_email)) + self.assertRedirects(response, obj.get_absolute_url()) + + def test_post_object_exists(self): + obj = factories.IgnoredManagedGroupMembershipFactory.create() + self.client.force_login(self.user) + response = self.client.post( + self.get_url(obj.group.name, obj.ignored_email), + { + "group": obj.group.pk, + "ignored_email": obj.ignored_email, + "note": fake.sentence(), + }, + ) + self.assertRedirects(response, obj.get_absolute_url()) + self.assertEqual(models.IgnoredManagedGroupMembership.objects.count(), 1) + self.assertIn(obj, models.IgnoredManagedGroupMembership.objects.all()) + class IgnoredManagedGroupMembershipDeleteTest(TestCase): def setUp(self):