Beispiel #1
0
    def setUp(self):
        self.con = sqlite3.connect("TestEl_Fieston.db")
        cur = self.con.cursor()
        self.db = DB('TestEl_Fieston.db')
        cur.execute('''CREATE TABLE IF NOT EXISTS favoritos
            (id Integer,
            nombre Text,
            tags Text,
            categoria Text,
            alcohol Text,
            vaso Text,
            instrucciones Text,
            imagen Text,
            ingredientes Text,
            medidas Text,
            bienElectrico Integer)
            ''')

        self.db.guardarBebida(
            bebida(
                14978, "Rum Punch", None, "Punch / Party Drink", "Alcoholic",
                "Punch bowl", "Mix all ingredients in a punch bowl and serve.",
                "https://www.thecocktaildb.com/images/media/drink/wyrsxu1441554538.jpg",
                "Rum, Ginger ale, Fruit punch, Orange juice, Ice, , , , , , , , , , ,",
                "mikey bottle , large bottle , 355 ml frozen , 355 ml frozen , crushed ,  ,  ,  ,  ,  , , , , , ,",
                7))
        self.db.guardarBebida(
            bebida(
                13621, "Tequila Sunrise", "IBA,ContemporaryClassic",
                "Cocktail", "Alcoholic", "Highball glass",
                "Pour the tequila and orange juice into glass over ice. Add the grenadine, which will sink to the bottom. Stir gently to create the sunrise effect. Garnish and serve.",
                "https://www.thecocktaildb.com/images/media/drink/quqyqp1480879103.jpg",
                "Tequila, Orange juice, Grenadine, , , , , , , , , , , , , ",
                "2 measures , , , , , , , , , , , , , , , ", 7))
        self.db.guardarBebida(
            bebida(
                11000, "Mojito", "IBA,ContemporaryClassic,Alcoholic,USA",
                "Cocktail", "Alcoholic", "Highball glass",
                "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with cracked ice. Pour the rum and top with soda water. Garnish and serve with straw.",
                "https://www.thecocktaildb.com/images/media/drink/rxtqps1478251029.jpg",
                "Light rum, Lime, Sugar, Mint, Soda water, , , , , , , , , , , ",
                "2-3 oz , Juice of 1 , 2 tsp , 2-4 , , , , , , , , , , , , ",
                10))
        self.db.guardarBebida(
            bebida(
                12770, "Iced Coffee", None, "Coffee / Tea", "Non alcoholic",
                "Coffee mug",
                "Mix together until coffee and sugar is dissolved. Add milk. Shake well. Using a blender or milk shake maker produces a very foamy drink. Serve in coffee mug.",
                "https://www.thecocktaildb.com/images/media/drink/ytprxy1454513855.jpg",
                "Coffee, Sugar, Water, Milk, , , , , , , , , , , , ",
                "1/4 cup instant , 1/4 cup , 1/4 cup hot , 4 cups cold ,  ,  ,  ,  ,  , , , , , , , ",
                7))
