Exemple #1
0
 def test_delete_someones_entry(self):
     """Delete someone else's entry."""
     url = reverse('diary.delete', args=[self.e.id])
     request = self.factory.post(url)
     request.user = self.c
     fn = lambda: views.delete(request, diary_id=self.e.id)
     self.assertRaises(PermissionDenied, fn)
Exemple #2
0
    def test_delete_existing_entry(self):
        url = reverse('diary.delete', args=[self.e.id])
        request = self.factory.post(url)
        request.user = self.u
        response = views.delete(request, diary_id=self.e.id)
        # Assert a redirect took place.
        eq_(response.status_code, 302)

        # Was the diary entry deleted?
        url = reverse('diary.list_all', args=[self.u.username])
        request = self.factory.get(url)
        request.user = self.u
        response = views.list_personal(request, username=self.u.username)
        eq_(response.status_code, 200)
        # Yes, indeed.
        not_contains(response.content, 'a' * 500)