From cb8e3140a44f219ac47608fb5c36b14b7ff4ad37 Mon Sep 17 00:00:00 2001 From: moanos Date: Thu, 30 May 2024 11:46:05 +0200 Subject: [PATCH] test: Add test for detail of animal adoption --- src/tests/test_views.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tests/test_views.py b/src/tests/test_views.py index 68dbc56..e252193 100644 --- a/src/tests/test_views.py +++ b/src/tests/test_views.py @@ -6,15 +6,13 @@ from model_bakery import baker from fellchensammlung.models import Animal, Species, AdoptionNotice, User -class AnimalTest(TestCase): +class AnimalAndAdoptionTest(TestCase): @classmethod def setUpTestData(cls): test_user0 = User.objects.create_user(username='testuser0', first_name="Admin", last_name="BOFH", password='12345') - permission_view_user = Permission.objects.get(codename='view_member') - test_user0.user_permissions.add(permission_view_user) test_user1 = User.objects.create_user(username='testuser1', first_name="Max", @@ -31,7 +29,7 @@ class AnimalTest(TestCase): species=rat, description="Eine unglaublich süße Ratte") - def test_detail(self): + def test_detail_animal(self): self.client.login(username='testuser0', password='12345') response = self.client.post(reverse('animal-detail', args="1")) @@ -39,3 +37,13 @@ class AnimalTest(TestCase): # Check our user is logged in self.assertEqual(str(response.context['user']), 'testuser0') self.assertContains(response, "Rat1") + + def test_detail_animal_notice(self): + self.client.login(username='testuser0', password='12345') + + response = self.client.post(reverse('adoption-notice-detail', args="1")) + self.assertEqual(response.status_code, 200) + # Check our user is logged in + self.assertEqual(str(response.context['user']), 'testuser0') + self.assertContains(response, "TestAdoption1") + self.assertContains(response, "Rat1")