def test_metodo_pago(self): # datos usuario nombre = "Armando" # datos pago numTarjeta = 5581238443939998 tipo_visa = PaymentData.tipo_VISA cvv = 117 # codigo seguridad tarjeta importe = 0 datosPago = PaymentData(tipo_visa, nombre, numTarjeta, cvv, importe) assert datosPago.get_tipo_pago() == tipo_visa print("Test_metodo_pago ok")
def test_comprovacio_tipus_tarjeta_incorrecte(self): p = Viatgers(4) past = p.get_num_viatgers() f = Vol("1234ABC", "MILAN", past, 10.0) f2 = Vol("5467DEF", "PARIS", past, 20.0) Vtg = [f, f2] v = Flights(past, Vtg) c1 = Car("COTXE1", "FERRARI", "MILAN", past, 30.0) cot = [c1] c = Cars(past, cot) h1 = Hotel("HOTEL1", "MILANO", past, 4, 20.0) h2 = Hotel("HOTEL2", "LE PARIS", past, 6, 25.0) hot = [h1, h2] h = Hotels(hot) p2 = PaymentData("PAYPAL", "Samu", "123456789", "ABC", v, c, h) self.assertEqual(p2.comprobar_targeta(), False)
def default_payment_data(): """ Fixture to create a PaymentData object from a default values. """ return PaymentData(DEFAULT_CARD_HOLDER_NAME, DEFAULT_CARD_NUMBER, DEFAULT_CARD_CVV, DEFAULT_PAYMENT_AMOUNT, DEFAULT_CARD_TYPE)
def __init__(self): self.__usuari__ = User() self.__dadesPagament__ = PaymentData() self.__VolsReservar__ = list() self.__HotelsReservar__ = list() self.__CotxesReservar__ = list() self.__numPersones__ = -1 self.__maxim__ = 4
def test_errorReservaVols(self): with pytest.raises(ValueError): viaje1 = Viaje(usr, 2) metode_pagament = PaymentData("Mastercard", "Jesus Gil Padre", "123456", "4242") viaje1.addDestino(Flights("1234", "Sant Esteve de les Roures", 100)) viaje1.addDestino(Flights(4737, "Talavera de la Reina", 50)) viaje1.user.seleccioMetodePagament(metode_pagament) viaje1.reservarYpagar()
def test1(self): aux1 = Vuelos(destino='BCN') aux2 = Vuelos(destino='ITA') aux_vuelo = [aux1, aux2] x = Viajes(lista_pasajeros=['p1', 'p2', 'p3'], vuelos=aux_vuelo) y = PaymentData('MASTERCARD', 'Pepito', '4546', '50') x.payment_V2(y) assert (x.payment_data.tipo_tarjeta == 'MASTERCARD')
def test_confirmaPagamentDestinacio(self): viaje1 = Viaje(usr, 1) viaje2 = Viaje(usr, 5) viajes = [viaje1, viaje2] test_res = [True, True] payData = PaymentData('VISA', 'Jesus Gil y Gil', '9999999999999999', '433') for viaje in viajes: viaje.addDestino(Flights("87465", "Martorell", 200)) viaje.user.seleccioMetodePagament(payData) for i, viaje in enumerate(viajes): self.assertEqual(viaje.reservarYpagar(), test_res[i])
def _process_payment_data(self, user_name: str, card_number: str, security_code: str, credit_card_type: str) -> PaymentData: """ Call _configure_travel and create an instance of PaymentData with the amount calculated. :param user_name: string with the name of the card holder :param card_number: string containing the card number :param security_code: integer with the security code of the card :return: instance of PaymentData with the total amount of money to pay and client information """ self._configure_travel() return PaymentData(user_name, card_number, security_code, self._travel.cost, credit_card_type)
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
def test_calcula_preu(self): p = Viatgers(4) past = p.get_num_viatgers() f = Vol("1234ABC", "MILAN", past, 10.0) f2 = Vol("5467DEF", "PARIS", past, 20.0) Vtg = [f, f2] v = Flights(past, Vtg) c1 = Car("COTXE1", "FERRARI", "MILAN", 4, 30.0) cot = [c1] c = Cars(past, cot) h1 = Hotel("HOTEL1", "MILANO", past, 4, 20.0) h2 = Hotel("HOTEL2", "LE PARIS", past, 6, 25.0) hot = [h1, h2] h = Hotels(hot) p = PaymentData("Visa", "Ruben", "1234", "1342", v, c, h) self.assertEqual(p.get_import_total(), 1160.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)
car_1 = Cars("1234ABC", "Suv", "BMW", "Calle Falsa 123", "Aeropuerto", 7, 150) car_2 = Cars("5089PFE", "Deportivo", "Audi", "Plaza del Pueblo", "Aeropuerto", 4, 70) car_3 = Cars("6205MOA", "Familiar", "Renault", "Calle Karl Marx", "Aeropuerto", 2, 25) hotel_1 = Hotels(1, "Jerez de la Frontera", "Morenos, 10, 11402 Jerez de la Frontera, España", 26, 7, 1) hotel_2 = Hotels(2, "Talavera de la Reina", "Roma, 1, 45600 Talavera de la Reina, España", 62, 7, 1) vuelo_1 = Flights("15612F", "MADRID", 55) vuelo_2 = Flights("68745A", "ESTAMBUL", 90) vuelo_3 = Flights("86452T", "LONDRES", 85) metode_pagament = PaymentData("Mastercard", "Jesus Gil Padre", "123456", "4242") class test_viaje_v4(unittest.TestCase): @mock.patch('src.Bank.do_payment', return_value=False) def test_volverRealizarPago(self, mock_Bank): num_passatgers = 3 viaje = Viaje(usr, num_passatgers) viaje.addDestino(vuelo_1) viaje.addDestino(vuelo_2) viaje.user.seleccioMetodePagament(metode_pagament) mock_Bank.do_payment.return_value = False self.assertTrue(mock_Bank.reservarYpagar()) #viaje.reservarYpagar().return_value = False