Пример #1
0
 def test_ReservaV3(self, mock_Rentalcars, mock_Booking):
     R3 = reserva(preu=0,
                  usuaris=[],
                  nUsuaris=0,
                  llistaVols=[],
                  llistaVehicles=[],
                  pagament=PaymentData("", "", "", "", ""),
                  allotjament=[],
                  Destins=[])
     R3.afegirUsuari("", "", "", "", "")
     R3.afegirUsuari("", "", "", "", "")
     R3.afegirVehicle("", "45682484A", "", 3, 25)
     assert R3.get_preu() == 75
     R3.eliminarVehicle("45682484A")
     assert R3.get_preu() == 0
     R3.afegirAllotjament("", 200, "", "", "AUS 548", 4)
     assert R3.get_preu() == 800
     R3.eliminarAllotjament("AUS 548")
     assert R3.get_preu() == 0
     mock_Rentalcars.confirm_reserve.return_value = True
     mock_Booking.confirm_reserve.return_value = True
     a, b = R3.ConfirmarReservaCoches("", "")
     assert a == "Reserva realitzada correctament"
     a, b = R3.ConfirmarReservaAllotjaments("", "")
     assert a == "Reserva realitzada correctament"
     mock_Rentalcars.confirm_reserve.return_value = False
     mock_Booking.confirm_reserve.return_value = False
     a, b = R3.ConfirmarReservaCoches("", "")
     assert a == "Error en la reserva"
     a, b = R3.ConfirmarReservaAllotjaments("", "")
     assert a == "Error en la reserva"
 def test_ReservaV4_2(
     self,
     mock_Skyscanner,
 ):
     R42 = reserva(preu=0,
                   usuaris=[],
                   nUsuaris=0,
                   llistaVols=[],
                   llistaVehicles=[],
                   pagament=PaymentData("", "", "", "", ""),
                   allotjament=[],
                   Destins=[])
     R42.afegirUsuari("", "", "", "", "")
     R42.afegirUsuari("", "", "", "", "")
     R42.afegirDesti("Madrid", "151", 80)
     R42.afegirDesti("Barcelona", "232", 120)
     mock_Skyscanner.confirm_reserve.return_value = False
     a, b = R42.ConfirmarReservaVols("", "")
     assert b > 1
     mock_Skyscanner.confirm_reserve.side_effect = [
         False,
         True,
         False,
         False,
         False,
     ]
     a, b = R42.ConfirmarReservaVols("", "")
     assert b == 2 and a == "Reserva realitzada correctament"
     mock_Skyscanner.confirm_reserve.side_effect = [
         False, False, False, False, False
     ]
     a, b = R42.ConfirmarReservaVols("", "")
     assert b == 5 and a == "Error en la reserva"
Пример #3
0
 def test_ReservaV5(self, mock_Rentalcars, mock_Booking):
     R5 = reserva(preu=0,
                  usuaris=[],
                  nUsuaris=0,
                  llistaVols=[],
                  llistaVehicles=[],
                  pagament=PaymentData("", "", "", "", ""),
                  allotjament=[],
                  Destins=[])
     R5.afegirUsuari("", "", "", "", "")
     R5.afegirUsuari("", "", "", "", "")
     R5.afegirDesti("Madrid", "151", 80)
     R5.afegirDesti("Barcelona", "232", 120)
     assert R5.rellenar_dades_Facturació("PEPE", 1456871430214742, "Visa",
                                         543) == "Dades correctes"
     assert R5.rellenar_dades_Facturació("143", "Lele", "Visas",
                                         543517) == "Dades invalides"
     R5.rellenar_dades_Facturació("PEPE", 1456871430214742, "Visa", 543)
     Dades = R5.get_data_pagament()
     assert Dades.get_nomtitular() == "PEPE"
     assert Dades.get_codiseguretat() == 543
     assert Dades.mostrar_tipus_targeta() == "Visa"
     assert Dades.mostra_import() == 400
     assert Dades.mostra_num_targeta() == 1456871430214742
     mock_Booking.confirm_reserve.return_value = False
     a, b = R5.ConfirmarReservaAllotjaments("", "")
     assert b > 1
     mock_Booking.confirm_reserve.side_effect = [
         False,
         True,
         False,
         False,
         False,
     ]
     a, b = R5.ConfirmarReservaAllotjaments("", "")
     assert b == 2 and a == "Reserva realitzada correctament"
     mock_Booking.confirm_reserve.side_effect = [
         False, False, False, False, False
     ]
     a, b = R5.ConfirmarReservaAllotjaments("", "")
     assert b == 5 and a == "Error en la reserva"
     mock_Rentalcars.confirm_reserve.return_value = False
     a, b = R5.ConfirmarReservaCoches("", "")
     assert b > 1
     mock_Rentalcars.confirm_reserve.side_effect = [
         False,
         True,
         False,
         False,
         False,
     ]
     a, b = R5.ConfirmarReservaCoches("", "")
     assert b == 2 and a == "Reserva realitzada correctament"
     mock_Rentalcars.confirm_reserve.side_effect = [
         False, False, False, False, False
     ]
     a, b = R5.ConfirmarReservaCoches("", "")
     assert b == 5 and a == "Error en la reserva"