Beispiel #2
0
    def testShowAll(self):
        salida_esperada = [bebida(12370, "Tequila Sour", "None", "Ordinary Drink", "Alcoholic", "Whiskey sour glass", "Shake tequila, juice of lemon, and powdered sugar with ice and strain into a whiskey sour glass. Add the half-slice of lemon, top with the cherry, and serve.", "https://www.thecocktaildb.com/images/media/drink/ek0mlq1504820601.jpg", "Tequila, Lemon, Powdered sugar, Lemon, Cherry, , , , , , , , , , , ", "2 oz , Juice of 1/2 , 1 tsp , 1/2 slice , 1 ,  ,  ,  ,  ,  , , , , , , ", 10),
                bebida(13621, "Tequila Sunrise", "IBA,ContemporaryClassic", "Cocktail", "Alcoholic", "Highball glass", "Pour the tequila and orange juice into glass over ice. Add the grenadine, which will sink to the bottom. Stir gently to create the sunrise effect. Garnish and serve.", "https://www.thecocktaildb.com/images/media/drink/quqyqp1480879103.jpg", "Tequila, Orange juice, Grenadine, , , , , , , , , , , , , ", "2 measures , , , , , , , , , , , , , , , ", 7),
                bebida(11000, "Mojito", "IBA,ContemporaryClassic,Alcoholic,USA", "Cocktail", "Alcoholic", "Highball glass", "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with cracked ice. Pour the rum and top with soda water. Garnish and serve with straw.", "https://www.thecocktaildb.com/images/media/drink/rxtqps1478251029.jpg", "Light rum, Lime, Sugar, Mint, Soda water, , , , , , , , , , , ", "2-3 oz , Juice of 1 , 2 tsp , 2-4 , , , , , , , , , , , , ", 10),
                bebida(12770, "Iced Coffee", "None", "Coffee / Tea", "Non alcoholic", "Coffee mug", "Mix together until coffee and sugar is dissolved. Add milk. Shake well. Using a blender or milk shake maker produces a very foamy drink. Serve in coffee mug.", "https://www.thecocktaildb.com/images/media/drink/ytprxy1454513855.jpg", "Coffee, Sugar, Water, Milk, , , , , , , , , , , , ", "1/4 cup instant , 1/4 cup , 1/4 cup hot , 4 cups cold ,  ,  ,  ,  ,  , , , , , , , ", 7),
                bebida(11007, "Margarita", "IBA,ContemporaryClassic", "Ordinary Drink", "Alcoholic", "Cocktail glass", "Rub the rim of the glass with the lime slice to make the salt stick to it. Take care to moisten only the outer rim and sprinkle the salt on it. The salt should present to the lips of the imbiber and never mix into the cocktail. Shake the other ingredients with ice, then carefully pour into the glass.", "https://www.thecocktaildb.com/images/media/drink/wpxpvu1439905379.jpg", "Tequila, Triple sec, Lime juice, Salt, , , , , , , , , , , , ", "1 1/2 oz , 1/2 oz , 1 oz , , , , , , , , , , , , , ", 9)]

        a = self.db.mostrarBebidas()
        self.assertEqual(salida_esperada[0], a[0])
        i=0
        for x in salida_esperada:
            self.assertEqual(salida_esperada[i], a[i])
            i+=1
Beispiel #3
0
    def testAdd(self):
        self.db.guardarBebida(bebida(11000, "Mojito", "IBA,ContemporaryClassic,Alcoholic,USA", "Cocktail", "Alcoholic", "Highball glass", "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with cracked ice. Pour the rum and top with soda water. Garnish and serve with straw.", "https://www.thecocktaildb.com/images/media/drink/rxtqps1478251029.jpg", "Light rum, Lime, Sugar, Mint, Soda water, , , , , , , , , , , ", "2-3 oz , Juice of 1 , 2 tsp , 2-4 , , , , , , , , , , , , ", 10))
        real = bebida(11000, "Mojito", "IBA,ContemporaryClassic,Alcoholic,USA", "Cocktail", "Alcoholic", "Highball glass", "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with cracked ice. Pour the rum and top with soda water. Garnish and serve with straw.", "https://www.thecocktaildb.com/images/media/drink/rxtqps1478251029.jpg", "Light rum, Lime, Sugar, Mint, Soda water, , , , , , , , , , , ", "2-3 oz , Juice of 1 , 2 tsp , 2-4 , , , , , , , , , , , , ", 10)
        nombre = "Mojito"
        salida_esperada = self.con.execute("select * from favoritos where nombre = ('{}')".format(nombre))
        cursor = salida_esperada.fetchone()
        l = []
        for row in cursor:
            l.append(row)

        salida_esperada2 = bebida(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10])
        salida = (salida_esperada2.id, salida_esperada2.nombre, salida_esperada2.tags, salida_esperada2.categoria, salida_esperada2.alcohol, salida_esperada2.vaso, salida_esperada2.instrucciones, salida_esperada2.imagen, salida_esperada2.ingredientes, salida_esperada2.medidas, salida_esperada2.bienElectrico)
        vreal = (real.id, real.nombre, real.tags, real.categoria, real.alcohol, real.vaso, real.instrucciones, real.imagen, real.ingredientes, real.medidas, real.bienElectrico)
        self.assertEqual(salida, vreal)
Beispiel #4
0
 def testCreateBebida(self):
     self.api = APIBebida()
     nombre = "Mojito"
     numero = 0
     salida_esperada = bebida(11000, "Mojito", "IBA,ContemporaryClassic,Alcoholic,USA", "Cocktail", "Alcoholic", "Highball glass", "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with cracked ice. Pour the rum and top with soda water. Garnish and serve with straw.", "https://www.thecocktaildb.com/images/media/drink/rxtqps1478251029.jpg", "Light rum, Lime, Sugar, Mint, Soda water, , , , , , , , , , , ", "2-3 oz , Juice of 1 , 2 tsp , 2-4 , , , , , , , , , , , , ", 10)
     real = self.api.getBebida(numero, nombre)
     self.assertEqual(type(salida_esperada), type(real))
     self.assertEqual(salida_esperada.id, int(real.id))
