def test_can_rsvp(self, rsvp_notification):
url = reverse('view_event', kwargs={'pk': self.other_event.pk})
self.client.force_login(self.person.role)
response = self.client.get(url)
self.assertIn('Participer à cet événement', response.content.decode())
response = self.client.post(url, data={
'action': 'rsvp'
}, follow=True)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn(self.person, self.other_event.attendees.all())
self.assertIn('Annuler ma participation', response.content.decode())
rsvp_notification.delay.assert_called_once()
rsvp = RSVP.objects.get(person=self.person, event=self.other_event)
self.assertEqual(rsvp_notification.delay.call_args[0][0], rsvp.pk)
评论列表
文章目录