From 7120734602c25abceb43786ef376427d25f510b0 Mon Sep 17 00:00:00 2001 From: Hamzah133 Date: Wed, 18 Dec 2024 20:07:46 +0200 Subject: [PATCH] test 6-8 --- banking_app/login.py | 7 ++++ banking_app/signup.py | 45 +++++++++++++++++++++ banking_app/transaction.py | 21 ++++++++++ functions_to_test.py | 81 +++++++++++++++++++++++++++++++++----- 4 files changed, 144 insertions(+), 10 deletions(-) diff --git a/banking_app/login.py b/banking_app/login.py index 2bbab36..e0efa4f 100644 --- a/banking_app/login.py +++ b/banking_app/login.py @@ -1,6 +1,13 @@ # login.py - Placeholder for login functionality def login(username, password): + + if username=='' or password=='': + raise ValueError + elif not username.isalnum() or not password.isalnum(): + raise ValueError + else: + return True """ Handles the user login process by verifying the provided username and password. diff --git a/banking_app/signup.py b/banking_app/signup.py index a920e5b..35edcc1 100644 --- a/banking_app/signup.py +++ b/banking_app/signup.py @@ -1,6 +1,51 @@ # signup.py - Placeholder for signup functionality +import string +def is_password_secure(password): + + uppercase=0 + lowercase=0 + digit=0 + special=0 + + if len(password)<8: + return False + + for i in password: + if i.isupper(): + uppercase += 1 + if uppercase==0: + return False + + for i in password: + if i.islower(): + lowercase += 1 + if lowercase==0: + return False + + for i in password: + if i.isdigit(): + digit+=1 + if digit==0: + return False + + # for i in password: + # if i in string.punctuation: + # special+=1 + # if special==0: + # return False + return True + + + + def signup(username, password, email): + if username=='' or password=='' or email=='': + raise ValueError + if is_password_secure(password)==False: + raise ValueError + else: + return True """ Handles the user signup process by validating the provided username, password, and email. diff --git a/banking_app/transaction.py b/banking_app/transaction.py index a444e25..e07b349 100644 --- a/banking_app/transaction.py +++ b/banking_app/transaction.py @@ -1,6 +1,27 @@ # transaction.py - Placeholder for transaction functionality def transact(sender_account, receiver_account, amount): + if sender_account==receiver_account: + raise ValueError + if amount<=0: + raise ValueError + + with open("database.csv",'r') as f: + the=f.read().splitlines() + for i in the: + i.split(',') + if sender_account not in the or receiver_account not in the: + raise ValueError + # else: + + # for i in the: + # if sender_account in i: + # if int(i[-1])0: + return False + else: + return True def sort_numbers(numbers): - pass + if len(numbers)>0: + for i in numbers: + if isinstance(i,str): + raise TypeError + else: + return sorted(numbers) + else: + return numbers def factorial(n): pass def fibonacci(n): - pass + if n==0 or n==1: + return n + else: + count=[0,1] + for i in range(n): + num=count[-1]+count[-2] + count.append(num) + return count def tower_of_hanoi(n, source, auxiliary, target): @@ -52,7 +109,11 @@ def tower_of_hanoi(n, source, auxiliary, target): class Person: def __init__(self, name, age): - pass + if isinstance(name,str) and isinstance(age,int): + self.name=name + self.age=age + else: + raise TypeError if __name__ == "__main__":