def test_can_edit_headphones_comment(self):
     # a device is created
     device = HeadphonesFactory()
     # it has a comment
     comment = HeadphonesCommentFactory(device=device,
                                     user=self.experimenter.user)
     # goes to detail page
     res = self.app.get('/devices/headphones/{pk}/'.format(pk=device.pk),
                                                 user=self.experimenter.user)
     # can see the comment
     assert_in(comment.text, res)
     # clicks the edit link
     res = res.click('Edit')
     # sees a form
     assert_in('Edit comment', res)
     form = res.forms['id-edit_comment_form']
     # changes the comment text
     form['text'] = 'new text'
     # submits the form
     res = form.submit().follow()
     # back at the detail page
     assert_equal(res.request.path, 
                 '/devices/headphones/{pk}/'.format(pk=device.pk))
     # sees the new comment text
     assert_in('new text', res)
 def test_can_delete_headphones_comment(self):
     device = HeadphonesFactory()
     comment = HeadphonesCommentFactory(device=device, 
                                 user=self.experimenter.user)
     self._test_delete_comment(device, comment,
                 detail_url='/devices/headphones/{pk}/'.format(pk=device.pk),
                 delete_url=reverse('comments:headphones_delete',
                                 args=(device.pk, comment.pk))
     )
Esempio n. 3
0
 def setUp(self):
     self.comment = HeadphonesCommentFactory()