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")
|
cls.test_user_1 = User.objects.create(username="Testuser1", password="SUPERSECRET", email="test@example.org")
|
||||||
|
|
||||||
def test_mark_read(self):
|
def test_mark_read(self):
|
||||||
not1 = Notification.objects.create(user=self.test_user_1, text="New rats to adopt", title="🔔 New Rat alert")
|
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=self.test_user_1,
|
not2 = Notification.objects.create(user_to_notify=self.test_user_1,
|
||||||
text="New wombat to adopt", title="🔔 New Wombat alert")
|
text="New wombat to adopt", title="🔔 New Wombat alert")
|
||||||
not1.mark_read()
|
not1.mark_read()
|
||||||
|
|
||||||
|
@@ -3,10 +3,11 @@ from time import sleep
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from fellchensammlung.models import SearchSubscription, User, TrustLevel, AdoptionNotice, Location, SexChoicesWithAll, \
|
from fellchensammlung.models import SearchSubscription, User, TrustLevel, AdoptionNotice, Location, SexChoicesWithAll, \
|
||||||
Animal, Species, AdoptionNoticeNotification, SexChoices
|
Animal, Species, SexChoices, Notification
|
||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
|
|
||||||
from fellchensammlung.tools.geo import LocationProxy
|
from fellchensammlung.tools.geo import LocationProxy
|
||||||
|
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
|
||||||
from fellchensammlung.tools.search import Search, notify_search_subscribers
|
from fellchensammlung.tools.search import Search, notify_search_subscribers
|
||||||
|
|
||||||
|
|
||||||
@@ -100,5 +101,7 @@ class TestSearch(TestCase):
|
|||||||
"""
|
"""
|
||||||
notify_search_subscribers(self.adoption1)
|
notify_search_subscribers(self.adoption1)
|
||||||
|
|
||||||
self.assertTrue(AdoptionNoticeNotification.objects.filter(user=self.test_user1, adoption_notice=self.adoption1).exists())
|
self.assertTrue(Notification.objects.filter(user_to_notify=self.test_user1,
|
||||||
self.assertFalse(AdoptionNoticeNotification.objects.filter(user=self.test_user2).exists())
|
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 django.test import TestCase
|
||||||
from model_bakery import baker
|
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
|
from fellchensammlung.tools.notifications import notify_of_AN_to_be_checked
|
||||||
|
|
||||||
|
|
||||||
@@ -29,6 +30,12 @@ class TestNotifications(TestCase):
|
|||||||
|
|
||||||
def test_notify_of_AN_to_be_checked(self):
|
def test_notify_of_AN_to_be_checked(self):
|
||||||
notify_of_AN_to_be_checked(self.adoption1)
|
notify_of_AN_to_be_checked(self.adoption1)
|
||||||
self.assertTrue(AdoptionNoticeNotification.objects.filter(user=self.test_user0).exists())
|
self.assertTrue(Notification.objects.filter(user_to_notify=self.test_user0,
|
||||||
self.assertTrue(AdoptionNoticeNotification.objects.filter(user=self.test_user1).exists())
|
adoption_notice=self.adoption1,
|
||||||
self.assertFalse(AdoptionNoticeNotification.objects.filter(user=self.test_user2).exists())
|
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 model_bakery import baker
|
||||||
|
|
||||||
from fellchensammlung.models import Animal, Species, AdoptionNotice, User, Location, AdoptionNoticeStatus, TrustLevel, \
|
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.geo import LocationProxy
|
||||||
|
from fellchensammlung.tools.model_helpers import NotificationTypeChoices
|
||||||
from fellchensammlung.views import add_adoption_notice
|
from fellchensammlung.views import add_adoption_notice
|
||||||
|
|
||||||
|
|
||||||
@@ -34,15 +35,6 @@ class AnimalAndAdoptionTest(TestCase):
|
|||||||
species=rat,
|
species=rat,
|
||||||
description="Eine unglaublich süße Ratte")
|
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):
|
def test_detail_animal_notice(self):
|
||||||
self.client.login(username='testuser0', password='12345')
|
self.client.login(username='testuser0', password='12345')
|
||||||
|
|
||||||
@@ -339,8 +331,10 @@ class AdoptionDetailTest(TestCase):
|
|||||||
reverse('adoption-notice-detail', args=str(an1.pk)),
|
reverse('adoption-notice-detail', args=str(an1.pk)),
|
||||||
data={"action": "comment", "text": "Test"})
|
data={"action": "comment", "text": "Test"})
|
||||||
self.assertTrue(Comment.objects.filter(user__username="testuser0").exists())
|
self.assertTrue(Comment.objects.filter(user__username="testuser0").exists())
|
||||||
self.assertFalse(CommentNotification.objects.filter(user__username="testuser0").exists())
|
self.assertFalse(Notification.objects.filter(user_to_notify__username="testuser0",
|
||||||
self.assertTrue(CommentNotification.objects.filter(user__username="testuser1").exists())
|
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):
|
class AdoptionEditTest(TestCase):
|
||||||
|
Reference in New Issue
Block a user