Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
def main():
    
    payeeService=PayeeService()
    transactionService=TransactionService()
    customer=user_login_first()
    choice=0
    if(customer==None):
        choice=int(input("Login attemt failed! Enter the choice to continue with login, press 1 to continue."))
        
    while(customer==None and choice==1):
        customer=user_login_first()
        if(customer==None):
            choice=int(input("Login attempt failed! Enter the choice to continue with login, press 1 to continue."))
    else:
        print("terminating the execution!")
        
    print("""Enter the choices with account operation:
            1.Add Payee
            2.Delete Payee
            3.Add Money
            4.Transfer Money
            5.Logout""")
    
    operation=int(input("Enter the choice"))
    
    if(operation==1):
        payee_account_number=int(input("Enter the account number of the payee"))
        payee_account_name=input("Enter the account name")
        payee_bank=input("Enter the bank name of payee")
        payee=Payee(payee_account_number,payee_account_name,payee_bank)
        customer=payeeService.add_payee(customer, payee)
        print(customer)
    elif operation==2:
        payee_account_number=int(input("Enter the account number of the payee to delete"))
        customer=payeeService.delete_payee(customer,payee_account_number)
        print(customer)
    elif operation==3:
        deposit_amount=int(input("Enter the amount to be deposited"))
        customer=transactionService.deposit_amount(deposit_amount, customer)
    elif operation==4:
        transfer_amount=int(input("Enter the amount to be transfered"))
        payee_account_number=int(input("Enter the payee account number to be transfered the amount"))
        customer=transactionService.transfer_amount(transfer_amount, customer,payee_account_number)
    elif operation==5:
Ejemplo n.º 6
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()
Ejemplo n.º 7
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()
Ejemplo n.º 8
0
from Repository.GenericFileRepository import GenericFileRepository
from Service.DrugService import DrugService
from Service.CardService import CardService
from Service.TransactionService import TransactionService
from UI.Console import Console

drug_repository = GenericFileRepository("drugs.pkl")
card_repository = GenericFileRepository("cards.pkl")
transaction_repository = GenericFileRepository("transactions.pkl")
drug_service = DrugService(drug_repository, transaction_repository)
card_service = CardService(card_repository, transaction_repository)
transaction_service = TransactionService(transaction_repository, drug_repository)
console = Console(drug_service, card_service, transaction_service)
console.run_console()
Ejemplo n.º 9
0
from Repository.RepositoryCar import RepositoryCar
from Repository.RepositoryCard import RepositoryCard
from Repository.RepositoryTransaction import RepositoryTransaction
from Service.CarService import CarService
from Service.CardService import CardService
from Service.TransactionService import TransactionService
from UI.Console import Console
if __name__ == '__main__':
    repoCar = RepositoryCar("masini.txt")
    repoCard = RepositoryCard("carduri.txt")
    repoTran = RepositoryTransaction("tranzactii.txt")
    serviceCar = CarService(repoCar, repoTran)
    serviceCard = CardService(repoCard)
    serviceTransaction = TransactionService(repoTran, serviceCar)
    console = Console(serviceCar, serviceCard, serviceTransaction)
    console.run_console()