def test_can_edit_ipad_comment(self):
     # A device is created
     device = IpadFactory()
     # It has a check-in comment
     comment = IpadCommentFactory(text="Just a bigger iPhone", 
                                 device=device,
                                 user=self.experimenter.user)
     # goes to the detail page
     res = self.app.get('/devices/ipads/{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'] = 'Or a flat MacBook Air'
     # submits the form
     res = form.submit().follow()
     # back at the detail page
     assert_equal(res.request.path, 
                 '/devices/ipads/{pk}/'.format(pk=device.pk))
     # sees the new comment text
     assert_in('Or a flat MacBook Air', res)
 def test_can_delete_ipad_comment(self):
     device = IpadFactory()
     comment = IpadCommentFactory(device=device, 
                                 user=self.experimenter.user)
     self._test_delete_comment(device, comment,
                 detail_url='/devices/ipads/{pk}/'.format(pk=device.pk),
                 delete_url=reverse('comments:ipad_delete',
                                 args=(device.pk, comment.pk))
     )
示例#3
0
 def setUp(self):
     self.comment = IpadCommentFactory()