class TestItem(unittest.TestCase): def setUp(self): self.item = Item() def test_new_item(self): self.assertIsInstance(self.item, Item) def test_loan_method_sets_loaned_variable(self): self.item.loan() self.assertTrue(self.item.loaned) def test_sets_borrower_on_loan(self): self.item.loan(borrower='James') self.assertEqual(self.item.borrower, 'James') def test_sets_loan_date(self): self.loan_date = datetime.datetime.now() self.item.loan(date=self.loan_date) self.assertEqual(self.item.loan_date, self.loan_date) def test_sets_return_date(self): self.item.loan() self.return_date = datetime.datetime.now() self.item.collect(date=self.return_date) self.assertEqual(self.item.return_date, self.return_date)
def setUp(self): self.item = Item()