From de30dfcb8b2b186c0731343965070c4623831193 Mon Sep 17 00:00:00 2001 From: moanos Date: Sat, 18 Jan 2025 21:39:45 +0100 Subject: [PATCH] tests: Add test for unsubscribe --- .../test_advanced_views.py} | 14 ++++++++++++++ 1 file changed, 14 insertions(+) rename src/tests/{test_views.py => test_views/test_advanced_views.py} (95%) diff --git a/src/tests/test_views.py b/src/tests/test_views/test_advanced_views.py similarity index 95% rename from src/tests/test_views.py rename to src/tests/test_views/test_advanced_views.py index 195cd36..acf5727 100644 --- a/src/tests/test_views.py +++ b/src/tests/test_views/test_advanced_views.py @@ -264,6 +264,20 @@ class AdoptionDetailTest(TestCase): data={"action": "subscribe"}) self.assertTrue(Subscriptions.objects.filter(owner__username="testuser0").exists()) + + def test_unsubscribe(self): + # Make sure subscription exists + an = AdoptionNotice.objects.get(name="TestAdoption1") + user = User.objects.get(username="testuser0") + subscription = Subscriptions.objects.get_or_create(owner=user, adoption_notice=an) + + # Unsubscribe + self.client.login(username='testuser0', password='12345') + response = self.client.post( + reverse('adoption-notice-detail', args=str(an.pk)), + data={"action": "unsubscribe"}) + self.assertFalse(Subscriptions.objects.filter(owner__username="testuser0").exists()) + def test_login_required(self): response = self.client.post( reverse('adoption-notice-detail', args=str(AdoptionNotice.objects.get(name="TestAdoption1").pk)),