Пример #1
0
 def pagament(self, precio):
     self.dades_pagament.añadirImporte(precio)
     banco = Bank()
     if self.validateInput() and self.dades_pagament.validateData():
         return banco.do_payment(self, self.dades_pagament)
     else:
         return False
Пример #2
0
    def payment_V2(self, payment, e=0):
        if e:
            return False

        x = Bank()

        self.payment_data = payment

        return x.do_payment(self.user, self.payment_data)
Пример #3
0
    def payment_V3(self, payment, e=0, reintentos=0, max=0):
        if e:
            return False
        if reintentos:
            return False
        if max >= 3:
            exit(0)

        x = Bank()

        self.payment_data = payment

        return x.do_payment(self.user, self.payment_data)
    def test2(self):
        aux1 = Vuelos(destino='BCN')
        aux2 = Vuelos(destino='ITA')
        aux_vuelo = [aux1, aux2]

        y = PaymentData('MASTERCARD', 'Pepito', '4546', '50')
        x = Viajes(user=User,
                   lista_pasajeros=['p1', 'p2', 'p3'],
                   vuelos=aux_vuelo)
        aux = User('Pol', '12345678J', '08390', '123456789', '*****@*****.**')

        fallo = x.payment_V2(y, 1)
        Bank.do_payment = MagicMock(return_value=False)
        i = Bank()

        assert i.do_payment(aux, y) == fallo
Пример #5
0
 def mock_confirm_payment(*args):
     retries = 0
     while retries < DEFAULT_MAX_RETRIES:
         try:
             return Bank.do_payment(*args)
         except ConnectionRefusedError:
             retries += 1
     return retries
Пример #6
0
 def mock_confirm_payment(*args):
     retries = 0
     while retries < DEFAULT_MAX_RETRIES:
         try:
             return retries, Bank.do_payment(*args)
         except ConnectionRefusedError:
             retries += 1
             if retries == DEFAULT_RETRIES:
                 monkeypatch.setattr(Bank, "do_payment", mock_bank_success)
Пример #7
0
 def ReservaCarsConsiderantErrors(self, api_rentalCars):
     resultatConfirmacio = api_rentalCars.confirm_reserve(self.__usuari__, self.__CotxesReservar__)
     i = 0
     while(resultatConfirmacio == False and i < 3):
         resultatConfirmacio = api_rentalCars.confirm_reserve(self.__usuari__, self.__CotxesReservar__)
         i = i + 1
     if(i == 3):
         api_banc = Bank()
         self.__dadesPagament__.__import__ = -1*self.__dadesPagament__.__import__
         self.PagamentViatge(api_banc)
         self.__dadesPagament__.__import__ = -1*self.__dadesPagament__.__import__
     return resultatConfirmacio
Пример #8
0
 def ReservaVolsConsiderantErrors(self, api_SkyScanner):
     resultatConfirmacio = api_SkyScanner.confirm_reserve(self.__usuari__, self.__VolsReservar__)
     i = 0
     while((resultatConfirmacio == False) & (i < 3)):
         resultatConfirmacio = api_SkyScanner.confirm_reserve(self.__usuari__, self.__VolsReservar__)
         i = i + 1
     if(i == 3):
         api_banc = Bank()
         self.__dadesPagament__.__import__ = -1*self.__dadesPagament__.__import__
         self.PagamentViatge(api_banc)
         self.__dadesPagament__.__import__ = -1*self.__dadesPagament__.__import__
     return resultatConfirmacio
Пример #9
0
    def _confirm_payment(self, payment_data: PaymentData) -> bool:
        """ Connect to the Bank API and perform the payment

        Catches ConnectionRefusedError(s) thrown by the Bank API and tries to establish the connection again.

        :param payment_data: the stored payment data in the Reservation
        :return: bool value indicating if the payment is done
        """

        retries = 0
        while retries < self.MAX_RETRIES:
            try:
                return Bank.do_payment(self._user, payment_data)
            except ConnectionRefusedError:
                retries += 1

        raise ConnectionRefusedError(Response.BANK_ERROR)
def bank(empty_account, activated_account):
    """Фикстура банка с предустановленными счетами"""
    bank = Bank("TestBank", [empty_account, activated_account])
    return bank
Пример #11
0
 def payment_V1(self, tipo_tarjeta, titular_tarjeta, cod_seg_tarjeta):
     precio_final = self.calcular_precio()
     x = Bank()
     self.payment_data = PaymentData(tipo_tarjeta, titular_tarjeta,
                                     cod_seg_tarjeta, precio_final)
     return x.do_payment(self.user, self.payment_data)
Пример #12
0
def function_bank(request):
    bank = Bank("FunctionBank", [])
    request.addfinalizer(bank.close)
    return bank
Пример #13
0
def session_bank(request):
    bank = Bank("SessionBank", [])
    request.addfinalizer(bank.close)
    return bank
Пример #14
0
def module_bank(request):
    bank = Bank("ModuleBank", [])
    request.addfinalizer(bank.close)
    return bank
Пример #15
0
def class_bank(request):
    bank = Bank("ClassBank", [])
    request.addfinalizer(bank.close)
    return bank