def test_search_social_media(self): ''' Test to confirm if the method returns the correct social media credential ''' self.new_credential.save_credentials() facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented') facebook.save_credentials() credential_exists = Credential.search_social_media('Facebook') self.assertEqual(credential_exists, facebook)
def test_display_credentials(self): ''' Test to confirm user can view the correct credential details ''' self.new_credential.save_credentials() facebook = Credential('cyrian', 'facebook', 'cyrian254', 'contented') facebook.save_credentials() self.assertEqual(Credential.display_credentials(), Credential.credentials_list)
def test_display_credentials(self): ''' method that returns a list of all credentials saved ''' self.new_credential.save_credentials() test_fb = Credential('sam','facebook','matta','123456') test_fb.save_credentials() self.assertEqual(Credential.display_credentials(User),Credential.user_credentials_list)
def test_save_multiple_credentials(self): ''' test_save_multiple_credential to check if we can save multiple credentials objects to our credentials_list ''' self.new_credential.save_credentials() test_credential = Credential("sam1","Medium","matta1","112233") # new credential test_credential.save_credentials() self.assertEqual(len(Credential.credentials_list),2)
def test_find_by_site_name(self): ''' Test to check if we can find a credential by site_name ''' self.new_credential.save_credentials() test_fb = Credential('Joseph', 'facebook', 'josylad', '123456') test_fb.save_credentials() credential_exists = Credential.find_by_site_name('facebook') self.assertEqual(credential_exists, test_fb)
def create_credential(user_name, social_media, account_name, password): ''' Function creating new credentials ''' new_credential = Credential(user_name, social_media, account_name, password) return new_credential
def test_confirm_user(self): ''' Function to confirm login details to active user ''' self.new_user = User('Norah', 'Shako', 'sugar') self.new_user.save_user() userX = User('Norah', 'Shako', 'sugar') userX.save_user() active_user = Credential.confirm_user('Norah', 'Shako', 'angry') self.assertTrue(active_user)
def test_copy_password(self): #uses pyperclip ''' Test to check if the copy password method will copy the correct password from social media site specified ''' self.new_credential.save_credentials() facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented') facebook.save_credentials() Credential.copy_password('facebook') self.assertEqual(self.new_credential.password, pyperclip.paste())
def test_copy_credential(self): ''' Test to confirm if we can copy a credential from saved credentials ''' self.new_credential.save_credentials() test_fb = Credential('Joseph', 'facebook', 'josylad', '123456') test_fb.save_credentials() Credential.copy_credential('123456') self.assertEqual(self.new_credential.password, pyperclip.paste()) print(pyperclip.paste())
def display_credentials(username): ''' Function to display saved credentials ''' return Credential.display_credentials(username)
def del_credential(site_name): ''' Function to delete a credential ''' Credential.delete_credentials()
def save_credential(credential): ''' Function to save a newly created credential ''' Credential.save_credentials(credential)
def create_credential(username, site_name, account_name, password): ''' Function to create a new credential ''' new_credential = Credential(username, site_name, account_name, password) return new_credential
def check_existing_site(site_name): ''' Function that check if a credential exists with that site_name and return a Boolean ''' return Credential.find_by_site_name(site_name)
def setUp(self): ''' Function to create social media account credentials before each test ''' self.new_credential = Credential('cyrian', 'facebook', 'cyrian254', 'contented')
def authenticate_user(first_name, password): ''' Function to verify user is enabled before launching the credentials ''' confirm_user = Credential.confirm_user(first_name, password) return confirm_user
def setUp(self): ''' Setup method to run before each test case ''' self.new_credential = Credential('Joseph', 'FB.com', 'Josylad', '123456')
class TestCredentials(unittest.TestCase): ''' Test class that defines the test cases for the the credential class behaviours. Args: unittest.TestCase: TestCase class that helps in creating test cases ''' def setUp(self): ''' Setup method to run before each test case ''' self.new_credential = Credential('Joseph', 'FB.com', 'Josylad', '123456') def test__init__(self): ''' Test to check if the initialization/creation of credential instances is properly done ''' self.assertEqual(self.new_credential.username, 'Joseph') self.assertEqual(self.new_credential.site_name, 'FB.com') self.assertEqual(self.new_credential.account_name, 'Josylad') self.assertEqual(self.new_credential.password, '123456') def test_save_credentials(self): ''' test_save_credentials test case to test if the credential object is saved into the credential list ''' self.new_credential.save_credentials() # saving the new credential self.assertEqual(len(Credential.credentials_list), 1) def test_save_multiple_credentials(self): ''' test_save_multiple_credential to check if we can save multiple credentials objects to our credentials_list ''' self.new_credential.save_credentials() test_credential = Credential("Joe", "Medium", "Josylad", "112233") # new credential test_credential.save_credentials() self.assertEqual(len(Credential.credentials_list), 2) def tearDown(self): ''' tearDown method that does clean up after each test case has run. ''' Credential.credentials_list = [] def test_find_by_site_name(self): ''' Test to check if we can find a credential by site_name ''' self.new_credential.save_credentials() test_fb = Credential('Joseph', 'facebook', 'josylad', '123456') test_fb.save_credentials() credential_exists = Credential.find_by_site_name('facebook') self.assertEqual(credential_exists, test_fb) def test_display_credentials(self): ''' method that returns a list of all credentials saved ''' self.new_credential.save_credentials() test_fb = Credential('Joseph', 'facebook', 'josylad', '123456') test_fb.save_credentials() self.assertEqual(Credential.display_credentials(User), Credential.user_credentials_list) def test_copy_credential(self): ''' Test to confirm if we can copy a credential from saved credentials ''' self.new_credential.save_credentials() test_fb = Credential('Joseph', 'facebook', 'josylad', '123456') test_fb.save_credentials() Credential.copy_credential('123456') self.assertEqual(self.new_credential.password, pyperclip.paste()) print(pyperclip.paste())
class TestCredentials(unittest.TestCase): ''' Test class that defines test cases for the credentials class behaviours Args: unittest.TestCase: Testcase class that helps create test cases ''' def test_confirm_user(self): ''' Function to confirm login details to active user ''' self.new_user = User('Norah', 'Shako', 'sugar') self.new_user.save_user() userX = User('Norah', 'Shako', 'sugar') userX.save_user() active_user = Credential.confirm_user('Norah', 'Shako', 'angry') self.assertTrue(active_user) def setUp(self): ''' Function to create social media account credentials before each test ''' self.new_credential = Credential('cyrian', 'facebook', 'cyrian254', 'contented') def test__init__(self): ''' Confirm that instance of credentials creation is as expected ''' self.assertEqual(self.new_credential.user_name, 'cyrian') self.assertEqual(self.new_credential.social_media, 'facebook') self.assertEqual(self.new_credential.account_name, 'cyrian254') self.assertEqual(self.new_credential.password, 'contented') def test_save_credentials(self): ''' Test and confirm that the new credential information is being saved ''' self.new_credential.save_credentials() self.assertEqual(len(Credential.credentials_list), 1) def tearDown(self): ''' tearDown method that executes a set of instructions after every test ''' User.users_list = [] Credential.credentials_list = [] def test_display_credentials(self): ''' Test to confirm user can view the correct credential details ''' self.new_credential.save_credentials() facebook = Credential('cyrian', 'facebook', 'cyrian254', 'contented') facebook.save_credentials() self.assertEqual(Credential.display_credentials(), Credential.credentials_list) def test_search_social_media(self): ''' Test to confirm if the method returns the correct social media credential ''' self.new_credential.save_credentials() facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented') facebook.save_credentials() credential_exists = Credential.search_social_media('Facebook') self.assertEqual(credential_exists, facebook) def test_copy_password(self): #uses pyperclip ''' Test to check if the copy password method will copy the correct password from social media site specified ''' self.new_credential.save_credentials() facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented') facebook.save_credentials() Credential.copy_password('facebook') self.assertEqual(self.new_credential.password, pyperclip.paste())
def find_credential(site_name): ''' Function that finds a contact by number and returns the contact ''' return Credential.find_by_site_name(site_name)
def copy_credential(site_name): ''' Function to copy a credentials details to the clipboard ''' return Credential.copy_credential(site_name)
def display_credentials(): ''' Function to display_credentials saved by user ''' return Credential.display_credentials()
def generate_password(): ''' Function to automatically gen password ''' gen_pwd = Credential.generate_password() return gen_pwd
def setUp(self): ''' Setup method to run before each test case ''' self.new_credential = Credential('sam','FB.com','matta','123456')
def save_credential(credential): ''' Saves new credentials ''' Credential.save_credentials(credential)
def verify_user(first_name, password): ''' Function that verifies the existence of the user before creating credentials ''' check_user = Credential.check_user(first_name, password) return check_user
def copy_password(social_media): ''' Function to copy credential details and paste then in clipboard ''' return Credential.copy_password(social_media)
def generate_password(): ''' Function to generate a password automatically ''' password_gen = Credential.generate_password() return password_gen