예제 #1
0
 def test_save_many_account(self):
 '''
     test to check if we can save multiple credentials objects to our credentials list
     '''
     self.new_creditials.save_user_creditials()
     test_creditial = Creditials('kerry','kerry1','joker1234')
     test_creditial.save_user_creditials()
     self.assertEqual(len(Creditials.creditials_list),2)
예제 #2
0
 def test_creditial_exist(self):
     """
     test to check if we can return a true or false based on whether we find or can't find the credential.
     """
     self.new_creditials.save_user_creditials()
     test_creditial = Creditials('kerry','kerry1','joker1234')
     test_creditial.save_user_creditials()
     
     found_credential = Creditials.creditials_exist("kerry")
     self.assertTrue(found_credential)
예제 #3
0
 def test_delete_credential(self):
     """
     test method to test if we can remove an account credentials from our credentials_list
     """
     self.new_creditials.save_user_creditials()
     test_creditial = Creditials('kerry','kerry1','joker1234')
     test_creditial.save_user_creditials()
     
     
     self.new_creditials.delete_creditials()
     self.assertEqual(len(Creditials.creditials_list),1)
예제 #4
0
    def test_find_creditial(self):
        """
        test to check if we can find a credential entry by account name and display the details of the credential
        """
        
        self.new_creditials.save_user_creditials()
        test_creditial = Creditials('kerry','kerry1','joker1234')
        test_creditial.save_user_creditials()

        the_creditial = Creditials.find_by_number("kerry")
        self.assertEqual(the_creditial.account,test_creditial.account)
예제 #5
0
def generate_password(self):
    ''' 
    function tht generates password randomely
    '''
    auto_password = Creditials.generate_password(self)
    return auto_password
예제 #6
0
def check_credentials(account):
    '''
    function that checks if the credentials of the searched name exist and return true or falsd
    '''
    return Creditials.creditials_exist(account)
예제 #7
0
def find_credential(account):
    """
    Function that finds a Credentials by an account name and returns the Credentials that belong to that account
    """
    return Creditials.find_by_number(account)
예제 #8
0
def create_new_credential(account, username, password):
    '''
    function that create new credential details for a new user
    '''
    new_credential = Creditials(account, username, password)
    return new_credential
예제 #9
0
def login_user(password, username):
    '''
    a fumction that checks if the users already exist 
    '''
    checked_user = Creditials.verify_user(password, username)
    return checked_user
예제 #10
0
 def setUp(self):
     '''
     Method that runs before each individual credentials test methods run.
     '''
     self.new_creditials = Creditials('kerry','kerry1','joker1234')
예제 #11
0
class TestCreditials(unittest.TestCase):   
    """
    A test class that defines test cases for credentials class

    """ 
    def setUp(self):
        '''
        Method that runs before each individual credentials test methods run.
        '''
        self.new_creditials = Creditials('kerry','kerry1','joker1234')

    def tearDown(self):
        '''
        method that does clean up after each test case has run.
        '''
        Creditials.creditials_list = []

    def test_details(self):
        """
        Test case to check if a new Credentials instance has been initialized correctly
        """
        
        self.assertEqual(self.new_creditials.account,'kerry')
        self.assertEqual(self.new_creditials.username,'kerry1')
        self.assertEqual(self.new_creditials.password,'joker1234') 

    def test_save_credentials(self):
        """
        test case to test if the crential object is saved into the credentials list.

        """
        self.new_creditials.save_user_creditials()
        self.assertEqual(len(Creditials.creditials_list),1)

    def test_save_many_account(self):
    '''
        test to check if we can save multiple credentials objects to our credentials list
        '''
        self.new_creditials.save_user_creditials()
        test_creditial = Creditials('kerry','kerry1','joker1234')
        test_creditial.save_user_creditials()
        self.assertEqual(len(Creditials.creditials_list),2)

    def test_find_creditial(self):
        """
        test to check if we can find a credential entry by account name and display the details of the credential
        """
        
        self.new_creditials.save_user_creditials()
        test_creditial = Creditials('kerry','kerry1','joker1234')
        test_creditial.save_user_creditials()

        the_creditial = Creditials.find_by_number("kerry")
        self.assertEqual(the_creditial.account,test_creditial.account)

    def test_creditial_exist(self):
        """
        test to check if we can return a true or false based on whether we find or can't find the credential.
        """
        self.new_creditials.save_user_creditials()
        test_creditial = Creditials('kerry','kerry1','joker1234')
        test_creditial.save_user_creditials()
        
        found_credential = Creditials.creditials_exist("kerry")
        self.assertTrue(found_credential)

    def test_delete_credential(self):
        """
        test method to test if we can remove an account credentials from our credentials_list
        """
        self.new_creditials.save_user_creditials()
        test_creditial = Creditials('kerry','kerry1','joker1234')
        test_creditial.save_user_creditials()
        
        
        self.new_creditials.delete_creditials()
        self.assertEqual(len(Creditials.creditials_list),1)