예제 #1
0
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.cajero = Cajero()
        billetes = []
        for i in range(0, 10):
            billetes.append(self.b1000)
        self.cajero.agregar_dinero(billetes)

    def test_contar(self):
        a = self.cajero.contar_dinero()
        self.assertEqual(a, "10 billetes de $1000, " +
                            "parcial $10000\n" +
                            "Total $10000")

    def test_extraer1(self):
        b = self.cajero.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_extraer2(self):
        c = self.cajero.extraer_dinero(12000)
        self.assertEqual(c, "Error. Quiere sacar mas dinero de lo que se puede"
                         )

    def test_extraer3(self):
        d = self.cajero.extraer_dinero(5520)
        self.assertEqual(d, "Error. El monto es incorrecto")
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.b500 = Billete500()
        self.cajero = Cajero()
        billetes = []
        for i in range(0, 10):
            billetes.append(self.b1000)
        for i in range(0, 20):
            billetes.append(self.b500)
        self.cajero.agregar_dinero(billetes)

    def test_contar(self):
        a = self.cajero.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" + "Total $20000")

    def test_extraer1(self):
        b = self.cajero.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_extraer2(self):
        c = self.cajero.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_extraer3(self):
        d = self.cajero.extraer_dinero(12100)
        self.assertEqual(
            d, "Error. No hay una combinacion de billetes que" +
            " nos permita extraer ese monto.")
