def test_create_quesadillas(self): store = FoodStore() quesadilla = store.order_food("quesadilla_con_carne") self.assertIsInstance(quesadilla, QuesadillaConCarne) quesadilla = store.order_food("quesadilla_grilled_chicken") self.assertIsInstance(quesadilla, QuesadillaGrilledChicken) quesadilla = store.order_food("quesadilla_pork") self.assertIsInstance(quesadilla, QuesadillaPork) quesadilla = store.order_food("quesadilla_pulled_chicken") self.assertIsInstance(quesadilla, QuesadillaPulledChicken) quesadilla = store.order_food("quesadilla_vegan") self.assertIsInstance(quesadilla, QuesadillaVegan)
def test_create_enchiladas(self): store = FoodStore() enchilada = store.order_food("enchilada_con_carne") self.assertIsInstance(enchilada, EnchiladaConCarne) enchilada = store.order_food("enchilada_grilled_chicken") self.assertIsInstance(enchilada, EnchiladaGrilledChicken) enchilada = store.order_food("enchilada_pork") self.assertIsInstance(enchilada, EnchiladaPork) enchilada = store.order_food("enchilada_pulled_chicken") self.assertIsInstance(enchilada, EnchiladaPulledChicken) enchilada = store.order_food("enchilada_vegan") self.assertIsInstance(enchilada, EnchiladaVegan)
def test_create_burritos(self): store = FoodStore() burrito = store.order_food("burrito_con_carne") self.assertIsInstance(burrito, BurritoConCarne) burrito = store.order_food("burrito_grilled_chicken") self.assertIsInstance(burrito, BurritoGrilledChicken) burrito = store.order_food("burrito_pork") self.assertIsInstance(burrito, BurritoPork) burrito = store.order_food("burrito_pulled_chicken") self.assertIsInstance(burrito, BurritoPulledChicken) burrito = store.order_food("burrito_vegan") self.assertIsInstance(burrito, BurritoVegan)
def __init__(self): FoodStore.register_product("enchilada_pulled_chicken", type(self))
def __init__(self): FoodStore.register_product("enchilada_pork", type(self))
def __init__(self): FoodStore.register_product("burrito_pulled_chicken", type(self))
def __init__(self): FoodStore.register_product("quesadilla_pork", type(self))
def __init__(self): FoodStore.register_product("burrito_pork", type(self))
import time from food_store import FoodStore start_time = time.time() store = FoodStore() for i in range(100001): burrito = store.order_food("burrito_con_carne") burrito = store.order_food("burrito_grilled_chicken") burrito = store.order_food("burrito_pork") burrito = store.order_food("burrito_pulled_chicken") burrito = store.order_food("burrito_vegan") end_time = time.time() - start_time
def __init__(self): FoodStore.register_product("quesadilla_con_carne", type(self))
def __init__(self): FoodStore.register_product("burrito_con_carne", type(self))
def __init__(self): FoodStore.register_product("quesadilla_pulled_chicken", type(self))
def __init__(self): FoodStore.register_product("enchilada_con_carne", type(self))
def test_singleton(self): first_singleton = FoodStore() second_singleton = FoodStore() self.assertTrue(first_singleton is second_singleton)