Exemple #1
0
def test_show_transactions():
    repoTran = RepositoryTransaction("tranzactiiTests.txt")
    repoCar = RepositoryCar("masiniTests.txt")
    car_service = CarService(repoCar, "")
    tran_service = TransactionService(repoTran, car_service)
    tran1 = Transaction(1, 1, 1, 1200, 700, "12.12.2010", 13.30)
    tran_service.add_transaction(tran1.getTId(), tran1.getIdCar(),
                                 tran1.getIdCard(), tran1.getSumaP(),
                                 tran1.getSumaM(), tran1.getDate(),
                                 tran1.getHour())
    tran2 = Transaction(2, 2, 2, 2000, 1300, "12.12.2010", 13.30)
    tran_service.add_transaction(tran2.getTId(), tran2.getIdCar(),
                                 tran2.getIdCard(), tran2.getSumaP(),
                                 tran2.getSumaM(), tran2.getDate(),
                                 tran2.getHour())
    tran3 = Transaction(3, 3, 3, 800, 450, "12.12.2010", 13.30)
    tran_service.add_transaction(tran3.getTId(), tran3.getIdCar(),
                                 tran3.getIdCard(), tran3.getSumaP(),
                                 tran3.getSumaM(), tran3.getDate(),
                                 tran3.getHour())
    assert len(repoTran.getAll()) == 3
    l = tran_service.show_tranzactions("sumaP", 600, 900)
    l1 = []
    l1.append(str(tran3))
    assert l[0] == str(l1)
    repoTran.eraseFile()
Exemple #2
0
def test_show_transactions_data():
    repoTran = RepositoryTransaction("tranzactiiTests.txt")
    repoCar = RepositoryCar("masiniTests.txt")
    car_service = CarService(repoCar, "")
    tran_service = TransactionService(repoTran, car_service)
    tran1 = Transaction(1, 1, 1, 1200, 700, "09.03.2011", 13.30)
    tran_service.add_transaction(tran1.getTId(), tran1.getIdCar(),
                                 tran1.getIdCard(), tran1.getSumaP(),
                                 tran1.getSumaM(), tran1.getDate(),
                                 tran1.getHour())
    tran2 = Transaction(2, 2, 2, 2000, 1300, "12.12.2012", 13.30)
    tran_service.add_transaction(tran2.getTId(), tran2.getIdCar(),
                                 tran2.getIdCard(), tran2.getSumaP(),
                                 tran2.getSumaM(), tran2.getDate(),
                                 tran2.getHour())
    tran3 = Transaction(3, 3, 3, 800, 450, "12.12.2003", 13.30)
    tran_service.add_transaction(tran3.getTId(), tran3.getIdCar(),
                                 tran3.getIdCard(), tran3.getSumaP(),
                                 tran3.getSumaM(), tran3.getDate(),
                                 tran3.getHour())
    assert len(repoTran.getAll()) == 3
    l = tran_service.show_transaction_data("03.07.2010", "12.12.2013")

    assert len(repoTran.getAll()) == 1
    repoTran.eraseFile()
Exemple #3
0
def test_reducere():
    repoTran = RepositoryTransaction("tranzactiiTests.txt")
    repoCar = RepositoryCar("masiniTests.txt")
    car_service = CarService(repoCar, "")
    tran_service = TransactionService(repoTran, car_service)
    tran1 = Transaction(1, 1, 1, 1200, 700, "12.12.2010", 13.30)
    tran_service.add_transaction(tran1.getTId(), tran1.getIdCar(),
                                 tran1.getIdCard(), tran1.getSumaP(),
                                 tran1.getSumaM(), tran1.getDate(),
                                 tran1.getHour())
    tran2 = Transaction(2, 2, 2, 2000, 1300, "12.12.2010", 13.30)
    tran_service.add_transaction(tran2.getTId(), tran2.getIdCar(),
                                 tran2.getIdCard(), tran2.getSumaP(),
                                 tran2.getSumaM(), tran2.getDate(),
                                 tran2.getHour())
    tran3 = Transaction(3, 3, 3, 800, 450, "12.12.2010", 13.30)
    tran_service.add_transaction(tran3.getTId(), tran3.getIdCar(),
                                 tran3.getIdCard(), tran3.getSumaP(),
                                 tran3.getSumaM(), tran3.getDate(),
                                 tran3.getHour())
    assert len(repoTran.getAll()) == 3
    dict1 = tran_service.reducere()

    dict = {}
    dict[700] = '70.0'
    dict[1300] = '130.0'
    dict[450] = '45.0'
    assert dict1 == dict
    repoTran.eraseFile()
def test_transaction1():
    tran = Transaction(1, 1, 1, 1200, 700, "12.12.2009", 13.30)
    assert tran.getTId() == 1
    assert tran.getIdCar() == 1
    assert tran.getIdCard() == 1
    assert tran.getSumaP() == 1200
    assert tran.getSumaM() == 700
    assert tran.getDate() == "12.12.2009"
    assert tran.getHour() == 13.30
Exemple #5
0
def test_Transaction():
    t = Transaction(1, 2, 0, 2, "13.11.2019", "11:34", "True")
    assert t.getID() == 1
    assert t.getMedID() == 2
    assert t.getCardID() == 0
    assert t.getAmount() == 2
    assert t.getDate() == "13.11.2019"
    assert t.getClock() == "11:34"
    t1 = Transaction(1, 2, 0, 2, "13.11.2019", "11:34", "True")
    assert t1 == t
    t1.setMedID(3)
    assert t1 != t
