def test_deposit_withdraw(self):
     logged_user = sql_manager.login('Tester', '123Ab#78')
     sql_manager.deposit(10000,
                         sql_manager.get_tan(logged_user)[0], logged_user)
     self.assertEqual(sql_manager.display_balance(logged_user), 10000.00)
     sql_manager.withdraw(1000,
                          sql_manager.get_tan(logged_user)[1], logged_user)
     self.assertEqual(sql_manager.display_balance(logged_user), 9000.00)
Beispiel #2
0
def logged_menu(logged_user):
    print("Welcome you are logged in as: " + logged_user.get_username())
    while True:
        command = input("Logged>>")

        if command == 'info':
            print("You are: " + logged_user.get_username())
            print("Your id is: " + str(logged_user.get_id()))
            print("Your balance is:" + str(logged_user.get_balance()) + '$')

        elif command == 'changepass':
            new_pass = getpass.getpass(prompt='Password: '******'deposit':
            amount = input("Enter amount: ")
            tan_code = input("Enter your TAN code: ")
            if sql_manager.use_tan(logged_user, tan_code):
                if logged_user.deposit(float(amount)):
                    new_balance = logged_user.get_balance()
                    sql_manager.deposit(logged_user, new_balance)
                    print("Deposited %s$ succesfully." % amount)

        elif command == 'withdraw':
            amount = input("Enter amount: ")
            tan_code = input("Enter your TAN code: ")
            if sql_manager.use_tan(logged_user, tan_code):
                if logged_user.withdraw(float(amount)):
                    new_balance = logged_user.get_balance()
                    sql_manager.withdraw(logged_user, new_balance)
                    print("Withdrew %s$ succesfully." % amount)

        elif command == 'get-tan':
            password = getpass.getpass(prompt='Enter your password again please: ')
            if sql_manager.validate_password(logged_user, password):
                sql_manager.get_tan(logged_user)
            else:
                print("Invalid password.")

        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == 'logout':
            print("Goodbye %s!" % logged_user.get_username())
            break

        elif command == 'help':
            print("info - for showing account info")
            print("changepass - for changing passowrd")
            print("change-message - for changing users message")
            print("show-message - for showing users message")
Beispiel #3
0
def logged_menu(logged_user):
    print("Welcome you are logged in as: " + logged_user.get_username())
    while True:
        command = input("Logged>>")

        if command == 'info':
            print("You are: " + logged_user.get_username())
            print("Your id is: " + str(logged_user.get_id()))
            print("Your balance is:" + str(logged_user.get_balance()) + '$')

        elif command == 'changepass':
            new_pass = getpass.getpass("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == 'deposit':
            amount = input("Enter the amount of money you want to deposit: ")
            tan = input("Enter TAN code: ")
            sql_manager.deposit(amount, tan, logged_user)

        elif command == 'withdraw':
            amount = input("Enter the amount of money you want to withdraw: ")
            tan = input("Enter TAN code: ")
            sql_manager.withdraw(amount, tan, logged_user)

        elif command == 'display-balance':
            print(sql_manager.display_balance(logged_user))

        elif command == 'get-tan':
            sql_manager.get_tan(logged_user)

        elif command == 'help':
            print("info - for showing account info")
            print("changepass - for changing passowrd")
            print("change-message - for changing users message")
            print("show-message - for showing users message")
            print("deposit - to deposit into your account")
            print("withdraw - to withdraw from your account")
            print("display-balance - to display your current balance")
            print("get-tan - to send TAN codes to your email, you need " \
                  "them to make a deposit or to withdraw!")
            print("logout - to return to the main menu")

        elif command == 'logout':
            break
def logged_menu(logged_user):
    print("Welcome you are logged in as: " + logged_user.get_username())
    while True:
        command = input("Logged>>")

        if command == "info":
            print("You are: " + logged_user.get_username())
            print("Your id is: " + str(logged_user.get_id()))
            print("Your balance is:" + str(logged_user.get_balance()) + "$")

        elif command == "changepass":
            new_pass = getpass.getpass("Enter your new password: "******"change-message":
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == "show-message":
            print(logged_user.get_message())

        elif command == "deposit":
            amount = input("Enter the amount of money you want to deposit: ")
            tan = input("Enter TAN code: ")
            sql_manager.deposit(amount, tan, logged_user)

        elif command == "withdraw":
            amount = input("Enter the amount of money you want to withdraw: ")
            tan = input("Enter TAN code: ")
            sql_manager.withdraw(amount, tan, logged_user)

        elif command == "display-balance":
            print(sql_manager.display_balance(logged_user))

        elif command == "get-tan":
            sql_manager.get_tan(logged_user)

        elif command == "help":
            print("info - for showing account info")
            print("changepass - for changing passowrd")
            print("change-message - for changing users message")
            print("show-message - for showing users message")
            print("deposit - to deposit into your account")
            print("withdraw - to withdraw from your account")
            print("display-balance - to display your current balance")
            print("get-tan - to send TAN codes to your email, you need " "them to make a deposit or to withdraw!")
            print("logout - to return to the main menu")

        elif command == "logout":
            break
 def test_get_tan(self):
     logged_user = sql_manager.login('Tester', '123Ab#78')
     self.assertEqual(10, len(sql_manager.get_tan(logged_user)))
 def test_deposit_withdraw(self):
     logged_user = sql_manager.login('Tester', '123Ab#78')
     sql_manager.deposit(10000, sql_manager.get_tan(logged_user)[0], logged_user)
     self.assertEqual(sql_manager.display_balance(logged_user), 10000.00)
     sql_manager.withdraw(1000, sql_manager.get_tan(logged_user)[1], logged_user)
     self.assertEqual(sql_manager.display_balance(logged_user), 9000.00)
 def test_get_tan(self):
     logged_user = sql_manager.login('Tester', '123Ab#78')
     self.assertEqual(10, len(sql_manager.get_tan(logged_user)))