Example #1
0
 def test_edit_someones_entry(self):
     """Edit someone else's entry."""
     url = reverse('diary.edit', args=[self.e.id])
     request = self.factory.get(url)
     request.user = self.c
     fn = lambda: views.edit(request, diary_id=self.e.id)
     self.assertRaises(PermissionDenied, fn)
Example #2
0
 def test_edit_entry(self):
     url = reverse('diary.edit', args=[self.e.id])
     request = self.factory.get(url)
     request.user = self.u
     response = views.edit(request, diary_id=self.e.id)
     eq_(response.status_code, 200)
     page_content = response.content
     # In edit form box, assert initial contents are displayed.
     contains(page_content, 's' * 500)
     contains(page_content, 'diary/entry/%d/edit' % (self.e.id))
Example #3
0
    def test_edit_update_entry(self):
        url = reverse('diary.edit', args=[self.e.id])
        request = self.factory.post(url, {'text': 'x' * 500})
        request.user = self.u
        response = views.edit(request, diary_id=self.e.id)
        # Is HttpResponseRedirect called (based on a valid form)?
        eq_(response.status_code, 302)

        # Was the diary entry changed?
        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.
        contains(response.content, 'x' * 500)