Beispiel #5
0
    def getBebida(self, bebidaElegida, drinkName):
        url = 'http://www.thecocktaildb.com/api/json/v1/1/search.php?s=' + drinkName
        response = requests.get(url)

        if response.status_code == 200:
            response_json = response.json(
            )  # DiccionarioJ con elemento de una lista
            idDrink = response_json[
                'drinks']  # Elemento de la lista que es un diccionario

            # asignamos el valor de bebida
            id = idDrink[bebidaElegida].get("idDrink")
            nombre = idDrink[bebidaElegida].get("strDrink")
            tags = idDrink[bebidaElegida].get("strTags")
            categoria = idDrink[bebidaElegida].get("strCategory")
            alcohol = idDrink[bebidaElegida].get("strAlcoholic")
            vaso = idDrink[bebidaElegida].get("strGlass")
            instrucciones = idDrink[bebidaElegida].get("strInstructions")
            imagen = idDrink[bebidaElegida].get("strDrinkThumb")
            ingredientes = ""
            ing = 1
            while ing <= 15:
                if idDrink[bebidaElegida].get(
                        f"strIngredient{ing}"
                ) != "" or idDrink[bebidaElegida].get(
                        f"strIngredient{ing}") != " " or idDrink[
                            bebidaElegida].get(f"strIngredient{ing}") is None:
                    ingredientes += idDrink[bebidaElegida].get(
                        f"strIngredient{ing}")
                    ingredientes += ", "
                    ing += 1

            medidas = ""
            med = 1
            while med <= 15:
                if idDrink[bebidaElegida].get(
                        f"strMeasure{med}"
                ) != "" or idDrink[bebidaElegida].get(
                        f"strMeasure{med}"
                ) != " " or idDrink[bebidaElegida].get(
                        f"strMeasure{med}") != "\n" or idDrink[
                            bebidaElegida].get(f"strMeasure{med}") is None:
                    medidas += idDrink[bebidaElegida].get(f"strMeasure{med}")
                    medidas += ", "
                    med += 1

            bienElectrico = randint(5, 10)

            #creamos el objeto bebida
            b = bebida(id, nombre, tags, categoria, alcohol, vaso,
                       instrucciones, imagen, ingredientes, medidas,
                       bienElectrico)

            return b
Beispiel #6
0
    def mostrarBebidas(self):
        bMostrar = self.cur.execute("SELECT * from favoritos").fetchall()

        bebidas = []
        i = 0
        for b in bMostrar:
            bebidas.append(
                bebida(b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8],
                       b[9], b[10]))
            i += 1

        return bebidas
Beispiel #7
0
 def testMostrarT(self):
     salida_esperada = [
         bebida(
             14978, "Rum Punch", "None", "Punch / Party Drink", "Alcoholic",
             "Punch bowl", "Mix all ingredients in a punch bowl and serve.",
             "https://www.thecocktaildb.com/images/media/drink/wyrsxu1441554538.jpg",
             "Rum, Ginger ale, Fruit punch, Orange juice, Ice, , , , , , , , , , ,",
             "mikey bottle , large bottle , 355 ml frozen , 355 ml frozen , crushed ,  ,  ,  ,  ,  , , , , , ,",
             7),
         bebida(
             13621, "Tequila Sunrise", "IBA,ContemporaryClassic",
             "Cocktail", "Alcoholic", "Highball glass",
             "Pour the tequila and orange juice into glass over ice. Add the grenadine, which will sink to the bottom. Stir gently to create the sunrise effect. Garnish and serve.",
             "https://www.thecocktaildb.com/images/media/drink/quqyqp1480879103.jpg",
             "Tequila, Orange juice, Grenadine, , , , , , , , , , , , , ",
             "2 measures , , , , , , , , , , , , , , , ", 7),
         bebida(
             11000, "Mojito", "IBA,ContemporaryClassic,Alcoholic,USA",
             "Cocktail", "Alcoholic", "Highball glass",
             "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with cracked ice. Pour the rum and top with soda water. Garnish and serve with straw.",
             "https://www.thecocktaildb.com/images/media/drink/rxtqps1478251029.jpg",
             "Light rum, Lime, Sugar, Mint, Soda water, , , , , , , , , , , ",
             "2-3 oz , Juice of 1 , 2 tsp , 2-4 , , , , , , , , , , , , ",
             10),
         bebida(
             12770, "Iced Coffee", "None", "Coffee / Tea", "Non alcoholic",
             "Coffee mug",
             "Mix together until coffee and sugar is dissolved. Add milk. Shake well. Using a blender or milk shake maker produces a very foamy drink. Serve in coffee mug.",
             "https://www.thecocktaildb.com/images/media/drink/ytprxy1454513855.jpg",
             "Coffee, Sugar, Water, Milk, , , , , , , , , , , , ",
             "1/4 cup instant , 1/4 cup , 1/4 cup hot , 4 cups cold ,  ,  ,  ,  ,  , , , , , , , ",
             7)
     ]
     a = self.db.mostrarBebidas()
     self.assertEqual(salida_esperada[0], a[0])
     i = 0
     for x in salida_esperada:
         self.assertEqual(salida_esperada[i], a[i])
         i += 1
