Example #1
0
    def test_find_account_by_name(self):
        self.new_account.save_account()
        test_account = Account("Medium", "Jeff_Bezos", "investingissmart")
        test_account.save_account()

        found_account = Account.find_by_accountName("Medium")
        self.assertEqual(found_account.account_name, "Medium")
class TestAccount(unittest.TestCase):
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_account = Account("Gmail", "James", "james123")

    def tearDown(self):
        '''
        The tear down method which will clean up after every test case is complete
        '''

        Account.accounts = []

    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_account.account_name, "Gmail")
        self.assertEqual(self.new_account.username, "James")
        self.assertEqual(self.new_account.password, "james123")

    def test_save_account(self):

        self.new_account.save_account()
        self.assertEqual(len(Account.accounts), 1)

    def test_display_all_account(self):
        '''
        method that returns a list of all contacts saved
        '''

        self.assertEqual(Account.display_account(), Account.accounts)
Example #3
0
    def test_delete_account(self):
        self.new_account.save_account()
        test_account = Account("Twitter", "James_Lebron", "basketballislife")
        test_account.save_account()

        self.new_account.delete_account()
        # test_account.delete_account()
        self.assertEqual(len(Account.account_list), 1)
Example #4
0
class TestAccount(unittest.TestCase):
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''

        self.new_account = Account("Instagram", "Edithreine", "umedith")

    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''

        self.assertEqual(self.new_account.account_name, "Instagram")
        self.assertEqual(self.new_account.account_userName, "Edithreine")
        self.assertEqual(self.new_account.account_password, "umedith")

    def test_save_account(self):
        '''
        test_save_account test case to test if the account object is saved into
         the account list
        '''

        self.new_account.save_account()  #saving the new account
        self.assertEqual(len(Account.account_list), 1)

    def tearDown(self):
        Account.account_list = []

    def test_display_account_credentials(self):
        self.assertEqual(Account.display_accounts(), Account.account_list)

    def test_delete_account(self):
        self.new_account.save_account()
        test_account = Account("Twitter", "James_Lebron", "basketballislife")
        test_account.save_account()

        self.new_account.delete_account()
        # test_account.delete_account()
        self.assertEqual(len(Account.account_list), 1)

    def test_find_account_by_name(self):
        self.new_account.save_account()
        test_account = Account("Medium", "Jeff_Bezos", "investingissmart")
        test_account.save_account()

        found_account = Account.find_by_accountName("Medium")
        self.assertEqual(found_account.account_name, "Medium")
Example #5
0
def find_account(account_name):
    '''
    Function that finds a account by number and returns the account
    '''
    return Account.find_account(account_name)
Example #6
0
def del_account(Account):
    '''
    Function to delete a account
    '''
    Account.delete_account()
Example #7
0
def save_accounts(Account):
    '''
    Function to save account
    '''
    Account.save_account()
Example #8
0
def create_account(a_name, u_name, pass_word):
    '''
    Function to create a new account
    '''
    new_account = Account(a_name, u_name, pass_word)
    return new_account
Example #9
0
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''

        self.new_account = Account("Instagram", "Edithreine", "umedith")
Example #10
0
 def test_display_account_credentials(self):
     self.assertEqual(Account.display_accounts(), Account.account_list)
Example #11
0
def find_account_credentials(accountname):
    return Account.find_by_accountName(accountname)
Example #12
0
def display_account_credentials():
    return Account.display_accounts()
Example #13
0
def create_account(accountname, accountusername, accountpassword):
    new_account = Account(accountname, accountusername, accountpassword)
    return new_account
Example #14
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_account = Account("Gmail", "James", "james123")
Example #15
0
def check_existing_accounts(account_name):

    return Account.find_account(account_name)
Example #16
0
def main():
    pass_word = password2
    print("Hello, What name would like use to call you?")
    master_name = input()
    print("Please enter your master password :"******"Hello {master_name}. what would you like to do?")
    print('\n')

    while True:
        print("Use these short codes :")
        print(" cc - create a new account")
        print(" dc - display accounts")
        print(" fc -find a account")
        print(" ex -exit the account list")
        short_code = input().lower()

        if short_code == 'cc':
            #account
            print("New account")
            print("-" * 10)

            #account_name
            print(
                "Please type in the account:(Facebook, Twitter, Gmail e.t.c)")
            a_name = input()

            #user_name
            print("Username:"******"Do you what us to generate a password for you ....(yes or no)"
            )
            shortcode = input()
            if shortcode == 'yes':
                password = pass_word
                print(f"your password is {password} ")
            else:
                print("enter your password")
                password = input()
            #Saves the credentials
            save_accounts(create_account(a_name, u_name, password))

            print('\n')
            print(
                f"you have succesfully created your new credentials for {a_name} account"
            )
            print('\n')

        elif short_code == 'dc':

            if Account.display_account():
                print("Here is a list of all your accounts")
                print('\n')

                for account in Account.display_account():
                    print("Account          Username          Password")
                    print(
                        f"{account.account_name}            {account.username}         {account.password}"
                    )

                print('\n')
            else:
                print('\n')
                print("You dont seem to have any accounts saved yet")
                print('\n')

        elif short_code == 'fc':

            print("Enter the account you want to search for")

            search_account = input()
            if check_existing_accounts(search_account):
                search_account = find_account(search_account)
                print(f"{Account.search_account.account_name}")
                print('-' * 20)

                print(f"Username: .......{search_account.user_name}")
                print(f"Password: .......{search_account.password}")
            else:
                print("That account does not exist")

        elif short_code == "ex":
            print("Bye .......")
            break
        else:
            print("Invalid Input! ")
Example #17
0
    def test_display_all_account(self):
        '''
        method that returns a list of all contacts saved
        '''

        self.assertEqual(Account.display_account(), Account.accounts)