예제 #3
0
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.b500 = Billete500()
        self.b200 = Billete200()
        self.cajero = Cajero()
        billetes = []
        for i in range(0, 10):
            billetes.append(self.b1000)
        for i in range(0, 20):
            billetes.append(self.b500)
        for i in range(0, 15):
            billetes.append(self.b200)
        self.cajero.agregar_dinero(billetes)

    def test_contar(self):
        a = self.cajero.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" +
            "15 billetes de $200, " + "parcial $3000\n" + "Total $23000")

    def test_extraer1(self):
        b = self.cajero.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_extraer2(self):
        c = self.cajero.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_extraer3(self):
        with self.assertRaises(CombinacionError):
            self.cajero.extraer_dinero(12100)

    def test_extraer5(self):
        with self.assertRaises(MontoError):
            self.cajero.extraer_dinero(-5000)

    def test_extraer6(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero.extraer_dinero(6850)

    def test_extraer7(self):
        with self.assertRaises(CantidadError):
            self.cajero.extraer_dinero(25000)

    def test_extraer13(self):
        c = self.cajero.extraer_dinero(23000)
        with self.assertRaises(CargaError):
            self.cajero.extraer_dinero(5000)
class CajeroTest(unittest.TestCase):
    def setUp(self):
        self.primerSet = Cajero()
        self.segundoSet = Cajero()
        self.tercerSet = Cajero()
        self.empty = Cajero()

        billetera1 = [Billete1000() for item in range(10)]

        billetera2 = [Billete1000() for item in range(10)]
        billetera2 += [Billete500() for item in range(20)]

        billetera3 = [Billete1000() for item in range(10)]
        billetera3 += [Billete500() for item in range(20)]
        billetera3 += [Billete200() for item in range(15)]

        self.primerSet.agregar_dinero(billetera1)
        self.segundoSet.agregar_dinero(billetera2)
        self.tercerSet.agregar_dinero(billetera3)

    def test_cajero_vacio(self):

        with self.assertRaises(Exception):
            self.empty.extraer_dinero(100)

    def test_contar_a(self):
        dinero_contado = self.primerSet.contado_imprimir()
        self.assertEqual(
            dinero_contado, "pesos:\n" +
            "10 billetes de $1000 parcial $10000\n\n" + "Total:10000")

    def test_extraer_bien_a(self):
        billetes = self.primerSet.extraer_dinero(5000, 0)
        ext = [i.getRepresentacion() for i in billetes]
        self.assertEqual(ext, ["$1000", "$1000", "$1000", "$1000", "$1000"])

    def test_extraer_mucho_a(self):
        self.assertRaises(Exception, self.primerSet.extraer_dinero, **{
            "monto": 12000,
            "porcentaje_cambio": 0
        })

    def test_extraer_mal_a(self):
        self.assertRaises(Exception, self.primerSet.extraer_dinero, **{
            "monto": 5520,
            "porcentaje_cambio": 0
        })

    def test_contar_b(self):
        dinero_contado = self.segundoSet.contado_imprimir()
        self.assertEqual(
            dinero_contado,
            "pesos:\n" + "10 billetes de $1000 parcial $10000\n" +
            "20 billetes de $500 parcial $10000\n\n" + "Total:20000")

    def test_extraer_bien_b(self):
        billetes = self.segundoSet.extraer_dinero(5000, 0)
        ext = [i.getRepresentacion() for i in billetes]
        self.assertEqual(ext, ["$1000", "$1000", "$1000", "$1000", "$1000"])

    def test_extraer_bien2_b(self):
        billetes = self.segundoSet.extraer_dinero(12000, 0)
        ext = [i.getRepresentacion() for i in billetes]
        self.assertEqual(ext, [
            "$1000", "$1000", "$1000", "$1000", "$1000", "$1000", "$1000",
            "$1000", "$1000", "$1000", "$500", "$500", "$500", "$500"
        ])

    def test_extraer_mal_b(self):
        self.assertRaises(Exception, self.segundoSet.extraer_dinero, **{
            "monto": 12100,
            "porcentaje_cambio": 0
        })

    def test_extraer_cambio_b(self):
        billetes = self.segundoSet.extraer_dinero(7000, 10)
        ext = [i.getRepresentacion() for i in billetes]
        self.assertEqual(ext, [
            "$500", "$500", "$1000", "$1000", "$1000", "$1000", "$1000",
            "$1000"
        ])

    def test_contar_c(self):
        dinero_contado = self.tercerSet.contado_imprimir()
        self.assertEqual(
            dinero_contado,
            "pesos:\n" + "10 billetes de $1000 parcial $10000\n" +
            "20 billetes de $500 parcial $10000\n" +
            "15 billetes de $200 parcial $3000\n\n"
            "Total:23000")

    def test_extraer_bien_c(self):
        billetes = self.tercerSet.extraer_dinero(5000, 0)
        ext = [i.getRepresentacion() for i in billetes]
        self.assertEqual(ext, ["$1000", "$1000", "$1000", "$1000", "$1000"])

    def test_extraer_bien2_c(self):
        billetes = self.tercerSet.extraer_dinero(12000, 0)
        ext = [i.getRepresentacion() for i in billetes]
        self.assertEqual(ext, [
            "$1000", "$1000", "$1000", "$1000", "$1000", "$1000", "$1000",
            "$1000", "$1000", "$1000", "$500", "$500", "$500", "$500"
        ])

    def test_extraer_mal_c(self):
        self.assertRaises(Exception, self.tercerSet.extraer_dinero, **{
            "monto": 12100,
            "porcentaje_cambio": 0
        })

    def test_extraer_cambio_c(self):
        billetes = self.tercerSet.extraer_dinero(7000, 10)
        ext = [i.getRepresentacion() for i in billetes]
        self.assertEqual(ext, [
            "$200", "$200", "$200", "$200", "$1000", "$1000", "$1000", "$1000",
            "$1000", "$1000", "$200"
        ])
    cajero1 = Cajero()
    cajero2 = Cajero()

    # Creo Billetes
    a = Billete100()
    b = Billete200()
    c = Billete500()
    d = Billete1000()
    e = Billete200()
    f = Billete1000()

    dep1 = [a, b, c, d, e, f]  # 3000 # Deposito1
    dep2 = [a, a, b, b, c, c, d, d]  # 3600 # Deposito2

    agr_bill_1 = cajero1.agregar_dinero(dep1)
    agr_bill_2 = cajero2.agregar_dinero(dep2)

    # Acitvidad de deposito
    # ACTIVIDAD 1
    a1 = Actividad("Informacion", agr_bill_1)
    a1.tipo_actividad = cargar_dinero.id
    a1.persona_id = pers1.id
    pers1.actividad.append(a1)  # Guardo actividad 1
    persona_DAO.guardar(pers1)  # Forma distinta a la actividad 2

    # ACITIVIDAD 2
    a2 = Actividad("Informacion", agr_bill_2)
    a2.tipo_actividad = cargar_dinero.id
    a2.persona_id = pers2.id
    actividad_DAO.guardar(a2)  # Guardo actividad 2
class TestCajero(unittest.TestCase):
    def setUp(self):

        self.b1000 = Billete1000()
        self.b500 = Billete500()
        self.b200 = Billete200()
        # Set 1
        self.cajero1 = Cajero()
        billetes1 = []
        for i in range(0, 10):
            billetes1.append(self.b1000)
        self.cajero1.agregar_dinero(billetes1)
        # Set 2
        self.cajero2 = Cajero()
        billetes2 = []
        for i in range(0, 10):
            billetes2.append(self.b1000)
        for i in range(0, 20):
            billetes2.append(self.b500)
        self.cajero2.agregar_dinero(billetes2)
        # Set 3
        self.cajero3 = Cajero()
        billetes3 = []
        for i in range(0, 10):
            billetes3.append(self.b1000)
        for i in range(0, 20):
            billetes3.append(self.b500)
        for i in range(0, 15):
            billetes3.append(self.b200)
        self.cajero3.agregar_dinero(billetes3)

# Test Set 1

    def test_set1_contar(self):
        a = self.cajero1.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" + "Total $10000")

    def test_set1_extraer1(self):
        b = self.cajero1.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_set1_extraer2(self):
        with self.assertRaises(CantidadError):
            self.cajero1.extraer_dinero(12000)

    def test_set1_extraer3(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero1.extraer_dinero(5520)

    def test_set1_extraer4(self):
        with self.assertRaises(MontoError):
            self.cajero1.extraer_dinero(-5000)

    def test_set1_extraer5(self):
        with self.assertRaises(CombinacionError):
            self.cajero1.extraer_dinero(9100)

    def test_set1_extraer6(self):
        c = self.cajero1.extraer_dinero(10000)
        with self.assertRaises(CargaError):
            self.cajero1.extraer_dinero(5000)

# Test Set 2

    def test_set2_contar(self):
        a = self.cajero2.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" + "Total $20000")

    def test_set2_extraer1(self):
        b = self.cajero2.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_set2_extraer2(self):
        c = self.cajero2.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_set2_extraer3(self):
        with self.assertRaises(CombinacionError):
            self.cajero2.extraer_dinero(12100)

    def test_set2_extraer4(self):
        with self.assertRaises(MontoError):
            self.cajero2.extraer_dinero(-5000)

    def test_set2_extraer5(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero2.extraer_dinero(6850)

    def test_set2_extraer6(self):
        with self.assertRaises(CantidadError):
            self.cajero2.extraer_dinero(25000)

    def test_set2_extraer7(self):
        c = self.cajero2.extraer_dinero(20000)
        with self.assertRaises(CargaError):
            self.cajero2.extraer_dinero(5000)


# Test Set 3

    def test_set3_contar(self):
        a = self.cajero3.contar_dinero()
        self.assertEqual(
            a, "10 billetes de $1000, " + "parcial $10000\n" +
            "20 billetes de $500, " + "parcial $10000\n" +
            "15 billetes de $200, " + "parcial $3000\n" + "Total $23000")

    def test_set3_extraer1(self):
        b = self.cajero3.extraer_dinero(5000)
        self.assertEqual(b, "5 billetes de $1000\n")

    def test_set3_extraer2(self):
        c = self.cajero3.extraer_dinero(12000)
        self.assertEqual(c, "10 billetes de $1000\n" + "4 billetes de $500\n")

    def test_set3_extraer3(self):
        with self.assertRaises(CombinacionError):
            self.cajero3.extraer_dinero(12100)

    def test_set3_extraer4(self):
        with self.assertRaises(MontoError):
            self.cajero3.extraer_dinero(-5000)

    def test_set3_extraer5(self):
        with self.assertRaises(MultiplicidadError):
            self.cajero3.extraer_dinero(6850)

    def test_set3_extraer6(self):
        with self.assertRaises(CantidadError):
            self.cajero3.extraer_dinero(25000)

    def test_set3_extraer7(self):
        c = self.cajero3.extraer_dinero(23000)
        with self.assertRaises(CargaError):
            self.cajero3.extraer_dinero(5000)