def setUp(self): ''' Set up method to run before each test case ''' self.new_credential = Credentials("Lewis", "Twitter", "Lewis", "1234")
def find_credential(account): return Credentials.find_credential(account)
def generate_Password(): auto_password = Credentials.generatePassword() return auto_password
def setUp(self): ''' method to run before and after each test ''' self.new_credential = Credentials("vperry", "twitter", "xyz")
def create_new_credential(account, userName, password): new_credential = Credentials(account, userName, password) return new_credential
def Credentialsuser_exist(account): return Credentials.credentialsuser_exist(account)
def gen_password(): gen_password = Credentials.gen_password() return gen_password
def delete_credentials(Credentials): return Credentials.delete_credentials()
def show_credentials(): return Credentials.show_credentials()
def test_generate_password(self): test_credentials = Credentials("instagram","bchizi","lehann","lbchizi") test_credentials.social_password = Credentials.generate_password()
def create_credentials(account_name, login_detail, Password): new_credentials = Credentials(account_name, Password) return new_credentials
def test_display_credentials(self): """ method that returns a list of all credentials """ self.assertEqual(Credentials.display_credentials(),Credentials.credentials_list)
def setUp(self): self.new_account = Credentials ("instagram","bchizi","lehann","lbchizi")
def test_display_credentials(self): ''' test case to test if credentials are displayed ''' self.assertEqual(Credentials.display_credentials(), Credentials.credentials_list)
def save_credentials(credentials): Credentials.save_credentials(credentials)
def test_user_account_exits(self): self.newlogin.save_user_account() test_user = Credentials("username", "password", "accountType") test_user.save_user_account() user_account_exists = Credentials.user_account_exists("username") self.assertEqual(user_account_exists)
def display_credentials(): return Credentials.display_credentials()
def test_display_user_acounts(self): self.assertEqual(Credentials.display_user_accounts(), Credentials.user_details_list)
def find_account(account): return Credentials.find_account(account)
def setUp(self): self.newlogin = Credentials("devgakuya", "qwerty", "DevPass")
def test_show_credentials(self): '''This test will list all the credentials''' self.assertEqual(Credentials.list_all(), Credentials.credentials_list)
def test_display_all_account(self): ''' method that returns a list of all account saved ''' self.assertEqual(Credentials.display_accounts(), Credentials.accounts)
def login_user(username, password): check_user = Credentials.verify_user(username, password) return check_user
def setUp(self): ''' Set up method to run before each test cases. ''' # create user object self.new_account = Credentials("WhatsApp", "daudi", "password")
def display_accounts_details(): return Credentials.display_credentials()
class TestCredentials(unittest.TestCase): ''' Test class that defines test cases for the credential class behaviours. Args: unittest.TestCase: TestCase class that helps in creating test cases ''' #1 def setUp(self): ''' Set up method to run before each test cases. ''' # create user object self.new_account = Credentials("WhatsApp", "daudi", "password") def tearDown(self): ''' tearDown method that does clean up after each test case has run. ''' Credentials.accounts = [] def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_account.user_account_name, "WhatsApp") self.assertEqual(self.new_account.user_account_user, "daudi") self.assertEqual(self.new_account.user_account_password, "password") def test_save_account(self): ''' test_save_user test case to test if the credential object is saved into the account list ''' # saving the new credential account self.new_account.save_account() self.assertEqual(len(Credentials.accounts), 1) def test_save_multiple_accounts(self): ''' test_save_multiple_accounts to check if we can save multiple accounts objects to our accounts ''' self.new_account.save_account() test_account = Credentials("WhatsApp", "daudi", "password") # new account test_account.save_account() self.assertEqual(len(Credentials.accounts), 2) def test_delete_account(self): ''' test_delete_user to test if we can remove a account from our accounts ''' self.new_account.save_account() test_account = Credentials("Test", "user", "password") # new account test_account.save_account() self.new_account.accounts self.new_account.delete_account() # Deleting a account object self.assertEqual(len(Credentials.accounts), 1) def test_find_account_by_number(self): ''' test to check if we can find a account by phone number and display information ''' self.new_account.save_account() test_account = Credentials("Test", "anum", "password") # new account test_account.save_account() found_account = Credentials.find_by_number("anum") self.assertEqual(found_account, Credentials.find_by_number("anum")) # Test if account exist def test_account_exists(self): ''' test to check if we can return a Boolean if we cannot find the user. ''' self.new_account.save_account() test_account = Credentials("Viber", "daudi", "12345") # new account test_account.save_account() account_exists = Credentials.account_exist("daudi") self.assertTrue(account_exists) """ Dispaly account user """ def test_display_all_account(self): ''' method that returns a list of all account saved ''' self.assertEqual(Credentials.display_accounts(), Credentials.accounts)
def check_credendtials(account): return Credentials.if_credential_exist(account)
def create_credentials(account, username, password): New_credentials = Credentials(account, username, password) return New_credentials
def copy_password(account): return Credentials.copy_password(account)
def setUp(self): """ Method to define the constructor """ self.cred = Credentials("Instagram", "@nyambucindy", "fox12345")