Пример #4
0
 def __init__(self,
              preu=0,
              usuaris=[],
              nUsuaris=0,
              llistaVols=[],
              llistaVehicles=[],
              pagament=PaymentData("", "", "", "", ""),
              allotjament=[],
              Destins=[]):
     self.__preu = preu
     self.__usuaris = usuaris
     self.__nUsuaris = nUsuaris
     self.__llistaVols = llistaVols
     self.__llistaVehicles = llistaVehicles
     self.__pagament = pagament
     self.__llistaAllotjaments = allotjament
     self.__Destins = Destins
     self.__maxFlights = 4
     self.__maxReintents = 5
Пример #5
0
    def rellenar_dades_Facturació(self, nomtitular, numtargeta, tipustargeta,
                                  codiseguretat):

        if not isinstance(nomtitular, str):
            return "Dades invalides"
        if not isinstance(numtargeta, int):
            return "Dades invalides"
        if not isinstance(tipustargeta, str):
            return "Dades invalides"
        if not isinstance(codiseguretat, int):
            return "Dades invalides"
        if len(str(numtargeta)) != 16:
            return "Dades invalides"
        if len(str(codiseguretat)) != 3:
            return "Dades invalides"
        if tipustargeta != 'Visa' and tipustargeta != "Mastercard":
            return "Dades invalides"
        self.__pagament = PaymentData(nomtitular, numtargeta, tipustargeta,
                                      codiseguretat, self.__preu)
        return "Dades correctes"
Пример #6
0
    def test_ReservaV1(self):

        R = reserva(preu=0,
                    usuaris=[],
                    nUsuaris=0,
                    llistaVols=[],
                    llistaVehicles=[],
                    pagament=PaymentData("", "", "", "", ""),
                    allotjament=[],
                    Destins=[])
        R.afegirUsuari("", "", "", "", "")
        assert R.get_nUsuaris() == 1
        assert R.get_llistatVols() == []
        assert R.get_Destins() == []
        assert R.get_preu() == 0
        R.afegirDesti("Madrid", "151", 80)
        p = 80
        assert p == R.get_preu()
        a = []
        a.append(Desti("Madrid", "151", 80))
        assert R.get_Destins() == a
        b = []
        b.append(Flights("", "", "151", "", "", ""))
        assert R.get_llistatVols() == b
        R.afegirUsuari("", "", "", "", "")
        p = 80 * 2
        assert p == R.get_preu()
        R.afegirDesti("Barcelona", "232", 120)
        R.eliminarDesti("232")
        assert p == R.get_preu()
        assert R.get_llistatVols() == b
        assert R.get_Destins() == a

        a, b = R.RealitzarPagament("p", "l")
        assert a == "Pagament realitzat correctament"
        a, b = R.ConfirmarReservaVols("p", "l")
        assert a == "Reserva realitzada correctament"
Пример #7
0
 def test_ReservaV2(self, mock_Bank, mock_Skyscanner):
     R2 = reserva(preu=0, usuaris=[], nUsuaris=0, llistaVols=[], llistaVehicles=[], pagament=PaymentData("","","","",""), allotjament=[], Destins=[])
     R2.afegirUsuari("", "", "", "", "")
     R2.afegirUsuari("", "", "", "", "")
     R2.afegirDesti("Madrid", "151", 80)
     R2.afegirDesti("Barcelona", "232", 120)
     R2.seleccionar_metode_pagament("Visa")
     a = R2.get_data_pagament()
     assert a.mostrar_tipus_targeta() == "Visa"
     mock_Bank.do_payment.return_value = False
     mock_Skyscanner.confirm_reserve.return_value = False
     a, b = R2.RealitzarPagament("", "")
     assert a == "Error en el pagament"
     a, b = R2.ConfirmarReservaVols("", "")
     assert a == "Error en la reserva"
 def test_ReservaV4_1(self,mock_Bank,):
     R41 = reserva(preu=0, usuaris=[], nUsuaris=0, llistaVols=[], llistaVehicles=[], pagament=PaymentData("","","","",""), allotjament=[], Destins=[])
     R41.afegirUsuari("", "", "", "", "")
     R41.afegirUsuari("", "", "", "", "")
     R41.afegirDesti("Madrid", "151", 80)
     R41.afegirDesti("Barcelona", "232", 120)
     mock_Bank.do_payment.return_value = False
     a,b = R41.RealitzarPagament("", "")
     assert b>1
     mock_Bank.do_payment.side_effect = [False,True,False,False,False,]
     a, b = R41.RealitzarPagament("", "")
     assert b==2 and a=="Pagament realitzat correctament"
     mock_Bank.do_payment.side_effect = [False,False,False,False,False]
     a, b = R41.RealitzarPagament("", "")
     assert b == 5 and a == "Error en el pagament"