Ejemplo n.º 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
Ejemplo n.º 2
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
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def test_3(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_V3(y, 1, 1, 0)
        i = Bank()
        i.do_payment = MagicMock(return_value=False)

        error_max = x.payment_V3(y, 0, 0, 3)
        j = Bank()
        j.do_payment = MagicMock(return_value=False)

        assert j.do_payment(aux, y) == error_max
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)