def test_save_multiple_accounts(self): ''' test to check if we can save multiple credentials objects to our credentials list ''' self.new_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() self.assertEqual(len(Credentials.credentials_list),2)
def test_find_credentials(self): """ test to check if we can find credential using account name """ self.new_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() found_credentials = Credentials.find_account_name('Twitter') self.assertEqual(found_credentials.account_name,test_credentials.account_name)
def test_credentials_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_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() credentials_exist = Credentials.credentials_exist('Twitter') self.assertTrue(credentials_exist)
def test_delete_credential(self): """ test method to test if we can remove an account credentials from our credentials_list """ self.new_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() self.new_credentials.delete_credentials() self.assertEqual(len(Credentials.credentials_list),1)
def test_save_multiple_accounts(self): self.new_credentials.save_credentials() test_credentials = Credentials('Facebook','Aoko','Mercy2x0') test_credentials.save_credentials() self.assertEqual(len(Credentials.credentials_list),2)
def copy_credentials(): return Credentials.copy_credentials()
def generate_password(): gen_pwrd = Credentials.generate_password() return gen_pwrd
def find_credentials(account_name): return Credentials.find_account_name(account_name)
def check_credentials(account_name): return Credentials.credentials_exist()
def display_credentials(): return Credentials.display_credentials()
def create_credentials(account_name, username, password): new_credentials = Credentials(account_name, username, password) return new_credentials
def display_credential_list(): """ Function that returns all the saved credential. """ return Credentials.display_credentials()
def test_credentials_exist(self): self.new_credentials.save_credentials() test_credentials = Credentials('Facebook','Aoko','Mercy2x0') test_credentials.save_credentials() credentials_exist = Credentials.credentials_exist('Facebook') self.assertTrue(credentials_exist)
def test_delete_credential(self): self.new_credentials.save_credentials() test_credentials = Credentials('Facebook','Aoko','Mercy2x0') test_credentials.save_credentials() self.new_credentials.delete_credentials() self.assertEqual(len(Credentials.credentials_list),1)
def check_credentials(account_name): """ Function that check if a Credentials exists with that account name and return true or false """ return Credentials.credentials_exist()
def setUp(self): """ Method that runs before each individual credentials test methods run. """ self.new_credentials = Credentials('Instagram','Abzed','Abzed1z0')
class TestCredentials(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_credentials = Credentials('Instagram','Abzed','Abzed1z0') def test_init(self): """ Test case to check if a new Credentials instance has been initialized correctly """ self.assertEqual(self.new_credentials.account_name,'Instagram') self.assertEqual(self.new_credentials.username,'Abzed') self.assertEqual(self.new_credentials.password,'Abzed1z0') def test_save_credentials(self): """ test case to test if the crential object is saved into the credentials list. """ self.new_credentials.save_credentials() self.assertEqual(len(Credentials.credentials_list),1) def tearDown(self): ''' method that does clean up after each test case has run. ''' Credentials.credentials_list = [] def test_save_multiple_accounts(self): ''' test to check if we can save multiple credentials objects to our credentials list ''' self.new_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() self.assertEqual(len(Credentials.credentials_list),2) def test_delete_credential(self): """ test method to test if we can remove an account credentials from our credentials_list """ self.new_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() self.new_credentials.delete_credentials() self.assertEqual(len(Credentials.credentials_list),1) def test_find_credentials(self): """ test to check if we can find credential using account name """ self.new_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() found_credentials = Credentials.find_account_name('Twitter') self.assertEqual(found_credentials.account_name,test_credentials.account_name) def test_credentials_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_credentials.save_credentials() test_credentials = Credentials('Twitter','Abzed','Abzedar2') test_credentials.save_credentials() credentials_exist = Credentials.credentials_exist('Twitter') self.assertTrue(credentials_exist) def display_credentials(self): ''' method that displays all the credentials that has been saved by the user ''' self.assertEqual(Credentials.display_credentials(),Credentials.credentials_list)
def generate_password(): ''' generates a random password for the user. ''' gen_pwrd = Credentials.generate_password() return gen_pwrd
def find_credentials(account_name): """ Function that finds a Credentials by an account name and returns the Credentials that belong to that account """ return Credentials.find_account_name(account_name)
def test_find_credentials(self): self.new_credentials.save_credentials() test_credentials = Credentials('Facebook','Aoko','Mercy2x0') test_credentials.save_credentials() found_credentials = Credentials.find_account_name('Facebook') self.assertEqual(found_credentials.account_name,test_credentials.account_name)
def display_credentials(self): ''' method that displays all the credentials that has been saved by the user ''' self.assertEqual(Credentials.display_credentials(),Credentials.credentials_list)
def display_credentials(self): self.assertEqual(Credentials.display_credentials(),Credentials.credentials_list)
def create_credentials(account_name, username, password): """ Function that creates new credentials for a given user account """ new_credentials = Credentials(account_name, username, password) return new_credentials