class HeadphonesTest(TestCase): def setUp(self): self.headphones = HeadphonesFactory() def test_model(self): headphones = HeadphonesFactory() assert_true(headphones.pk) assert_true(headphones.status) assert_true(headphones.created_at) assert_true(headphones.updated_at) assert_false(headphones.lendee) assert_false(headphones.lender) def test_display_status(self): headphones = HeadphonesFactory(status=Device.CHECKED_IN) assert_equal(headphones.get_verbose_status(), 'Checked in') def test_check_in(self): self.headphones.check_in(condition='excellent') assert_equal(self.headphones.status, Device.CHECKED_IN) self.headphones.check_in(condition='scratched') assert_equal(self.headphones.status, Device.CHECKED_IN) assert_equal(self.headphones.condition, Device.SCRATCHED) self.headphones.check_in(condition='broken') assert_equal(self.headphones.status, Device.BROKEN) assert_equal(self.headphones.condition, Device.BROKEN) self.headphones.check_in(condition='missing') assert_equal(self.headphones.status, Device.MISSING) assert_equal(self.headphones.condition, Device.MISSING)
def test_can_checkout_headphones_to_user(self): # headphones are created device = HeadphonesFactory(status=Device.CHECKED_IN) # user is created user = UserFactory() # checks out to user self._checkout(device, user.username)
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_model(self): headphones = HeadphonesFactory() assert_true(headphones.pk) assert_true(headphones.status) assert_true(headphones.created_at) assert_true(headphones.updated_at) assert_false(headphones.lendee) assert_false(headphones.lender)
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)) )
def test_display_status(self): headphones = HeadphonesFactory(status=Device.CHECKED_IN) assert_equal(headphones.get_verbose_status(), 'Checked in')
def setUp(self): self.headphones = HeadphonesFactory()
def test_can_checkout_headphones_to_subject(self): # headphones are created device = HeadphonesFactory(status=Device.CHECKED_IN) # checks out to subject self._checkout(device, '123451')
def test_can_checkin_headphones(self): # headphones are creted device = HeadphonesFactory(status=Device.CHECKED_OUT) # checks it in self._checkin(device, expected_status=Device.CHECKED_IN)