def test_user_login(self): ''' Function to test whether the login in function login_user works as expected ''' self.new_user = User("Alex", "mwaura", "12345") self.new_user.save_user() user_login = User("test", "user", "1122") user_login.save_user() for user in User.users_list: if user.first_name == user_login.first_name and user.password == user_login.password: current_user = user.first_name return current_user
def test_check_user(self): ''' Function to confirm the login info ''' self.new_user = User('Mary', 'Mbaru', 'Mark17') self.new_user.save_user() user2 = User('Maria', 'Mwema', 'Maria17') user2.save_user() for user in User.user_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user
def test_check_user(self): """ Function to test whether the login in function check_user works as expected """ self.new_user = User('Humphrey', 'Mutuma', '1234') self.new_user.save_user() user2 = User('Alex', 'Mutuma', '1234') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user
def test_check_user(self): self.new_user = User('Dancan', 'Od\'uo\'r', '28750187') self.new_user.save_user() user2 = User('Ben', 'Od\'uo\'r', '28750187') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name)) return current_user
def confirm_user(self): """ function to confirm """ self.newuser = User("Christine", "Ombima", "tyna452") self.newuser.save_user() user2 = User("alex", "nad", "nad452") user2.save_user() for user in User.users: if user.firstname == user2.firstname and user.password == user2.password: current_user = user.firstname return current_user
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User('Bernice','Twili','1234') self.new_user.save_user() user2 = User('Kaylin','Ella','5678') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual(current_user,Credential.check_user(user2.password,user2.first_name))
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User("Eve","evelyne","pswd100") self.new_user.save_user() user2 = User("Aggy","agnes","pswd200") user2.save_user() for user in User.user_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual(current_user,Credential.check_user(user2.password,user2.first_name))
def test_confirm_login(self): ''' Method to test login functionality. ''' self.new_user = User('Js', '123abc') self.new_user.save_user() user2 = User('Test', '123abc') user2.save_user() for user in User.user_list: if user.username == user2.username and user.password == user2.password: current_user = user.username return current_user self.assertEqual( current_user, Credentials.confirm_login(user2.password, user2.username))
def test_check_user(self): ''' Test to check if users login works as it is suppossed to ''' self.new_user = User('Tabby','Wanjiku' ,'twpd254') self.new_user.save_user() user2 = User('Nicky' ,'Wanjiku', 'twpd254') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user2.first_name return current_user self.assertEqual(current_user ,Credential.check_user(user2.password ,user2.first_name))
def test_check_user(self): ''' Function to test whether the login function check_user works as expected ''' self.new_user = User('Charlotte', 'Chelang\'at', 'pswd007') self.new_user.save_user() user2 = User('Benard', 'Chelang\'at', 'pswd007') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name))
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User('peter', 'Ng\'ang\'a', 'pswd100') self.new_user.save_user() user2 = User('Ken', 'Ng\'ang\'a', 'pswd100') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name))
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User('Miriam','pswd4363') self.new_user.save_user() user2 = User('philip','pswd4363') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual(current_user,Credential.check_user(user2.password,user2.first_name)) Credential.credentials_list.append(self)
def test_check_credentials(self): ''' test_check_credentials to test whether user_check method executes as intended ''' self.new_user = User("Gideon", "Chef", "Been2000") self.new_user.save_user() addUser = User("Peter", "Chamgei", "Double10") addUser.save_user() for user in User.user_list: if user.fname == addUser.fname and user.password == addUser.password: current_user = user.fname return current_user self.assertEqual( current_user, Credentials.user_check(addUser.password, addUser.fname))
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User('Ibrahim', 'Hassib', 'McGee') self.new_user.save_user() user2 = User('Loso', 'Wii', 'psd001') user2.save_user() for user in User.user_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name))
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User('Stephen', 'Ndele', 'ndele') self.new_user.save_user() user2 = User('mark', 'luke', 'john') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name))
class TestCredentials(unittest.TestCase): ''' Test class that defines test cases for the credentials class behaviours. Args: unittest.TestCase: helps in creating test cases ''' def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User('peter', 'Ng\'ang\'a', 'pswd100') self.new_user.save_user() user2 = User('Ken', 'Ng\'ang\'a', 'pswd100') user2.save_user() for user in User.users_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name)) def setUp(self): ''' Function to create an account's credentials before each test ''' self.new_credential = Credential('peter', 'Facebook', 'joe', 'pswd100') def test__init__(self): ''' Test to if check the initialization/creation of credential instances is properly done ''' self.assertEqual(self.new_credential.user_name, 'peter') self.assertEqual(self.new_credential.site_name, 'Facebook') self.assertEqual(self.new_credential.account_name, 'joe') self.assertEqual(self.new_credential.password, 'pswd100') def test_save_credentials(self): ''' Test to check if the new credential info is saved into the credentials list ''' self.new_credential.save_credentials() twitter = Credential('Jane', 'Twitter', 'joe', 'pswd100') twitter.save_credentials() self.assertEqual(len(Credential.credentials_list), 2) def tearDown(self): ''' Function to clear the credentials list after every test ''' Credential.credentials_list = [] User.users_list = [] def test_display_credentials(self): ''' Test to check if the display_credentials method, displays the correct credentials. ''' self.new_credential.save_credentials() twitter = Credential('Jane', 'Twitter', 'joe', 'pswd100') twitter.save_credentials() gmail = Credential('Jane', 'Gmail', 'joe', 'pswd200') gmail.save_credentials() self.assertEqual( len(Credential.display_credentials(twitter.user_name)), 2) def test_find_by_site_name(self): ''' Test to check if the find_by_site_name method returns the correct credential ''' self.new_credential.save_credentials() twitter = Credential('Jane', 'Twitter', 'joe', 'pswd100') twitter.save_credentials() credential_exists = Credential.find_by_site_name('Twitter') self.assertEqual(credential_exists, twitter) def test_copy_credential(self): ''' Test to check if the copy a credential method copies the correct credential ''' self.new_credential.save_credentials() twitter = Credential('Jane', 'Twitter', 'joe', 'pswd100') twitter.save_credentials() find_credential = None for credential in Credential.user_credentials_list: find_credential = Credential.find_by_site_name( credential.site_name) return pyperclip.copy(find_credential.password) Credential.copy_credential(self.new_credential.site_name) self.assertEqual('pswd100', pyperclip.paste()) print(pyperclip.paste())
def setUp(self): ''' Function to create a user account before each test ''' self.new_user = User('peter', 'Ng\'ang\'a', 'pswd100')
def setUp(self): ''' Function to create a user account before each test ''' self.new_user = User('Miriam','pswd4363')
def display_user(): return User.display_user()
def create_user(fname, lname, password): ''' Function that creates a new user account. ''' new_user = User(fname, lname, password) return new_user
def verify_user(first_name, password): ''' Function that verifies if user exists. ''' checking_user = User.check_user(first_name, password) return checking_user
def test_display_user(self): ''' displays all user ''' self.assertEqual(User.display_user(), User.user_list)
def setUp(self): ''' method that runs before each Test ''' self.new_user = User("Michael", "Mbogo", "Michaelmm17") #create users
def save_user(user): ''' Function to save a new user account ''' User.save_user(user)
def create_user(fname, lname, password): ''' Function to create new user account ''' new_user = User(fname, lname, password) return new_user
def setUp(self): ''' Function to create a user account before each test ''' self.new_user = User('silver', 'staar', 'pswd100')
class TestUser(unittest.TestCase): ''' Test class defining test cases for the users class behavior ''' def setUp(self): ''' method that runs before each Test ''' self.new_user = User("Michael", "Mbogo", "Michaelmm17") #create users def test_init(self): ''' Test case to check proper initialization ''' self.assertEqual(self.new_user.first_name, "Michael") self.assertEqual(self.new_user.last_name, "Mbogo") self.assertEqual(self.new_user.password, "Michaelmm17") def test_save_user(self): ''' tests if the user is saved in the user list ''' self.new_user.save_user() #saves new users self.assertEqual(len(User.user_list), 1) def tearDown(self): ''' cleans up after each TestCase is made ''' User.user_list = [] def test_save_multiple_user(self): ''' check to see if multiple users can be saved ''' self.new_user.save_user() test_user = User("Ann", "Bridgit", "brig13") test_user.save_user() self.assertEqual(len(User.user_list), 2) def test_delete_user(self): ''' Deletes the user from the user_list ''' self.new_user.save_user() test_user = User("Ann", "Bridgit", "brig13") test_user.save_user() self.new_user.delete_user() self.assertEqual(len(User.user_list), 1) def test_display_user(self): ''' displays all user ''' self.assertEqual(User.display_user(), User.user_list)
if (rs == "y"): print( "you can choose the size of the password you want by entering the number of characters \n" ) rrs = input("do you what to choose characters? Y/N: ").lower() if (rrs == "y"): size = int( input("Enter the size you want your password to have: ")) pwd = generate_password(size) else: pwd = generate_password() print("your password is: ") print(pwd) else: pwd = input("password: \n") nuser = User(uname, pwd) print("\n") logIn = input("Enter your Password to logIn into the System: \n") if (logIn == nuser.user_holder[1]): print( f"Welcome {nuser.user_holder[0]} you are in what do you want to do(use short code)?" ) while True: print( "Use these short codes : cc - create new credential account, dc - display credentials, fc - find credential, del - to delete credential ex -exit the user list " ) short_code = input().lower()
class TestCredential(unittest.TestCase): ''' Test case defining cases for credentials class behavior ''' def test_check_user(self): ''' Function to confirm the login info ''' self.new_user = User('Esther', 'Mumbi', 'essy17') self.new_user.save_user() user2 = User('Maria', 'Mwema', 'Maria17') user2.save_user() for user in User.user_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user def setUp(self): ''' function to create an account before each test ''' self.new_credential = Credential('Mikey', 'Michael-mbogo', 'Facebook', 'Michaelmm17') def test__init__(self): ''' Method testing proper initialization ''' self.assertEqual(self.new_credential.user_name, "Mikey") self.assertEqual(self.new_credential.account_name, "Michael-mbogo") self.assertEqual(self.new_credential.site, "Facebook") self.assertEqual(self.new_credential.site_password, "Michaelmm17") def test_save_credential(self): ''' saves credentials ''' self.new_credential.save_credential() google = Credential('AnnB', 'Annbrig', 'twitter', 'Michaelmm17') google.save_credential() self.assertEqual(len(Credential.credential_list), 2) def tearDown(self): ''' Clears the list after each test ''' Credential.credential_list = [] User.user_list = [] def test_save_multiple_credentials(self): ''' Test to check whether multiple functions can be saved ''' self.new_credential.save_credential() test_credential = Credential('Kevin', 'Kevin Mwan', 'Facebook', 'Kevkev') test_credential.save_credential() self.assertEqual(len(Credential.credential_list), 2) def test_display_credentials(self): ''' Displays the credentials ''' self.assertEqual(Credential.display_credentials(), Credential.credential_list) def test_find_by_user_name(self): ''' Function that helps search for a credential by user name ''' self.new_credential.save_credential() test_credential = Credential('Kevin', 'Kevin Mwan', 'Facebook', 'Kevkev') test_credential.save_credential() found_credential = Credential.find_by_user_name('Kevin') self.assertEqual(found_credential, test_credential)
def save_user(user): ''' Function that saves a new user. ''' User.save_user(user)