def test_delete_a_inventory(self): """ Delete an inventory """ inventory = Inventory(name="tools", category="widget1", available=True,condition="new") inventory.save() self.assertEqual(len(Inventory.all()), 1) # delete the inventory and make sure it isn't in the database inventory.delete() self.assertEqual(len(Inventory.all()), 0)
def test_key_error_on_delete(self, bad_mock): """ Test KeyError on delete """ bad_mock.side_effect = KeyError() inventory = Inventory("tools", "widget1", False, "new") inventory.create() inventory.delete()