Esempio n. 1
0
 def test_save_multiple_credentials(self):
     """test to check if we can save multiple account credentials.
     """
     self.new_account.save_credentials()
     test_credentials = Credentials("InstaJames", "Hello000")  #new account
     test_credentials.save_credentials()
     self.assertEqual(len(Credentials.account_list), 2)
Esempio n. 2
0
 def test_save_multiple_accounts(self):
     '''
     tests to check if we can solve multiple credential objects to our account_list
     '''
     self.new_account.save_account()
     test_account = Credentials(1,"Jerusha","Auma","*****@*****.**", "jeru") #new account
     test_account.save_account()
     self.assertEqual(len(Credentials.account_list),2)
Esempio n. 3
0
 def test_find_credentials_by_username(self):
     """
     test to check if we can find the credentials using just the username
     """
     self.new_account.save_credentials()
     test_credentials = Credentials("InstaJames", "test")  #new contact
     test_credentials.save_credentials()
     found_credentials = Credentials.find_by_username("InstaJames")
     self.assertEqual(found_credentials.password, test_credentials.password)
Esempio n. 4
0
 def test_delete_credentials(self):
     """
     test to see if we can remove account credentials from our list
     """
     self.new_account.save_credentials()
     test_credentials = Credentials("FbJames", "Facebook")  #new credentials
     test_credentials.save_credentials()
     self.new_account.delete_credentials()  #deleting a credentials object
     self.assertEqual(len(Credentials.account_list), 1)
Esempio n. 5
0
    def test_delete_account(self):
        '''
        tests if we can remove an account from account_list
        '''
        self.new_account.save_account()
        test_account = Credentials(1,"Jerusha","Auma","*****@*****.**", "jeru")
        test_account.save_account()

        self.new_account.delete_account() #Deleting a credential object
        self.assertEqual(len(Credentials.account_list),1)
Esempio n. 6
0
    def test_auhenticate(self):
        '''
        test to check if we can restrict access by password authentication
        '''

        self.new_account.save_account()
        test_account = Credentials(1,"Jerusha","Auma","*****@*****.**", "jeru")
        test_account.save_account()

        found_account = Credentials.authenticate_account("Jerusha","jeru")
        self.assertEqual(found_account.user_id, test_account.user_id)
Esempio n. 7
0
def create_account(users_name, username, password):
    """
    function to create new credentials for a new account
    """
    new_account = User(users_name)
    new_account = Credentials(username, password)
    return new_account
Esempio n. 8
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_account = Credentials(1,"Michel","Atieno","*****@*****.**","michel") #create new object
Esempio n. 9
0
def display_credentials():
    """
    function that returns all saved credentials
    """
    return Credentials.display_credentials()
Esempio n. 10
0
def copy_credentials(Credentials):
    """
    function that return copied credentials, those in clipboard
    """
    return Credentials.copy_credentials()
Esempio n. 11
0
def create_account(user_id, first_name, last_name, email, password):
    '''
    Function to create a new account
    '''
    new_account = Credentials(user_id, first_name, last_name, email, password)
    return new_account
Esempio n. 12
0
def find_credentials(username):
    """
    function that finds credentials by username and returns all credentias
    """
    return Credentials.find_by_username(username)
Esempio n. 13
0
def authenticate_account(first_name, password):
    '''
    Function to authenticate account
    '''
    return Credentials.authenticate_account(first_name, password)
Esempio n. 14
0
 def test_display_credentials(self):
     """
     test to check if display_credentials works
     """
     self.assertEqual(Credentials.display_credentials(),
                      Credentials.account_list)
