def setUp(self): """ Method that runs before each individual credentials test methods run. """ self.new_credential = Credential('Instagram', 'uwas-dian', '@August2016')
def test_copy_password(self): ''' Test to confirm that we are copying the email address from a found contact ''' self.new_credential.save_credentials() Credential.copy_password("uwas-dian") self.assertEqual(self.new_credential.password, pyperclip.paste())
def test_save_many_accounts(self): ''' test to check if we can save multiple credentials objects to our credentials list ''' self.new_credential.save_credentials() test_credential = Credential("Yahoo", "RahelBrhane", "Rahel45xs") test_credential.save_credentials() self.assertEqual(len(Credential.credential_list), 2)
def test_detele_credential(self): """ test method to test if we can remove an account credentials from our credentials_list """ self.new_credential.save_credentials() test_credential = Credential("Yahoo", "RaheBrhane", "Rahel45xs") test_credential.save_credentials() self.new_credential.delete_credentials() self.assertEqual(len(Credential.credential_list), 1)
def test_find_credential(self): """ test to check if we can find a credential entry by username and display the details of the credential """ self.new_credential.save_credentials() test_credential = Credential("Yahoo", "RaheBrhane", "Rahel45xs") test_credential.save_credentials() username_credential = Credential.find_credential("RaheBrhane") self.assertEqual(username_credential.username, test_credential.username)
def test_credential_exist(self): """ test to check if we can return a true or false based on whether we find or can't find the credential. """ self.new_credential.save_credentials() username_credential = Credential("Yahoo", "RaheBrhane", "Rahel45xs") username_credential.save_credentials() found_user = Credential.credential_exist("RaheBrhane") self.assertTrue(found_user)
def copy_password(username): """ A funct that copies the password using the pyperclip framework """ return Credential.copy_password(username)
def chec_credentials(username): return Credential.credential_exist(username)
def find_credential(username): """ Function that finds a Credentials by an user name and returns the Credentials that belong to that account """ return Credential.find_credential(username)
def display_accounts_credentials(): """ Function that returns all the saved credential. """ return Credential.display_credentials()
def create_new_credential(accountName,username,password): """ Function that creates new credentials for a given user account """ new_credential = Credential(accountName,username,password) return new_credential
def login_user(userName,password): """ function that checks whether a user exist and then login the user in. """ check_user = Credential.user_verify(userName,password) return check_user
class TestClassCredentials(unittest.TestCase): """ A test class that defines test cases for credentials class """ def setUp(self): """ Method that runs before each individual credentials test methods run. """ self.new_credential = Credential('Instagram', 'uwas-dian', '@August2016') def test_init(self): """ Test case to check if a new Credentials instance has been initialized correctly """ self.assertEqual(self.new_credential.accountName, 'Instagram') self.assertEqual(self.new_credential.username, 'uwas-dian') self.assertEqual(self.new_credential.password, '@August2016') def test_save_credentials(self): """ test case to test if the crential object is saved into the credentials list. """ self.new_credential.save_credentials() self.assertEqual(len(Credential.credential_list), 1) def tearDown(self): ''' method that does clean up after each test case has run. ''' Credential.credential_list = [] def test_save_many_accounts(self): ''' test to check if we can save multiple credentials objects to our credentials list ''' self.new_credential.save_credentials() test_credential = Credential("Yahoo", "RahelBrhane", "Rahel45xs") test_credential.save_credentials() self.assertEqual(len(Credential.credential_list), 2) def test_detele_credential(self): """ test method to test if we can remove an account credentials from our credentials_list """ self.new_credential.save_credentials() test_credential = Credential("Yahoo", "RaheBrhane", "Rahel45xs") test_credential.save_credentials() self.new_credential.delete_credentials() self.assertEqual(len(Credential.credential_list), 1) def test_find_credential(self): """ test to check if we can find a credential entry by username and display the details of the credential """ self.new_credential.save_credentials() test_credential = Credential("Yahoo", "RaheBrhane", "Rahel45xs") test_credential.save_credentials() username_credential = Credential.find_credential("RaheBrhane") self.assertEqual(username_credential.username, test_credential.username) def test_copy_password(self): ''' Test to confirm that we are copying the email address from a found contact ''' self.new_credential.save_credentials() Credential.copy_password("uwas-dian") self.assertEqual(self.new_credential.password, pyperclip.paste()) def test_credential_exist(self): """ test to check if we can return a true or false based on whether we find or can't find the credential. """ self.new_credential.save_credentials() username_credential = Credential("Yahoo", "RaheBrhane", "Rahel45xs") username_credential.save_credentials() found_user = Credential.credential_exist("RaheBrhane") self.assertTrue(found_user) def test_display_credential(self): ''' method that displays all the credentials that has been saved by the user ''' self.assertEqual(Credential.display_credentials(), Credential.credential_list)
def test_display_credential(self): ''' method that displays all the credentials that has been saved by the user ''' self.assertEqual(Credential.display_credentials(), Credential.credential_list)