コード例 #1
0
ファイル: test_views.py プロジェクト: ccarlos/code-samples
 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))
コード例 #2
0
ファイル: test_views.py プロジェクト: ccarlos/code-samples
 def test_existing_entry(self):
     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)
     page_content = response.content
     contains(page_content, '/diary/user/zinoma/%d/%d/%d' %
         (self.e.created_day.year, self.e.created_day.month,
          self.e.created_day.day))
     contains(page_content, 'entry/%d/delete' % (self.e.id))
コード例 #3
0
ファイル: test_views.py プロジェクト: ccarlos/code-samples
 def test_new_entry(self):
     # Since user doesn't have an entry, we check if the
     # new diary form is displayed.
     url = reverse('diary.new')
     request = self.factory.get(url)
     request.user = self.c
     response = views.new(request)
     eq_(response.status_code, 200)
     page_content = response.content
     contains(page_content, 'Write your entry here...')
     contains(page_content, 'action=\"/diary/new')
コード例 #4
0
ファイル: test_views.py プロジェクト: ccarlos/code-samples
    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)
コード例 #5
0
ファイル: test_views.py プロジェクト: ccarlos/code-samples
    def test_reply_diary(self):
        url = reverse('diary.reply', args=[self.e.id])
        request = self.factory.post(url, {'text': 'ha' * 10})
        request.user = self.u
        response = views.reply(request, diary_id=self.e.id)
        # Is HttpResponseRedirect called (based on a valid form)?
        eq_(response.status_code, 302)

        # Was the diary comment created?
        url = reverse('diary.single',
                      kwargs=get_kwargs_for_diary_id(self.e.id))
        request = self.factory.get(url)
        request.user = self.u
        response = views.single(request, username=self.u.username,
                                year=self.e.created_day.year,
                                month=self.e.created_day.month,
                                day=self.e.created_day.day)
        eq_(response.status_code, 200)
        # Yes, indeed.
        contains(response.content, 'ha' * 10)