Exemple #6
0
def test_order_car_desc():
    repoTran = RepositoryTransaction("tranzactiiTests.txt")
    repoCar = RepositoryCar("masiniTests.txt")
    car_service = CarService(repoCar, "")
    tran_service = TransactionService(repoTran, car_service)
    tran1 = Transaction(1, 1, 1, 1200, 700, "12.12.2010", 13.30)
    tran_service.add_transaction(tran1.getTId(), tran1.getIdCar(),
                                 tran1.getIdCard(), tran1.getSumaP(),
                                 tran1.getSumaM(), tran1.getDate(),
                                 tran1.getHour())
    tran2 = Transaction(2, 2, 2, 2000, 1300, "12.12.2010", 13.30)
    tran_service.add_transaction(tran2.getTId(), tran2.getIdCar(),
                                 tran2.getIdCard(), tran2.getSumaP(),
                                 tran2.getSumaM(), tran2.getDate(),
                                 tran2.getHour())
    tran3 = Transaction(3, 3, 3, 800, 450, "12.12.2010", 13.30)
    tran_service.add_transaction(tran3.getTId(), tran3.getIdCar(),
                                 tran3.getIdCard(), tran3.getSumaP(),
                                 tran3.getSumaM(), tran3.getDate(),
                                 tran3.getHour())
    assert len(repoTran.getAll()) == 3
    car1 = Car(1, "Mercedes", 2019, 0, "da")
    car_service.add_car(car1.getCarId(), car1.getModel(), car1.getYear(),
                        car1.getNoKm(), car1.getGuarantee())
    car2 = Car(2, "Ford", 2007, 120000, "da")
    car_service.add_car(car2.getCarId(), car2.getModel(), car2.getYear(),
                        car2.getNoKm(), car2.getGuarantee())
    car3 = Car(3, "bmw", 2001, 100000, "nu")
    car_service.add_car(car3.getCarId(), car3.getModel(), car3.getYear(),
                        car3.getNoKm(), car3.getGuarantee())
    assert len(repoCar.getAll()) == 3
    l = car_service.order_car_desc()
    l1 = [car1, car2, car3]
    string = str(l1[:])
    comp = string.split(",")
    assert l == l1
    print(l)
    repoTran.eraseFile()
    repoCar.eraseFile()
Exemple #7
0
def add_transaction_test():
    repoTran = RepositoryTransaction("tranzactiiTests.txt")
    repoCar = RepositoryCar("masiniTests.txt")
    car_service = CarService(repoCar, "")
    tran_service = TransactionService(repoTran, car_service)
    assert len(repoTran.getAll()) == 0
    tran = Transaction(1, 1, 1, 1200, 700, "12.12.2010", 13.30)
    tran_service.add_transaction(tran.getTId(), tran.getIdCar(),
                                 tran.getIdCard(), tran.getSumaP(),
                                 tran.getSumaM(), tran.getDate(),
                                 tran.getHour())
    assert len(repoTran.getAll()) == 1
    repoTran.eraseFile()
Exemple #8
0
def test_guarantee():
    repoTran = RepositoryTransaction("tranzactiiTests.txt")
    repoCar = RepositoryCar("masiniTests.txt")
    car_service = CarService(repoCar, "")
    tran_service = TransactionService(repoTran, car_service)
    tran1 = Transaction(1, 1, 1, 1200, 700, "12.12.2010", 13.30)
    tran_service.add_transaction(tran1.getTId(), tran1.getIdCar(),
                                 tran1.getIdCard(), tran1.getSumaP(),
                                 tran1.getSumaM(), tran1.getDate(),
                                 tran1.getHour())
    tran2 = Transaction(2, 2, 2, 2000, 1300, "12.12.2010", 13.30)
    tran_service.add_transaction(tran2.getTId(), tran2.getIdCar(),
                                 tran2.getIdCard(), tran2.getSumaP(),
                                 tran2.getSumaM(), tran2.getDate(),
                                 tran2.getHour())
    tran3 = Transaction(3, 3, 3, 800, 450, "12.12.2010", 13.30)
    tran_service.add_transaction(tran3.getTId(), tran3.getIdCar(),
                                 tran3.getIdCard(), tran3.getSumaP(),
                                 tran3.getSumaM(), tran3.getDate(),
                                 tran3.getHour())
    assert len(repoTran.getAll()) == 3
    car1 = Car(1, "Mercedes", 2019, 0, "da")
    car_service.add_car(car1.getCarId(), car1.getModel(), car1.getYear(),
                        car1.getNoKm(), car1.getGuarantee())
    car2 = Car(2, "Ford", 2008, 120000, "nu")
    car_service.add_car(car2.getCarId(), car2.getModel(), car2.getYear(),
                        car2.getNoKm(), car2.getGuarantee())
    car3 = Car(3, "bmw", 2018, 100000, "nu")
    car_service.add_car(car3.getCarId(), car3.getModel(), car3.getYear(),
                        car3.getNoKm(), car3.getGuarantee())
    assert len(repoCar.getAll()) == 3
    dict1 = tran_service.guarantee()
    dict = {}
    dict[1200] = 0
    assert dict1 == dict
    repoTran.eraseFile()
    repoCar.eraseFile()
def test_transaction2():
    tran = Transaction(1, 1, 1, 1200, 700, "12.12.2009", 13.30)
    tran.setTId(2)
    assert tran.getTId() == 2
    tran.setIdCar(2)
    assert tran.getIdCar() == 2
    tran.setIdCard(2)
    assert tran.getIdCard() == 2
    tran.setSumaP(1300)
    assert tran.getSumaP() == 1300
    tran.setSumaM(800)
    assert tran.getSumaM() == 800
    tran.setDate("13.12.2009")
    assert tran.getDate() == "13.12.2009"
    tran.setHour(13.00)
    assert tran.getHour() == 13.00