class ShoppingListTest(unittest.TestCase): """Tests for the ShoppingList class""" def setUp(self): self.shopping_list = ShoppingList() # self.list_item = ListItem() def test_shoppingList_property_initialization(self): self.assertEquals(self.shopping_list.id, 0, msg="initial value of id should be zero") self.assertIsInstance(self.shopping_list.items, list, msg="items is not a list") def test_add_item_to_shopping_list(self): self.shopping_list.add_item(name="mac book", description="apple", quantity=1) self.assertIsInstance(self.shopping_list.items[0], ListItem, msg="item was not added to shopping list") def test_get_item_on_shopping_list(self): self.shopping_list.add_item(name="mac book", description="apple", quantity=1) item = self.shopping_list.get_item(1) self.assertEquals(item.id, 1, msg="failed to get item from the list") def test_update_item_on_shopping_list(self): self.shopping_list.add_item(name="mac book", description="apple", quantity=1) self.shopping_list.update_item(item_id=1, quantity=2) item = self.shopping_list.get_item(1) self.assertEquals(item.quantity, 2, msg="item was not updated on the shopping list") def test_delete_item_from_shopping_list(self): self.shopping_list.add_item(name="mac book", description="apple", quantity=1) self.shopping_list.delete_item(1) self.assertEquals(len(self.shopping_list.items), 0, msg="item was not deleted from shopping list") def test_view_items_on_shopping_list(self): self.shopping_list.add_item(name="mac book", description="apple", quantity=1) items = self.shopping_list.view_items() self.assertEquals(items[1][0], "mac book", "view all shopping list items added failed")