def test_total_price_when_not_empty(self): cart = CartFactory() book1 = BookFactory() book2 = BookFactory() cart.items.create(book=book1, quantity=1) cart.items.create(book=book2, quantity=2) price = book1.price + book2.price * 2 self.assertEqual(cart.total_price(), price)
def test_total_price_when_empty(self): cart = CartFactory() self.assertEqual(cart.total_price(), 0)