コード例 #1
0
 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)
コード例 #2
0
ファイル: unit_tests.py プロジェクト: sloria/device-inventory
class IpadCommentTest(TestCase):
    def setUp(self):
        self.comment = IpadCommentFactory()

    def test_updated_at(self):
        then = timezone.now()
        # Upon saving, updated_at field is updated
        self.comment.save()
        assert_true(self.comment.updated_at > then)

    def test_get_cname(self):
        assert_equal(self.comment.get_cname(), "comment")

    def test_device_updated_at(self):
        then = timezone.now()
        self.comment.save()
        assert_true(self.comment.device.updated_at > then)
コード例 #3
0
ファイル: unit_tests.py プロジェクト: sboden/device-inventory
class IpadCommentTest(TestCase):
    def setUp(self):
        self.comment = IpadCommentFactory()

    def test_updated_at(self):
        then = timezone.now()
        # Upon saving, updated_at field is updated
        self.comment.save()
        assert_true(self.comment.updated_at > then)

    def test_get_cname(self):
        assert_equal(self.comment.get_cname(), 'comment')

    def test_device_updated_at(self):
        then = timezone.now()
        self.comment.save()
        assert_true(self.comment.device.updated_at > then)
コード例 #4
0
 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))
     )
コード例 #5
0
ファイル: unit_tests.py プロジェクト: sloria/device-inventory
 def setUp(self):
     self.comment = IpadCommentFactory()
コード例 #6
0
ファイル: unit_tests.py プロジェクト: sboden/device-inventory
 def setUp(self):
     self.comment = IpadCommentFactory()