Exemple #1
0
class TestUser(unittest.TestCase):
    def setUp(self):
        self.newlogin = Credentials("devgakuya", "qwerty", "DevPass")

    def test_init(self):
        self.assertEqual(self.newlogin.username, "devgakuya")
        self.assertEqual(self.newlogin.password, "qwerty")
        self.assertEqual(self.newlogin.account_type, "DevPass")

    def test_save_account(self):
        self.newlogin.save_account()
        self.assertEqual(len(Credentials.user_details_list), 1)

    def tearDown(self):
        Credentials.user_details_list = []

    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 test_display_user_acounts(self):
        self.assertEqual(Credentials.display_user_accounts(),
                         Credentials.user_details_list)

    def test_delete_acc(self):
        self.newlogin.save_user_account()
        test_user = Credentials("username", "password", "accountType")
        test_user.save_user_account()

        self.newlogin.delete_acc()
        self.assertEqual(len(Credentials.user_details_list), 1)
Exemple #2
0
 def test_save_multiple_accounts(self):
     """
     test_save_multiple_accounts to test if we can save multiple credentials to accounts
     """
     self.newaccount.save_account()
     testaccount=Credentials("TestUsername","TestAccount","Password")
     testaccount.save_account()
     self.assertEqual(len(Credentials.accounts),2)
Exemple #3
0
 def test_delete_account(self):
     """
     test_delete_account to test if we can remove a credential from our account
     """
     self.newaccount.save_account()
     testaccount=Credentials("donaldkiplagat","Twitter","twitter123")
     testaccount.save_account()
     self.newaccount.delete_account()
     self.assertEqual(len(Credentials.accounts),1)
Exemple #4
0
 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","Wainaina","password") # new account
     test_account.save_account()
     self.assertEqual(len(Credentials.accounts),2)
Exemple #5
0
    def test_find_user_by_number(self):
        """
        test to check if we can find a credential by their accountusername and display the credential
        """
        self.newaccount.save_account()
        testaccount=Credentials("TestUsername","TestAccount","Password")
        testaccount.save_account()

        found_account = Credentials.find_by_number("TestUsername")
        self.assertEqual(found_account.accountusername,testaccount.accountusername)
Exemple #6
0
    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("Google","Wainaina","12345") # new account
            test_account.save_account()

            account_exists = Credentials.account_exist("Wainaina")

            self.assertTrue(account_exists)
Exemple #7
0
    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"))
Exemple #9
0
class TestCredentials(unittest.TestCase):
    def setUp(self):
        """
        Test class that defines test cases for the Credentials Class behaviours
        """
        self.newaccount = Credentials("donaldkiplagat","Instagram","donald123")

    def tearDown(self):
        """
        tearDown method that does clean up after each test case has been return
        """
        Credentials.accounts=[]

    def test_init(self):
        """
        test_init case to test if the object is initialized properly
        """
        self.assertEqual(self.newaccount.accountusername,"donaldkiplagat")
        self.assertEqual(self.newaccount.accountname,"Instagram")
        self.assertEqual(self.newaccount.accountpassword,"donald123")


    def test_save_account(self):
        """
        test_save_account test case to test if the credentials object is saved into accounts
        """
        self.newaccount.save_account()
        self.assertEqual(len(Credentials.accounts),1)

    def test_save_multiple_accounts(self):
        """
        test_save_multiple_accounts to test if we can save multiple credentials to accounts
        """
        self.newaccount.save_account()
        testaccount=Credentials("TestUsername","TestAccount","Password")
        testaccount.save_account()
        self.assertEqual(len(Credentials.accounts),2)

    def test_delete_account(self):
        """
        test_delete_account to test if we can remove a credential from our account
        """
        self.newaccount.save_account()
        testaccount=Credentials("donaldkiplagat","Twitter","twitter123")
        testaccount.save_account()
        self.newaccount.delete_account()
        self.assertEqual(len(Credentials.accounts),1)

    def test_display_all_accounts(self):
        """
        method that returns a list of all credentials saved
        """
        self.assertEqual(Credentials.display_accounts(),Credentials.accounts)

    def test_find_user_by_number(self):
        """
        test to check if we can find a credential by their accountusername and display the credential
        """
        self.newaccount.save_account()
        testaccount=Credentials("TestUsername","TestAccount","Password")
        testaccount.save_account()

        found_account = Credentials.find_by_number("TestUsername")
        self.assertEqual(found_account.accountusername,testaccount.accountusername)
Exemple #10
0
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("Youtube","Wainaina","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.account_name,"Youtube")
        self.assertEqual(self.new_account.user_account,"Wainaina")
        self.assertEqual(self.new_account.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","Wainaina","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)



    # 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("Google","Wainaina","12345") # new account
            test_account.save_account()

            account_exists = Credentials.account_exist("Wainaina")

            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)
Exemple #11
0
def save_account(Credentials):
    Credentials.save_account()