fix (test): Notification framework changed
This commit is contained in:
@@ -85,8 +85,8 @@ class TestNotifications(TestCase):
|
||||
cls.test_user_1 = User.objects.create(username="Testuser1", password="SUPERSECRET", email="test@example.org")
|
||||
|
||||
def test_mark_read(self):
|
||||
not1 = Notification.objects.create(user=self.test_user_1, text="New rats to adopt", title="🔔 New Rat alert")
|
||||
not2 = Notification.objects.create(user=self.test_user_1,
|
||||
not1 = Notification.objects.create(user_to_notify=self.test_user_1, text="New rats to adopt", title="🔔 New Rat alert")
|
||||
not2 = Notification.objects.create(user_to_notify=self.test_user_1,
|
||||
text="New wombat to adopt", title="🔔 New Wombat alert")
|
||||
not1.mark_read()
|
||||
|
||||
|
@@ -3,10 +3,11 @@ from time import sleep
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from fellchensammlung.models import SearchSubscription, User, TrustLevel, AdoptionNotice, Location, SexChoicesWithAll, \
|
||||
Animal, Species, AdoptionNoticeNotification, SexChoices
|
||||
Animal, Species, SexChoices, Notification
|
||||
from model_bakery import baker
|
||||
|
||||
from fellchensammlung.tools.geo import LocationProxy
|
||||
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
|
||||
from fellchensammlung.tools.search import Search, notify_search_subscribers
|
||||
|
||||
|
||||
@@ -100,5 +101,7 @@ class TestSearch(TestCase):
|
||||
"""
|
||||
notify_search_subscribers(self.adoption1)
|
||||
|
||||
self.assertTrue(AdoptionNoticeNotification.objects.filter(user=self.test_user1, adoption_notice=self.adoption1).exists())
|
||||
self.assertFalse(AdoptionNoticeNotification.objects.filter(user=self.test_user2).exists())
|
||||
self.assertTrue(Notification.objects.filter(user_to_notify=self.test_user1,
|
||||
adoption_notice=self.adoption1,
|
||||
notification_type=NotificationTypeChoices.AN_FOR_SEARCH_FOUND).exists())
|
||||
self.assertFalse(Notification.objects.filter(user_to_notify=self.test_user2,).exists())
|
||||
|
@@ -1,7 +1,8 @@
|
||||
from django.test import TestCase
|
||||
from model_bakery import baker
|
||||
|
||||
from fellchensammlung.models import User, TrustLevel, Species, Location, AdoptionNotice, AdoptionNoticeNotification
|
||||
from fellchensammlung.models import User, TrustLevel, Species, Location, AdoptionNotice, Notification
|
||||
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
|
||||
from fellchensammlung.tools.notifications import notify_of_AN_to_be_checked
|
||||
|
||||
|
||||
@@ -24,11 +25,17 @@ class TestNotifications(TestCase):
|
||||
cls.test_user0.trust_level = TrustLevel.ADMIN
|
||||
cls.test_user0.save()
|
||||
|
||||
cls.adoption1 = baker.make(AdoptionNotice, name="TestAdoption1", owner=cls.test_user1,)
|
||||
cls.adoption1.set_unchecked() # Could also emit notification
|
||||
cls.adoption1 = baker.make(AdoptionNotice, name="TestAdoption1", owner=cls.test_user1, )
|
||||
cls.adoption1.set_unchecked() # Could also emit notification
|
||||
|
||||
def test_notify_of_AN_to_be_checked(self):
|
||||
notify_of_AN_to_be_checked(self.adoption1)
|
||||
self.assertTrue(AdoptionNoticeNotification.objects.filter(user=self.test_user0).exists())
|
||||
self.assertTrue(AdoptionNoticeNotification.objects.filter(user=self.test_user1).exists())
|
||||
self.assertFalse(AdoptionNoticeNotification.objects.filter(user=self.test_user2).exists())
|
||||
self.assertTrue(Notification.objects.filter(user_to_notify=self.test_user0,
|
||||
adoption_notice=self.adoption1,
|
||||
notification_type=NotificationTypeChoices.AN_IS_TO_BE_CHECKED).exists())
|
||||
self.assertTrue(Notification.objects.filter(user_to_notify=self.test_user1,
|
||||
adoption_notice=self.adoption1,
|
||||
notification_type=NotificationTypeChoices.AN_IS_TO_BE_CHECKED).exists())
|
||||
self.assertFalse(Notification.objects.filter(user_to_notify=self.test_user2,
|
||||
adoption_notice=self.adoption1,
|
||||
notification_type=NotificationTypeChoices.AN_IS_TO_BE_CHECKED).exists())
|
||||
|
@@ -5,8 +5,9 @@ from django.urls import reverse
|
||||
from model_bakery import baker
|
||||
|
||||
from fellchensammlung.models import Animal, Species, AdoptionNotice, User, Location, AdoptionNoticeStatus, TrustLevel, \
|
||||
Animal, Subscriptions, Comment, CommentNotification, SearchSubscription
|
||||
Animal, Subscriptions, Comment, Notification, SearchSubscription
|
||||
from fellchensammlung.tools.geo import LocationProxy
|
||||
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
|
||||
from fellchensammlung.views import add_adoption_notice
|
||||
|
||||
|
||||
@@ -34,15 +35,6 @@ class AnimalAndAdoptionTest(TestCase):
|
||||
species=rat,
|
||||
description="Eine unglaublich süße Ratte")
|
||||
|
||||
def test_detail_animal(self):
|
||||
self.client.login(username='testuser0', password='12345')
|
||||
|
||||
response = self.client.post(reverse('animal-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, "Rat1")
|
||||
|
||||
def test_detail_animal_notice(self):
|
||||
self.client.login(username='testuser0', password='12345')
|
||||
|
||||
@@ -339,8 +331,10 @@ class AdoptionDetailTest(TestCase):
|
||||
reverse('adoption-notice-detail', args=str(an1.pk)),
|
||||
data={"action": "comment", "text": "Test"})
|
||||
self.assertTrue(Comment.objects.filter(user__username="testuser0").exists())
|
||||
self.assertFalse(CommentNotification.objects.filter(user__username="testuser0").exists())
|
||||
self.assertTrue(CommentNotification.objects.filter(user__username="testuser1").exists())
|
||||
self.assertFalse(Notification.objects.filter(user_to_notify__username="testuser0",
|
||||
notification_type=NotificationTypeChoices.NEW_COMMENT).exists())
|
||||
self.assertTrue(Notification.objects.filter(user_to_notify__username="testuser1",
|
||||
notification_type=NotificationTypeChoices.NEW_COMMENT).exists())
|
||||
|
||||
|
||||
class AdoptionEditTest(TestCase):
|
||||
|
Reference in New Issue
Block a user