Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anorthall committed Jul 12, 2023
1 parent 92bcda1 commit bf8596e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/comments/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,32 @@ def test_comments_do_not_send_an_email_when_disabled(self):
)

self.assertEqual(len(mail.outbox), 0)

def test_comments_do_not_send_an_email_to_same_user(self):
"""Test that a comment does not send an email to the same user"""
self.user.email_comments = True
self.user.save()
self.client.post(
reverse("comments:add", args=[self.trip.uuid]),
{
"content": "Test comment",
},
follow=True,
)

self.assertEqual(len(mail.outbox), 0)
self.assertEqual(self.trip.comments.first().content, "Test comment")

def test_comments_do_not_notify_the_same_user(self):
"""Test that a comment does not notify the same user"""
self.client.post(
reverse("comments:add", args=[self.trip.uuid]),
{
"content": "Test comment",
},
follow=True,
)

self.assertEqual(Notification.objects.count(), 0)
self.assertEqual(self.trip.comments.first().content, "Test comment")
self.assertEqual(self.user.notifications.count(), 0)

0 comments on commit bf8596e

Please sign in to comment.