Beispiel #8
0
    def testActualizar(self):
        self.db.actualizarBebida("Rum Punch", 7)
        nombre = "Rum Punch"
        salida_esperada = self.con.execute(
            "select * from favoritos where nombre = ('{}')".format(nombre))
        cursor = salida_esperada.fetchone()
        r = []
        for row in cursor:
            r.append(row)

        salida_esperada3 = bebida(r[0], r[1], r[2], r[3], r[4], r[5], r[6],
                                  r[7], r[8], r[9], r[10])
        real = bebida(
            14978, "Rum Punch", None, "Punch / Party Drink", "Alcoholic",
            "Punch bowl", "Mix all ingredients in a punch bowl and serve.",
            "https://www.thecocktaildb.com/images/media/drink/wyrsxu1441554538.jpg",
            "Rum, Ginger ale, Fruit punch, Orange juice, Ice, , , , , , , , , , ,",
            "mikey bottle , large bottle , 355 ml frozen , 355 ml frozen , crushed ,  ,  ,  ,  ,  , , , , , ,",
            7)
        sal = (salida_esperada3.bienElectrico, salida_esperada3.nombre)
        re = (real.bienElectrico, real.nombre)
        self.assertEqual(sal, re)
Beispiel #9
0
    def setUp(self):
        self.con = sqlite3.connect("TestEl_Fieston.db")
        cur = self.con.cursor()
        self.db = DB('TestEl_Fieston.db')
        cur.execute('''CREATE TABLE IF NOT EXISTS favoritos
            (id Integer,
            nombre Text,
            tags Text,
            categoria Text,
            alcohol Text,
            vaso Text,
            instrucciones Text,
            imagen Text,
            ingredientes Text,
            medidas Text,
            bienElectrico Integer)  
            ''')

        self.db.guardarBebida(bebida(12370, "Tequila Sour", "None", "Ordinary Drink", "Alcoholic", "Whiskey sour glass", "Shake tequila, juice of lemon, and powdered sugar with ice and strain into a whiskey sour glass. Add the half-slice of lemon, top with the cherry, and serve.", "https://www.thecocktaildb.com/images/media/drink/ek0mlq1504820601.jpg", "Tequila, Lemon, Powdered sugar, Lemon, Cherry, , , , , , , , , , , ", "2 oz , Juice of 1/2 , 1 tsp , 1/2 slice , 1 ,  ,  ,  ,  ,  , , , , , , ", 10))
        self.db.guardarBebida(bebida(13621, "Tequila Sunrise", "IBA,ContemporaryClassic", "Cocktail", "Alcoholic", "Highball glass", "Pour the tequila and orange juice into glass over ice. Add the grenadine, which will sink to the bottom. Stir gently to create the sunrise effect. Garnish and serve.", "https://www.thecocktaildb.com/images/media/drink/quqyqp1480879103.jpg", "Tequila, Orange juice, Grenadine, , , , , , , , , , , , , ", "2 measures , , , , , , , , , , , , , , , ", 7))
        self.db.guardarBebida(bebida(11000, "Mojito", "IBA,ContemporaryClassic,Alcoholic,USA", "Cocktail", "Alcoholic", "Highball glass", "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with cracked ice. Pour the rum and top with soda water. Garnish and serve with straw.", "https://www.thecocktaildb.com/images/media/drink/rxtqps1478251029.jpg", "Light rum, Lime, Sugar, Mint, Soda water, , , , , , , , , , , ", "2-3 oz , Juice of 1 , 2 tsp , 2-4 , , , , , , , , , , , , ", 10))
        self.db.guardarBebida(bebida(12770, "Iced Coffee", "None", "Coffee / Tea", "Non alcoholic", "Coffee mug", "Mix together until coffee and sugar is dissolved. Add milk. Shake well. Using a blender or milk shake maker produces a very foamy drink. Serve in coffee mug.", "https://www.thecocktaildb.com/images/media/drink/ytprxy1454513855.jpg", "Coffee, Sugar, Water, Milk, , , , , , , , , , , , ", "1/4 cup instant , 1/4 cup , 1/4 cup hot , 4 cups cold ,  ,  ,  ,  ,  , , , , , , , ", 7))
        self.db.guardarBebida(bebida(11007, "Margarita", "IBA,ContemporaryClassic", "Ordinary Drink", "Alcoholic", "Cocktail glass", "Rub the rim of the glass with the lime slice to make the salt stick to it. Take care to moisten only the outer rim and sprinkle the salt on it. The salt should present to the lips of the imbiber and never mix into the cocktail. Shake the other ingredients with ice, then carefully pour into the glass.", "https://www.thecocktaildb.com/images/media/drink/wpxpvu1439905379.jpg", "Tequila, Triple sec, Lime juice, Salt, , , , , , , , , , , , ", "1 1/2 oz , 1/2 oz , 1 oz , , , , , , , , , , , , , ", 9))
