def test_password_autogenerate(self): # test method to test auto generation of passwords self.new_account.save_account() another_account = Credentials("Blog", "Ger") another_account.save_account()
def test_dislay_accounts(self): # test method for displaying accounts self.new_account.save_account() another_account = Credentials("Gscroll", "Edward", "Young-Tad") another_account.save_account() self.assertEqual(Credentials.display_accounts(), Credentials.usercredential)
def test_save_multiple(self): ''' test method to check if user can add many accounts ''' self.new_account.save_account() another_account = Credentials("Instagram", "Robert", "Alai1234") another_account.save_account() self.assertEqual(len(Credentials.usercredential), 2) # We should have two of them
def test_delete_account(self): ''' test method to check if an account has been deleted ''' self.new_account.save_account() another_account = Credentials("LinkedIn", "Sam", "Yayers") another_account.save_account() self.new_account.delete_account() self.assertEqual(len(Credentials.usercredential), 1)
def test_search_accounts(self): ''' test method to test search functionality ''' self.new_account.save_account() another_account = Credentials("Facebook", "Kevin", "Stano1234") another_account.save_account() self.assertEqual(another_account, Credentials.search_accounts("Facebook"))
def setUp(self): ''' method run before each test. Gives the cutting guideline ''' self.new_account = Credentials("Twitter", "cyprian", "MyPassword")
class UserClassTest(unittest.TestCase): def setUp(self): ''' method run before each test. Gives the cutting guideline ''' self.new_account = Credentials("Twitter", "cyprian", "MyPassword") def tearDown(self): ''' method run after each test to avoid errors just as explained in the LMS should come before the test. ''' Credentials.usercredential = [] def test_init(self): ''' test to check for proper initialization ''' self.assertEqual(self.new_account.account_name, "Twitter") self.assertEqual(self.new_account.username, "cyprian") self.assertEqual(self.new_account.password, "MyPassword") def test_save_account(self): ''' test method that checks if account has been saved ''' self.new_account.save_account() self.assertEqual(len(Credentials.usercredential), 1) def test_save_multiple(self): ''' test method to check if user can add many accounts ''' self.new_account.save_account() another_account = Credentials("Instagram", "Robert", "Alai1234") another_account.save_account() self.assertEqual(len(Credentials.usercredential), 2) # We should have two of them def test_delete_account(self): ''' test method to check if an account has been deleted ''' self.new_account.save_account() another_account = Credentials("LinkedIn", "Sam", "Yayers") another_account.save_account() self.new_account.delete_account() self.assertEqual(len(Credentials.usercredential), 1) def test_password_autogenerate(self): # test method to test auto generation of passwords self.new_account.save_account() another_account = Credentials("Blog", "Ger") another_account.save_account() def test_dislay_accounts(self): # test method for displaying accounts self.new_account.save_account() another_account = Credentials("Gscroll", "Edward", "Young-Tad") another_account.save_account() self.assertEqual(Credentials.display_accounts(), Credentials.usercredential) def test_search_accounts(self): ''' test method to test search functionality ''' self.new_account.save_account() another_account = Credentials("Facebook", "Kevin", "Stano1234") another_account.save_account() self.assertEqual(another_account, Credentials.search_accounts("Facebook"))
def display_account(): # function to display all accounts saved return Credentials.display_accounts()
def generate_password(): # function to generate a password random_password = Credentials.password_generate() return random_password
def search_accounts(search): # function to find an account by account name return Credentials.search_accounts(search)
def create_account(account, u_name, passwd): # function to create a new account new_account = Credentials(account, u_name, passwd) return new_account