Esempio n. 15
0
class TestCredentials(unittest.TestCase
                      ):  #testcase checks for an expected result
    """
    Test class that defines test cases for the behaviours of the user and credentials classes.

    Arg:
        unittest.TestCase: TestCase class is used to help in creating test cases
    """
    def setUp(self):
        """
        The setup method is used to run before each testcase.
        """
        self.new_account = Credentials("TwitterJames",
                                       "12345678")  #create credentials object

    def test_init(self):
        """
        test_init test case to test if the object was initialised properly
        """
        self.assertEqual(self.new_account.username, "TwitterJames")
        self.assertEqual(self.new_account.password, "12345678")

    def test_save_credentials(self):
        """
        test_save_user test case to test if user object is saved 
        """
        self.new_account.save_credentials()  #save the user info
        self.assertEqual(len(Credentials.account_list), 1)

    def tearDown(self):
        """
        tearDown method does clean up after each test case has run
        """
        Credentials.account_list = []

    def test_save_multiple_credentials(self):
        """test to check if we can save multiple account credentials.
        """
        self.new_account.save_credentials()
        test_credentials = Credentials("InstaJames", "Hello000")  #new account
        test_credentials.save_credentials()
        self.assertEqual(len(Credentials.account_list), 2)

    def test_delete_credentials(self):
        """
        test to see if we can remove account credentials from our list
        """
        self.new_account.save_credentials()
        test_credentials = Credentials("FbJames", "Facebook")  #new credentials
        test_credentials.save_credentials()
        self.new_account.delete_credentials()  #deleting a credentials object
        self.assertEqual(len(Credentials.account_list), 1)

    def test_find_credentials_by_username(self):
        """
        test to check if we can find the credentials using just the username
        """
        self.new_account.save_credentials()
        test_credentials = Credentials("InstaJames", "test")  #new contact
        test_credentials.save_credentials()
        found_credentials = Credentials.find_by_username("InstaJames")
        self.assertEqual(found_credentials.password, test_credentials.password)

    # def test_copy_password(self):
    #     """
    #     test to confirm that we're copying password from an exising account
    #     """
    #     self.new_account.save_credentials()
    #     Credentials.copy_password("TwitterJames")
    #     self.assertEqual(self.new_account.password,pyperclip.paste())

    def test_display_credentials(self):
        """
        test to check if display_credentials works
        """
        self.assertEqual(Credentials.display_credentials(),
                         Credentials.account_list)
Esempio n. 16
0
class TestAccount(unittest.TestCase):

    '''
    Test class that defines test cases for the credentials class behaviours.

    Args: 
       unittest.TestCase: TestCase class that helps in creating test cases
    '''

    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_account = Credentials(1,"Michel","Atieno","*****@*****.**","michel") #create new object
    
    def tearDown(self):
        '''
        tearDown method that does clean up after each test case has run
        '''
        Credentials.account_list = []



    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_account.user_id,1)
        self.assertEqual(self.new_account.first_name,"Michel")
        self.assertEqual(self.new_account.last_name,"Atieno")
        self.assertEqual(self.new_account.email,"*****@*****.**") 
        self.assertEqual(self.new_account.password,"michel")

    def test_save_account(self):
        '''
        tests case to test if the credential object is saved into the account list
        '''
        self.new_account.save_account() #saving new account
        self.assertEqual(len(Credentials.account_list),1)

    def test_save_multiple_accounts(self):
        '''
        tests to check if we can solve multiple credential objects to our account_list
        '''
        self.new_account.save_account()
        test_account = Credentials(1,"Jerusha","Auma","*****@*****.**", "jeru") #new account
        test_account.save_account()
        self.assertEqual(len(Credentials.account_list),2)

    def test_delete_account(self):
        '''
        tests if we can remove an account from account_list
        '''
        self.new_account.save_account()
        test_account = Credentials(1,"Jerusha","Auma","*****@*****.**", "jeru")
        test_account.save_account()

        self.new_account.delete_account() #Deleting a credential object
        self.assertEqual(len(Credentials.account_list),1)

    def test_auhenticate(self):
        '''
        test to check if we can restrict access by password authentication
        '''

        self.new_account.save_account()
        test_account = Credentials(1,"Jerusha","Auma","*****@*****.**", "jeru")
        test_account.save_account()

        found_account = Credentials.authenticate_account("Jerusha","jeru")
        self.assertEqual(found_account.user_id, test_account.user_id)
Esempio n. 17
0
 def setUp(self):
     """
     The setup method is used to run before each testcase.
     """
     self.new_account = Credentials("TwitterJames",
                                    "12345678")  #create credentials object