Beispiel #10
0
 def testCreateBebida(self):
     self.api = APIBebida()
     nombre = "Rum"
     numero = 2
     salida_esperada = bebida(
         14978, "Rum Punch", None, "Punch / Party Drink", "Alcoholic",
         "Punch bowl", "Mix all ingredients in a punch bowl and serve.",
         "https://www.thecocktaildb.com/images/media/drink/wyrsxu1441554538.jpg",
         "Rum, Ginger ale, Fruit punch, Orange juice, Ice, , , , , , , , , , ,",
         "mikey bottle , large bottle , 355 ml frozen , 355 ml frozen , crushed ,  ,  ,  ,  ,  , , , , , ,",
         7)
     real = self.api.getBebida(numero, nombre)
     self.assertEqual(type(salida_esperada), type(real))
     self.assertEqual(salida_esperada.id, int(real.id))
Beispiel #11
0
    def testAgregar(self):
        self.db.guardarBebida(
            bebida(
                13621, "Tequila Sunrise", "IBA,ContemporaryClassic",
                "Cocktail", "Alcoholic", "Highball glass",
                "Pour the tequila and orange juice into glass over ice. Add the grenadine, which will sink to the bottom. Stir gently to create the sunrise effect. Garnish and serve.",
                "https://www.thecocktaildb.com/images/media/drink/quqyqp1480879103.jpg",
                "Tequila, Orange juice, Grenadine, , , , , , , , , , , , , ",
                "2 measures , , , , , , , , , , , , , , , ", 7))
        real = bebida(
            13621, "Tequila Sunrise", "IBA,ContemporaryClassic", "Cocktail",
            "Alcoholic", "Highball glass",
            "Pour the tequila and orange juice into glass over ice. Add the grenadine, which will sink to the bottom. Stir gently to create the sunrise effect. Garnish and serve.",
            "https://www.thecocktaildb.com/images/media/drink/quqyqp1480879103.jpg",
            "Tequila, Orange juice, Grenadine, , , , , , , , , , , , , ",
            "2 measures , , , , , , , , , , , , , , , ", 7)
        nombre = "Tequila Sunrise"
        salida_esperada = self.con.execute(
            "select * from favoritos where nombre = ('{}')".format(nombre))
        cursor = salida_esperada.fetchone()
        r = []
        for row in cursor:
            r.append(row)

        salida_esperada2 = bebida(r[0], r[1], r[2], r[3], r[4], r[5], r[6],
                                  r[7], r[8], r[9], r[10])
        salida = (salida_esperada2.id, salida_esperada2.nombre,
                  salida_esperada2.tags, salida_esperada2.categoria,
                  salida_esperada2.alcohol, salida_esperada2.vaso,
                  salida_esperada2.instrucciones, salida_esperada2.imagen,
                  salida_esperada2.ingredientes, salida_esperada2.medidas,
                  salida_esperada2.bienElectrico)
        vreal = (real.id, real.nombre, real.tags, real.categoria, real.alcohol,
                 real.vaso, real.instrucciones, real.imagen, real.ingredientes,
                 real.medidas, real.bienElectrico)
        self.assertEqual(salida, vreal)