def test_delete_credentials(self): ''' test_delete_credentials to test if we can remove a credential from our list_of_credentials ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() self.new_credential.delete_credentials() self.assertEqual(len(Credential.list_of_credentials),1)
def test_save_multiple_credentials(self): ''' test_save_multiple_credentials to check if we can save multiple credential objects to our list_of_credentials ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() self.assertEqual(len(Credential.list_of_credentials), 2)
def test_find_credential_by_website(self): ''' test_find_credentials_by_website to test if the credentials of a specific website are really saved ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() found_credential = Credential.find_by_website("Slack") self.assertEqual(found_credential.account_name, "Slack")
def test_credential_exists(self): ''' test_credential_exists test case to test if the credentials exists in the list_of_credentials ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() credential_exists = Credential.credential_exists("Slack") self.assertTrue(credential_exists)
def test_copy_password(self): ''' Test to confirm that we are copying the account_password for a specific website ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() Credential.copy_password("Slack") self.assertEqual(self.new_credential.account_password,pyperclip.paste())
def setUp(self): ''' Setup method to run before each test cases. ''' self.new_credential = Credential("Slack","Tonykm","xyz456")
class TestCredential(unittest.TestCase): ''' Test class that defines test cases for 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 cases. ''' self.new_credential = Credential("Slack","Tonykm","xyz456") def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_credential.account_name,"Slack") self.assertEqual(self.new_credential.user_name,"Tonykm") self.assertEqual(self.new_credential.account_password,"xyz456") def test_save_credentials(self): ''' test_save_credential test case to test if the credential object is saved into the list of credentials ''' self.new_credential.save_credentials() self.assertEqual(len(Credential.list_of_credentials), 1) def test_save_multiple_credentials(self): ''' test_save_multiple_credentials to check if we can save multiple credential objects to our list_of_credentials ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() self.assertEqual(len(Credential.list_of_credentials), 2) def tearDown(self): ''' tearDown method that cleans up the list_of_credentials after each test case has run. ''' Credential.list_of_credentials = [] def test_delete_credentials(self): ''' test_delete_credentials to test if we can remove a credential from our list_of_credentials ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() self.new_credential.delete_credentials() self.assertEqual(len(Credential.list_of_credentials),1) def test_find_credential_by_website(self): ''' test_find_credentials_by_website to test if the credentials of a specific website are really saved ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() found_credential = Credential.find_by_website("Slack") self.assertEqual(found_credential.account_name, "Slack") def test_credential_exists(self): ''' test_credential_exists test case to test if the credentials exists in the list_of_credentials ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() credential_exists = Credential.credential_exists("Slack") self.assertTrue(credential_exists) def test_copy_password(self): ''' Test to confirm that we are copying the account_password for a specific website ''' self.new_credential.save_credentials() test_credential = Credential("Slack","Tonykm","xyz456") test_credential.save_credentials() Credential.copy_password("Slack") self.assertEqual(self.new_credential.account_password,pyperclip.paste())
def display_credential(): return Credential.display_all_credentials() '''
def copy_password(account_name): ''' This function allows user to copy password to clipboard ''' return Credential.copy_password(account_name)
def check_credential_exists(account_name): ''' Function that checks if credential in the list_of_credentials ''' return Credential.credential_exists(account_name)
def find_credential(account_name): ''' Function that returns credential for specific website ''' return Credential.find_by_website(account_name)
def save_credential(credential): ''' Functions invokes the save_credentials method from class Credential to add a new_credential to the list of credentials ''' Credential.save_credentials(credential)
def create_credential(account_name,user_name,acc_password): ''' This function allows the creation of new credential ''' new_credential = Credential(account_name,user_name,acc_password) return new_credential
def make_password(): ''' Function that generates a random password for the user ''' auto_password = Credential.automate_password() return auto_password