class TestUser(unittest.TestCase): def setUp(self): self.new_user = User( "Celine", "Mmbone", "0723456789", "*****@*****.**") # Create password object def test_init(self): self.assertEqual(self.new_user.first_name, "Celine") self.assertEqual(self.new_user.last_name, "Mmbone") self.assertEqual(self.new_user.phone_number, "0723456789") 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) # setup and class creation up here def tearDown(self): ''' tearDown method that does clean up after each test case has run. ''' Credentials.user_list = [] def test_delete_user(self): '''
def create_user(fname, lname, password): ''' Function to create a new user account ''' new_user = User(fname, lname, password) new_user.save_user() 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 case. ''' self.new_user = User("Audrey", "Njiraini", "audreynjiraini", "12345678") # create contact object def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_user.first_name, "Audrey") self.assertEqual(self.new_user.last_name, "Njiraini") self.assertEqual(self.new_user.username, "audreynjiraini") self.assertEqual(self.new_user.password, "12345678") 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() # save the new contact self.assertEqual(len(User.user_list), 1)
class TestUser(unittest.TestCase): ''' Test class that defines test cases for the user class behaviors. Args: unittest.TestCase: helps in creating test case ''' def setUp(self): ''' Function to create a user account before each test ''' self.new_user = User('Christian','Jire','21','Pwd123456') def test__init__(self): ''' Test to if check the creation of user instances works ''' self.assertEqual(self.new_user.first_name,'Christian') self.assertEqual(self.new_user.last_name,'Jire') self.assertEqual(self.new_user.age,'21') self.assertEqual(self.new_user.password,'Pwd123456') def test_save_user(self): ''' Test to check if the new users info is saved into the users list ''' self.new_user.save_user() self.assertEqual(len(User.users_list),1)
def setUp(self): ''' Set up method to run before each test case. ''' self.new_user = User("Audrey", "Njiraini", "audreynjiraini", "12345678") # create contact object
class TestUser(unittest.TestCase): ''' Test class that defines test cases for the user class behaviours. Args: unittest.TestCase: helps in creating test cases ''' def setUp(self): ''' Function to create a user account before each test ''' self.new_user = User('David', 'Mumo', 'Msyoka!') def test__init__(self): ''' Test to if check the initialization/creation of user instances is properly done ''' self.assertEqual(self.new_user.first_name, 'David') self.assertEqual(self.new_user.last_name, 'Mumo') self.assertEqual(self.new_user.password, 'Msyoka!') def test_save_user(self): ''' Test to check if the new users info is saved into the users list ''' self.new_user.save_user() self.assertEqual(len(User.users_list), 1)
def test_delete_userDetails(self): ''' A function to test if we are able to delete user details. ''' self.new_user.save_userDetails() test_user = User("test", "user", "0780404626", "*****@*****.**", "Pwamaria", "leejones1") test_user.save_userDetails() self.new_user.delete_userDetails() self.assertEqual(len(User.users_list), 1)
def test_check_if_userExist(self): ''' A test function to ensure the working of the check if userExist function. ''' self.new_user = User("test", "user", "0780404626", "*****@*****.**", "Pwamaria", "leejones1") self.new_user.save_userDetails() user2 = User("test", "user", "0780404626", "*****@*****.**", "Pwamaria", "leejones1") for user in User.users_list: if user.username == user2.username and user.password == user2.password: current_user = user.first_name return current_user
def create_user(f_name, l_name, p_number, e_address, u_name, p_word): ''' A funtcion to create a new user. ''' new_user = User(f_name, l_name, p_number, e_address, u_name, p_word) return new_user
def create_user(first_name, last_name, username, password): ''' Function that creates a new password-Locker user account ''' new_user = User(first_name, last_name, username, password) return new_user
def __init__(self,**kwargs): """ Constructor function of Product class. Delay is set to random to avoid detection by amazon which could result in temporarily block. """ self.amazon_credential = User() self.email_credential = Email() self.product = kwargs['p_url']
class TestUser(unittest.TestCase): def setUp(self): self.new_user =User ("Yvette","Adana","0786574531","*****@*****.**") #Create password object def test_init(self): self.assertEqual(self.new_user.first_name,"Yvette") self.assertEqual(self.new_user.last_name,"Adana") self.assertEqual(self.new_user.phone_number,"0786574531") 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) # setup and class creation up here 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 =("Yvette","Adana","0786574531","*****@*****.**") # user
class TestUser(unittest.TestCase): def setUp(self): self.new_user = User("Celine", "mmbone", "0719476296", "*****@*****.**") def test_init(self): self.assertEqual(self.new_user.first_name, "Celine") self.assertEqual(self.new_user.last_name, "mmbone") self.assertEqual(self.new_user.phone_number, "0719476297") self.assertEqual(self.new_user.email, "*****@*****.**") def test_save_user(self): self.new_user.save_user() self.assertEqual(len(User.user_list), 1) def tearDown(self): Credentials.user_list = [] def test_delete_user(self):
class TestUser(unittest.TestCase): def setUp(self): self.new_user =User ("Jeffacy","Mwania","0722673853","*****@*****.**") def test_init(self): self.assertEqual(self.new_user.first_name,"Jeffacy") self.assertEqual(self.new_user.last_name,"Mwania") self.assertEqual(self.new_user.phone_number,"0722673853") 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 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 =("Jeffacy","Mwania","0722673853","*****@*****.**") # user
class TestClass(unittest.TestCase): """ A Test class that defines test cases for the User class. """ def setUp(self): """ Method that runs before each individual test methods run. """ self.new_user = User('OwitiCharles', 'XyZ3thf1') def test_init(self): """ test case to chek if the object has been initialized correctly """ self.assertEqual(self.new_user.username, 'OwitiCharles') self.assertEqual(self.new_user.password, 'XyZ3thf1') def test_save_user(self): """ test case to test if a new user instance has been saved into the User list """ self.new_user.save_user() self.assertEqual(len(User.user_list), 1)
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User('Christian','Jire','21','pwd123456') self.new_user.save_user() user2 = User('Chase','Lorde',22,'pw123456') 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('Jeanne', 'NYIRAMWIZA', 'amahoro1') self.new_user.save_user() user2 = User('Kennedy', 'MUVARA', 'ejo12345') 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('David', 'Mumo', 'Msyoka!') self.new_user.save_user() user2 = User('slime', 'Mumo', 'Msyoka!') 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): self.new_user = User( "Celine", "Mmbone", "0723456789", "*****@*****.**") # Create password object
def save_user(user): ''' Function to save a new user account ''' User.save_user(user)
def setUp(self): self.new_user =User ("Yvette","Adana","0786574531","*****@*****.**") #Create password object
def create_user(first_name, last_name, password): ''' Function to create a new user account ''' new_user = User(first_name, last_name, password) return new_user
class TestCredentials(unittest.TestCase): ''' Test class that defines test cases for the credentials class behaviors. 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('Christian','Jire','21','pwd123456') self.new_user.save_user() user2 = User('Chase','Lorde',22,'pw123456') 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('Christian','Facebook','chris','pwd123456') def test__init__(self): ''' Test to if check the initialization/creation of credential instances is properly done ''' self.assertEqual(self.new_credential.user_name,'Christian') self.assertEqual(self.new_credential.site_name,'Facebook') self.assertEqual(self.new_credential.account_name,'chris') self.assertEqual(self.new_credential.password,'pwd123456') 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('louis','Twitter','lou','14789') 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('Chris','Twitter','will','pwd123456') twitter.save_credentials() LinkedIn = Credential('chris','LinkedIn','will','pwd123456') LinkedIn.save_credentials() self.assertEqual(len(Credential.display_credentials(twitter.user_name)),1) #def test_delete_credentials(self): #''' #test_delete_contact to test if we can remove a contact from our contact list #''' #self.new_credential.save_credentials() #test_credential = Credential('Christian','Jire','21','pwd123456') #test_credential.save_credentials() #self.new_credential.delete_credentials() #self.assertEqual(len(Credential.delete_credentials),1) 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('Chris','Twitter','will','pwd123456') 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('Chris','Twitter','will','pwd123456') 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('pwd123456',pyperclip.paste()) print(pyperclip.paste())
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('David', 'Mumo', 'Msyoka!') self.new_user.save_user() user2 = User('slime', 'Mumo', 'Msyoka!') 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): '''assertEqual Function to create an account's credentials before each test ''' self.new_credential = Credential('David', 'Facebook', 'Mumo', 'Msyoka!') def test__init__(self): ''' Test to if check the initialization/creation of credential instances is properly done ''' self.assertEqual(self.new_credential.user_name, 'David') self.assertEqual(self.new_credential.site_name, 'Facebook') self.assertEqual(self.new_credential.account_name, 'Mumo') self.assertEqual(self.new_credential.password, 'Msyoka!') 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('buda', 'Twitter', 'Mumo', 'Msyoka!') twitter.save_credentials() self.assertEqual(len(Credential.credentials_list), 2) # def test_generate_password(self): # ''' # Test to check if the generate password generates 8 character long alphanumeric numbers # ''' # self.twitter = Credential('Twitter','Mumo','') # self.twitter.password = generate_password() # self.assertEqual() 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('buda', 'Twitter', 'Mumo', 'Msyoka!') twitter.save_credentials() gmail = Credential('buda', 'Gmail', 'Mumo', 'Msyoka!') 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('buda', 'Twitter', 'Mumo', 'Msyoka!') 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('buda', 'Twitter', 'Mumo', 'Msyoka!') 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('Msyoka!', pyperclip.paste()) print(pyperclip.paste())
def setUp(self): ''' Function to create a user account before each test ''' self.new_user = User('David', 'Mumo', 'Msyoka!')
def create_new_user(username, password): ''' Function to create a new user with a username and password ''' new_user = User(username, password) return new_user
def display_user(): """ Function to display existing user """ return User.display_user()
def save_userDetails(new_user): ''' a funtion to save user details ''' User.save_userDetails(new_user)
def setUp(self): self.new_user = User("Celine", "mmbone", "0719476296", "*****@*****.**")
def save_user(user): ''' Function that saves a new password-Locker user account ''' User.save_user(user)