def check_existing_accounts(user_name): ''' Function that check if an account exists with that number and return a Boolean ''' return User.account_exist(user_name)
def create_login(fname, lname, password): """ function to create a new User """ new_user = User(fname, lname, password) return new_user
class TestUser(unittest.TestCase): ''' Test class that defines test cases for the User class behaviours. Args: unittest.TestCase: TestCase class that helps in creating test cases ''' def setUp(self): ''' Set up method to run before each test cases. ''' self.new_user = User("Kinyanjui", "Lucy", "account", "*****@*****.**") self.new_credential = Credential("Wambui", "account", "*****@*****.**") def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_user.first_name, "Kinyanjui") self.assertEqual(self.new_user.last_name, "Lucy") self.assertEqual(self.new_user.email, "*****@*****.**") def test_save_user(self): ''' test_save_user test case to test if the user object is saved into the user list ''' self.new_user.save_user() # saving the new user self.assertEqual(len(User.user_list), 1) def test_save_credential(self): ''' test case to test if the credential object is saved into the credential list ''' self.new_credential.save_credential() self.assertEqual(len(Credential.credential_list), 1) def test_save_multiple_user(self): ''' test_save_multiple_user to check if we can save multiple user objects to our user_list ''' self.new_user.save_user() test_user = User("Test", "user", "account", "*****@*****.**") # new user test_user.save_user() self.assertEqual(len(User.user_list), 2) def test_save_multiple_credential(self): ''' test_save_multiple_credential to check if we can save multiple credential objects to our credential_list ''' self.new_credential.save_credential() test_credential = Credential("Test", "account", "*****@*****.**") # new credential test_credential.save_credential() self.assertEqual(len(Credential.credential_list), 2) def tearDown(self): ''' tearDown method that does clean up after each test case has run. ''' User.user_list = [] def test_delete_user(self): ''' test_delete_user to test if we can remove a user from our user list ''' self.new_user.save_user() test_user = User("Test", "user", "account", "*****@*****.**") # new user test_user.save_user() self.new_user.delete_user() # Deleting a user object self.assertEqual(len(User.user_list), 1) def test_delete_credential(self): ''' test_delete_credential to test if we can remove a credential from our credential list ''' self.new_credential.save_credential() test_credential = Credential("Test", "account", "*****@*****.**") # new user test_credential.save_credential() self.new_credential.delete_credential() # Deleting a credential object self.assertEqual(len(Credential.credential_list), 1) def test_find_user_by_name(self): ''' test to check if we can find a user by user name and display information ''' self.new_user.save_user() test_user = User("Test", "user", "account", "*****@*****.**") # new name found_user = User.find_by_name("Kinyanjui") self.assertEqual(found_user.email, test_user.email) def test_user_exists(self): ''' test to check if we can return a Boolean if we cannot find the user. ''' self.new_user.save_user() test_user = User("Test", "user", "account", "*****@*****.**") # new user test_user.save_user() user_exists = User.name_exist("Lucy") self.assertTrue(user_exists) def test_credential_exists(self): ''' test to check if we can return a Boolean if we cannot find the password. ''' self.new_credential.save_credential() test_credential = Credential("Test", "account", "*****@*****.**") # new credential test_credential.save_credential() credential_exists = Credential.password_exist("password") self.assertTrue(credential_exists) def test_copy_email(self): ''' Test to confirm that we are copying the email address from a found name ''' self.new_user.save_user() User.copy_email("") self.assertEqual(self.new_user.email, pyperclip.paste()) def test_display_all_credential(self): """ returns a list of all password saved. """ self.assertEqual(Credential.display_credential(), Credential.credential_list)
def test_display_credentials(self): self.assertEqual(User.display_credentials(), User.User_list)
def verify(self): """ This function verifies togin to enable users to access their vault """ self.test_user = User('Janice', 'somepassword0123')
def test_find_credentials_by_account(self): self.new_credentials.save_details() test_credentials = User("joz", "whatsapp", "1234567@") test_credentials.save_details() found_account = User.find_by_account("whatsapp") self.assertEqual(found_account.passwords, test_credentials.passwords)
def test_credentials_exists(self): self.new_credentials.save_details() test_credentials = User("me", "linkedIn", "12@12") test_credentials.save_details() credentials_exists = User.credentials_exists("linkedIn") self.assertTrue(credentials_exists)
def test_display_all_users(self): ''' method that returns a list of all users saved ''' self.assertEqual(User.display_users(), User.user_list)
def setUp(self): ''' Set up method to run before each test cases. ''' self.new_user = User("Twitter", "James", "Muriuki", "OG", "0712345678", "*****@*****.**", "123") # create object object
def create_login(firstname, lastname, password): """ Function to create a new login """ new_user = User(firstname, lastname, password) return new_user
def setUp(self): ''' test setup method ''' self.new_user = User("Peter", "Welcome123")
def del_account(): ''' Function that delete the saved account ''' return User.delete_account()
def create_account(user_name,email,password): ''' Function to create a new account ''' new_account = User(user_name,email,password) return new_account
def display_accounts(): ''' Function that returns all the saved account ''' return User.display_accounts()
def test_multiple_saves(self): self.new_credentials.save_details() test_credential = User("kent", "twitter", "1234ae") test_credential.save_details() self.assertEqual(len(User.User_list), 2)
class TestContact(unittest.TestCase): ''' Test class that defines test cases for the user class behaviours. Args: unittest.TestCase: TestCase class that helps in creating test cases ''' def setUp(self): ''' Set up method to run before each test cases. ''' self.new_user = User("Twitter", "James", "Muriuki", "OG", "0712345678", "*****@*****.**", "123") # create object object #init test def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_user.first_name, "James") self.assertEqual(self.new_user.last_name, "Muriuki") self.assertEqual(self.new_user.username, "OG") self.assertEqual(self.new_user.phone_number, "0712345678") self.assertEqual(self.new_user.email, "*****@*****.**") self.assertEqual(self.new_user.password, "123") #saving contact def test_save_user(self): ''' test case to test if the user object is saved into the user list ''' self.new_user.save_user() # saving the new user self.assertEqual(len(User.user_list), 1) #adding 1 contact def tearDown(self): ''' method that does clean up after each test case has run. ''' User.user_list = [] #creating empty list #adding multiple contacts def test_save_multiple_user(self): ''' to check if we can save multiple user objects to our contact_list ''' self.new_user.save_user() test_user = User("account", "Test", "user", "username", "0712345678", "*****@*****.**", "password") # new contact test_user.save_user() self.assertEqual(len(User.user_list), 2) # delete def test_delete_user(self): ''' to test if we can remove a user from our user list ''' self.new_user.save_user() test_user = User("account", "Test", "user", "username", "0712345678", "*****@*****.**", "password") test_user.save_user() self.new_user.delete_user() # Deleting a contact object self.assertEqual(len(User.user_list), 1) #find by username def test_find_user_by_username(self): ''' test to check if we can find a user by their username and display information ''' self.new_user.save_user() test_user = User("account", "Test", "user", "username", "0711223344", "*****@*****.**", "password") # new contact test_user.save_user() found_user = User.find_by_username("username") self.assertEqual(found_user.password, test_user.password) #check if contact exists def test_user_exists(self): ''' test to check if we can return a Boolean if we cannot find the user. ''' self.new_user.save_user() test_user = User("account", "Test", "user", "username", "0711223344", "*****@*****.**", "password") test_user.save_user() user_exists = User.user_exist("username") self.assertTrue(user_exists) #display all contacts def test_display_all_users(self): ''' method that returns a list of all users saved ''' self.assertEqual(User.display_users(), User.user_list)
def test_delete_credentials(self): self.new_credentials.save_details() test_credential = User("ken", "intagram", "iii111") test_credential.save_details() self.new_credentials.delete_credential() self.assertEqual(len(User.User_list), 1)
def find_account(fname): ''' function to search account. ''' return User.find_by_name(fname)
class TestUser(unittest.TestCase): def setUp(self): self.new_credentials = User("Rovet", "facebook", "wwww45") self.new_account = Account("clent", "iurt45") def tearDown(self): User.User_list = [] Account.account_list = [] def test_init(self): """ test init help test if the object is initialized properly """ self.assertEqual(self.new_credentials.username, "rovel") self.assertEqual(self.new_credentials.account, "facebook") self.assertEqual(self.new_credentials.passwords, "wwww45") self.assertEqual(self.new_account.name, "clent") self.assertEqual(self.new_account.passright, "iurt45") def test_save_details(self): self.new_credentials.save_details() self.assertEqual(len(User.User_list), 1) def test_save_account(self): self.new_account.save_account() self.assertEqual(len(Account.account_list), 1) def test_multiple_saves(self): self.new_credentials.save_details() test_credential = User("kent", "twitter", "1234ae") test_credential.save_details() self.assertEqual(len(User.User_list), 2) def test_multiple_saves(self): self.new_account.save_account() test_account = Account("Dan", "12jt3er") test_account.save_account() self.assertEqual(len(Account.account_list), 2) def test_delete_credentials(self): self.new_credentials.save_details() test_credential = User("ken", "intagram", "iii111") test_credential.save_details() self.new_credentials.delete_credential() self.assertEqual(len(User.User_list), 1) def test_delete_account(self): self.new_account.save_account() test_account = Account("joice", "@12rews") test_account.save_account() self.new_account.delete_account() self.assertEqual(len(Account.account_list), 1) def test_find_credentials_by_account(self): self.new_credentials.save_details() test_credentials = User("joz", "whatsapp", "1234567@") test_credentials.save_details() found_account = User.find_by_account("whatsapp") self.assertEqual(found_account.passwords, test_credentials.passwords) def test_credentials_exists(self): self.new_credentials.save_details() test_credentials = User("me", "linkedIn", "12@12") test_credentials.save_details() credentials_exists = User.credentials_exists("linkedIn") self.assertTrue(credentials_exists) def test_display_credentials(self): self.assertEqual(User.display_credentials(), User.User_list) def test_copy_passwords(self): """ this method tests coping the password to clip board """ self.new_credentials.save_details() User.copy_passwords("facebook") self.assertEqual(self.new_credentials.passwords, pyperclip.paste())
def display_accounts(): ''' function to display all user accounts. ''' return User.display_users()
def setUp(self): self.new_credentials = User("Rovet", "facebook", "wwww45") self.new_account = Account("clent", "iurt45")
def create_account(fname, lname, password, mail): ''' Function to create a new user ''' new_account = User(fname, lname, password, mail) return new_account
def setUp(self): ''' Function to create a user account before each test ''' self.test_user = User('Janice', 'somepassword0123')
def account_verification(first_name, last_name, password): ''' function to verify an account login. ''' return User.confirm_user(first_name, last_name, password)
def setUp(self): """ method to run before each test """ self.new_user = User("George", "ptex")
def new_user(username, passwords): """ creates a new user """ new_user = User(username, passwords) return new_user
def setUp(self): """ Method that runs before each individual test methods run. """ self.new_user = User('DavidHashisoma','XyZ3thf1')
def setUp(self): """ method to run before each test """ self.new_user = User("Chelsea", "12345")
def check_existing_users(username): ''' Function that check if a user exists with that usename and return a Boolean ''' return User.user_exist(username)
def find_user_name(user_name): ''' Function that finds an account by number and returns the account ''' return User.find_by_user_name(user_name)