def test_multiple_accounts(self): ''' Test case to check if we can save multiple contacts ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() self.assertEqual(len(Accounts.accounts_list),2)
def test_find_account_by_name(self): ''' Test case to check if we can find account details by account name and display the information ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() found_account = Accounts.find_by_name("Twitter") self.assertEqual(found_account.password,test_myaccounts.password)
def test_delete_accounts(self): ''' Test case for removing unwanted accounts from accounts-list ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() self.new_myaccounts.delete_account() self.assertEqual(len(Accounts.accounts_list),1)
def test_account_exists(self): ''' test to check if we can return a Boolean if we cannot find the contact. ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() account_exists = Accounts.account_exists("Twitter") self.assertTrue(account_exists)
def add_account(account, usr_name, a_password): ''' Function to add new account details ''' new_myaccounts = Accounts(account, usr_name, a_password) return new_myaccounts
def display_accounts(): ''' Function that returns all saved ''' return Accounts.display_all_accounts()
def view_existing_accounts(name): ''' Function that check if an account exists with account name and return a boolean ''' return Accounts.account_exists(name)
def find_account(name): ''' Function that finds an account by account-name and returns the account ''' return Accounts.find_by_name(name)
def test_display_all_accounts(self): ''' method that returns a list of all accounts saved ''' self.assertEqual(Accounts.display_all_accounts(),Accounts.accounts_list)
class TestAccounts(unittest.TestCase): ''' Test class that defines test cases for the accounts class behaviours. Args: unittest.TestCase: TestCase class that helps in creating test cases ''' def tearDown(self): ''' This method does clean up after each test case has run. ''' Accounts.accounts_list = [] Users.usersList = [] def setUp(self): ''' Set up method to run before each test cases. ''' self.new_myaccounts = Accounts("LinkedIn","Jammy","jem#jem") #create account object self.new_user = Users("Jemila","fuaad")#create user object def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_myaccounts.account_name,"LinkedIn") self.assertEqual(self.new_myaccounts.username, "Jammy") self.assertEqual(self.new_myaccounts.password, "jem#jem") self.assertEqual(self.new_user.loc_username, "Jemila") self.assertEqual(self.new_user.loc_password, "fuaad") def test_save_account(self): ''' Test case to test if the accounts object is saved in the myaccounts list ''' self.new_myaccounts.save_account() self.assertEqual(len(Accounts.accounts_list),1) def test_multiple_accounts(self): ''' Test case to check if we can save multiple contacts ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() self.assertEqual(len(Accounts.accounts_list),2) def test_delete_accounts(self): ''' Test case for removing unwanted accounts from accounts-list ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() self.new_myaccounts.delete_account() self.assertEqual(len(Accounts.accounts_list),1) def test_display_all_accounts(self): ''' method that returns a list of all accounts saved ''' self.assertEqual(Accounts.display_all_accounts(),Accounts.accounts_list) def test_find_account_by_name(self): ''' Test case to check if we can find account details by account name and display the information ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() found_account = Accounts.find_by_name("Twitter") self.assertEqual(found_account.password,test_myaccounts.password) def test_account_exists(self): ''' test to check if we can return a Boolean if we cannot find the contact. ''' self.new_myaccounts.save_account() test_myaccounts = Accounts("Twitter","Jammy","jam#jam") test_myaccounts.save_account() account_exists = Accounts.account_exists("Twitter") self.assertTrue(account_exists) # def test_copy_credentilas(self): # '''Test case to confirm we are copying username and password from account found # ''' # self.new_myaccounts.save_account() # Accounts.username("jammy") # Accounts.password("jam#jam") # self.assertEqual(self.new_myaccounts.username,self.new_myaccounts.password,pyperclip.paste()) def test_save_users(self): ''' Test case to confirm if users are being added to the users list ''' self.new_user.save_users() self.assertEqual(len(Users.usersList),1)
def setUp(self): ''' Set up method to run before each test cases. ''' self.new_myaccounts = Accounts("LinkedIn","Jammy","jem#jem") #create account object self.new_user = Users("Jemila","fuaad")#create user object