コード例 #1
0
 def test_get_seat_lean_specifications(self):
     with patch('src.Cars.requests') as mock_requests:
         mock_requests.get.side_effect = Timeout
         with self.assertRaises(Timeout):
             Cars.download_seat_leon_specifications()
             # Assert that the mock was called exactly once
             mock_requests.get.assert_called_once()
コード例 #2
0
ファイル: Viaje.py プロジェクト: S1nd1c/ES-2020-432-03
 def cancelaReserva_vehicle(self): # OJO PIOJO A ESTA FUNCION
     for coche in self.lista_coches:
         cars = Cars()
         if cars.reserva_coche(self.user, coche) != True:
             return True
         else:
             return False
コード例 #3
0
 def test_modificar_cotxe_import_total(self):
     p = Viatgers(4)
     past = p.get_num_viatgers()
     c1 = Car("COTXE1", "CITROEN", "LLOC1", past, 25.0)
     c2 = Car("COTXE2", "SEAT", "LLOC2", past, 19.0)
     cotxes = [c1]
     c = Cars(past, cotxes)
     c.modificar_cotxe(c1, c2)
     self.assertEqual(c.calcul_import_total_cotxe(), 76.0)
コード例 #4
0
 def confirmacion_coches(self, n_pasajeros, cod_car, marca, lugar_recogida,
                         dias_reserva):
     coche = Rentalcars()
     aux = Cars(cod_car, marca, lugar_recogida, dias_reserva)
     comp = aux.comprueba(cod_car, marca, lugar_recogida, dias_reserva)
     if comp == 1 and n_pasajeros <= 4:
         return coche.confirm_reserve(self.user, self.coches)
     else:
         return -1
コード例 #5
0
 def test_afegir_cotxe_import_total(self):
     p = Viatgers(4)
     past = p.get_num_viatgers()
     c1 = Car("COTXE1", "CITROEN", "LLOC1", past, 25.0)
     c2 = Car("COTXE2", "SEAT", "LLOC2", past, 19.0)
     c3 = Car("COTXE3", "MERCEDES-BENZ", "LLOC3", past, 32.0)
     cotxes = [c1, c2]
     c = Cars(past, cotxes)
     c.afegir_cotxe(c3)
     self.assertEqual(c.calcul_import_total_cotxe(), 304.0)
コード例 #6
0
    def test_2(self):
        aux1 = Cars(marca='BMW')
        aux2 = Cars()
        aux_coches = [aux1, aux2]
        n_viajeros = 3

        x = Viajes(lista_pasajeros=['p1', 'p2', 'p3'], coches=aux_coches)
        x.eliminar_coches('BMW')
        precio = x.precio
        precio_total = len(aux_coches) * precio * n_viajeros

        assert precio_total == x.calcular_precio()
コード例 #7
0
    def test_6(self):
        aux1 = Cars(marca='BMW')
        aux2 = Cars()
        aux_coches = [aux1, aux2]

        x = Viajes(user=User,
                   lista_pasajeros=['p1', 'p2', 'p3'],
                   coches=aux_coches)
        aux = User('Pepito Los Palotes', '12345678P', '08390', '678942316',
                   '*****@*****.**')

        fallo = x.anadir_coche(1)
        rentalcars = Rentalcars()
        rentalcars.confirm_reserve = MagicMock(return_value=False)

        assert rentalcars.confirm_reserve(aux, aux_coches) == fallo
コード例 #8
0
    def test_5(self):

        aux1 = Cars(marca='BMW')
        aux2 = Cars()
        aux_coches = [aux1, aux2]

        user = User('Pepito Los Palotes', '12345678P', '08390', '678942316',
                    '*****@*****.**')

        x = Viajes(user=user,
                   lista_pasajeros=['p1', 'p2', 'p3'],
                   coches=aux_coches)

        datos = x.anadir_coche()
        x.anadir_coche = MagicMock(return_value=True)

        assert datos == x.anadir_coche()
コード例 #9
0
 def test_ErrorReservaVehiculos(self):
     with pytest.raises(ValueError):
         viaje1 = Viaje(usr, 3)
         viaje1.addDestino(vuelo_2)
         viaje1.addDestino(vuelo_1)
         viaje1.añadirCoche(car_1)
         viaje1.añadirCoche(
             Cars(123, "Suv", "BMW", "Calle Falsa 123", "Aeropuerto", 7,
                  150))
         viaje1.confirmaReserva_vehicle()
コード例 #10
0
def test_cars_ctor(default_car_list: list):
    """ Test case for Cars.__init__(**) method

    Tests the constructor of the Cars class

    EXPECTED BEHAVIOUR:
        The object is instantiated with the default values
    """

    cars = Cars(default_car_list)
    assert len(cars) != 0
    assert len(cars) == DEFAULT_CARS_LEN
コード例 #11
0
 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)
コード例 #12
0
def test_getitem_cars(default_cars: Cars, default_car_list: list):
    """ Test case for Cars.__getitem__(**) method

    RESTRICTION:
        The code of the Car object to be searched should exist in Cars' dictionary.

    TEST CASE:
        Get the object with the given code in the Cars' dictionary.

    EXPECTED BEHAVIOUR:
        The instance of car searched is returned.
    """

    car = default_car_list[0]
    assert default_cars.__getitem__(car.code) == car
    assert default_cars._cars[car.code] == car
コード例 #13
0
 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)
コード例 #14
0
import unittest
import pytest
from src.Viaje import Viaje
from src.Cars import Cars
from src.User import User
from src.Flights import Flights
from src.Hotels import Hotels
from src.PaymentData import PaymentData

usr = User("Jesus Gil y Gil", "75245896W", "654879524",
           "Calle Alamo 23, Marbella", "*****@*****.**")
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)


class test_viatje_v3(unittest.TestCase):
    def test_sumaPrecioAñadirCoche(self):
        viaje = Viaje(usr, 3)
        viaje.añadirCoche(car_1)
コード例 #15
0
 def setUpClass(cls):
     cls.Cars = Cars()
コード例 #16
0
ファイル: conftest.py プロジェクト: JoanRosell/ES-2020-412-06
def default_cars(default_car_list):
    """ Fixture to create a Cars object from a default car list.

    """

    return Cars(default_car_list)
コード例 #17
0
    def testCasAfegir (self):
         vol = Flights() # "EF325F","Roma", 2, 50, 1 -> preu 101 
         vol.__codiVol__ = "EF325F"
         vol.__desti__ = "ROMA"
         vol.__numPassatgers__ = 2
         vol.__importv__ = 50
         vol.__taxav__ = 1
         
         cotxe1 = Cars()
         cotxe2 = Cars()
         
         cotxe1.__codi__ = 24
         cotxe1.__diesReserva__ = 10
         cotxe1.__importc__ = 10
         cotxe1.__taxac__ = 25
         #preu 125
         
         cotxe2.__codi__ = 25
         cotxe2.__diesReserva__ = 5
         cotxe2.__importc__ = 10
         cotxe2.__taxac__ = 30
         #preu 80
         
         viatge = Viatge()
         
         viatge.__numPersones__ = 2
         viatge.__VolsReservar__.append(vol)

         
         viatge.gestioCotxes(0, cotxe1)
         self.assertEqual(viatge.__dadesPagament__.__import__, 226)
         
         viatge.gestioCotxes(0, cotxe2)
         self.assertEqual(viatge.__dadesPagament__.__import__, 306)