示例#1
0
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)
示例#2
0
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)