def test_save_multiple_user(self):
     '''
     test_save_multiple_user to check if we can save multiple user objects to the users list
     '''
     self.new_user.save_user()
     test_user = User("Test", "User", "usert001")  #new user
     test_user.save_user()
     self.assertEqual(len(User.users_list), 2)
Exemplo n.º 2
0
    def test__init__(self):
        '''
        Test to see if the initialisation works.
        '''
        self.new_user = User('Mag', 'Um', 'SGhhn20m')

        self.assertEqual(self.new_user.fname, 'Mag')
        self.assertEqual(self.new_user.lname, 'Um')
        self.assertEqual(self.new_user.pword, 'SGhhn20m')
Exemplo n.º 3
0
    def test_save_user(self):
        '''
        test_save_user test case to test if the user object is saved into
         the user list
        '''
        self.new_user = User('Mag', 'Um', 'SGhhn20m')

        self.new_user.save_user()
        self.assertEqual(len(User.users_list), 1)
Exemplo n.º 4
0
class TestUser(unittest.TestCase):
    def setUp(self):
        self.new_user = User('Aoko','Mercy2x0')
        
    def test_init(self):
        self.assertEqual(self.new_user.username,'Aoko')
        self.assertEqual(self.new_user.password,'Mercy2x0')
        
    def test_save_user(self):
        self.new_user.save_user()
        self.assertEqual(len(User.user_list),1)
class TestUser(unittest.TestCase):
    '''
    Test class that defines test cases for the user class behaviours.

    Agrs:
        unittest.TestCase: TestCase class that helps in creating test cases 

    '''
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_user = User("Kernael", "Apuko",
                             "oketch92")  #create user object

    def tearDown(self):
        '''
        tearDown method that does clean up after case has run.
        '''
        User.users_list = []

    def test_init(self):
        '''
        test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_user.first_name, "Kernael")
        self.assertEqual(self.new_user.last_name, "Apuko")
        self.assertEqual(self.new_user.password, "oketch92")

    def test_save_user(self):
        '''
        test case to test if the new user info is saved into the users list.
        '''
        self.new_user.save_user()  #saving the new user
        self.assertEqual(len(User.users_list), 1)

    def test_save_multiple_user(self):
        '''
        test_save_multiple_user to check if we can save multiple user objects to the users list
        '''
        self.new_user.save_user()
        test_user = User("Test", "User", "usert001")  #new user
        test_user.save_user()
        self.assertEqual(len(User.users_list), 2)
Exemplo n.º 6
0
class TestUser(unittest.TestCase):
    """
    A Test class that defines test cases for the User class.
    """
    def setUp(self):
        """
        Method that runs before each individual test methods run.
        """
        self.new_user = User('Abzed','Abzed1z0')
        
    def test_init(self):
        """
        test case to chek if the object has been initialized correctly
        """
        self.assertEqual(self.new_user.username,'Abzed')
        self.assertEqual(self.new_user.password,'Abzed1z0')
        
    def test_save_user(self):
        """
        test case to check if the user has been saved
        """
        self.new_user.save_user()
        self.assertEqual(len(User.user_list),1)
Exemplo n.º 7
0
class TestUser(unittest.TestCase):
    '''
    Test class that defines test cases for the user class behaviours.
    Args:
	    unittest.TestCase: helps in creating test cases
    '''
    def setUP(self):
        '''
        Function to create user account.
        '''
        self.new_user = User('Mag', 'Um', 'SGhhn20m')

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

    def test__init__(self):
        '''
        Test to see if the initialisation works.
        '''
        self.new_user = User('Mag', 'Um', 'SGhhn20m')

        self.assertEqual(self.new_user.fname, 'Mag')
        self.assertEqual(self.new_user.lname, 'Um')
        self.assertEqual(self.new_user.pword, 'SGhhn20m')

    def test_save_user(self):
        '''
        test_save_user test case to test if the user object is saved into
         the user list
        '''
        self.new_user = User('Mag', 'Um', 'SGhhn20m')

        self.new_user.save_user()
        self.assertEqual(len(User.users_list), 1)
    def test_check_user(self):
        '''
        function to test whether the log in function check_user work as expected
        '''
        self.new_user = User("Kernael", "Apuko", "oketch92")
        self.new_user.save_user()
        user2 = User("Mary", "Jane", "maryja01")
        user2.save_user()

        for user in User.users_list:
            if user.first_name == user2.first_name and user.password == user2.password:
                current_user = user.first_name
        return current_user

        self.assertEqual(current_user, (user2.password, user2.first_name))
Exemplo n.º 9
0
    def test_verify_user(self):
        '''
        Test for the verify_user() function
        '''
        self.new_user = User('Mag', 'Um', 'SGhhn20m')
        self.new_user.save_user()
        user1 = User('Mwiin', 'sick', 'SGhhn20m')
        user1.save_user()
        logged_in_user = ''

        for user in User.users_list:
            if user.fname == user1.fname and user.pword == user.pword:
                logged_in_user = user.fname
            return logged_in_user

            self.assertEqual(logged_in_user,
                             Credential.verify_user(user1.pword, user1.fname))
class TestCredential(unittest.TestCase):
    '''
    Test class that defines test cases for the credential class behaviours.
    Agrs:
        unittest.TestCase: TestCase class that helps in creating test cases 
    '''
    def setUp(self):
        '''
        Function to create an account's credentials before each test.
        '''
        self.new_credential = Credential("Glenn", "Instagram", "glennjoy",
                                         "oketch001")

    def tearDown(self):
        '''
        tearDown method that does clean up after case has run.
        '''
        Credential.credentials_list = []

    def test_init(self):
        '''
        To check if the object is initialized properly.
        '''
        self.assertEqual(self.new_credential.user_name, "Glenn")
        self.assertEqual(self.new_credential.site_name, "Instagram")
        self.assertEqual(self.new_credential.account_name, "glennjoy")
        self.assertEqual(self.new_credential.password, "oketch001")

    def test_save_credential(self):
        '''
        To check if the new credentials are saved into the credential list
        '''
        self.new_credential.save_credential()
        facebook = Credential("Bobby", "facebook", "bobbyjoe",
                              "bobby001")  #new credential
        facebook.save_credential()
        self.assertEqual(len(Credential.credentials_list), 2)

    def test_display_all_credentials(self):
        '''
        method that returns a list of all credentials saved.
        '''
        self.assertEqual(Credential.display_credentials(),
                         Credential.credentials_list)

    def test_find_by_site_name(self):
        '''
        Test to check if the find_by_site_name method returns the correct credentials
        '''
        self.new_credential.save_credential()
        test_credential = Credential("Bobby", "facebook", "bobbyjoe",
                                     "bobby001")  #new credential
        test_credential.save_credential()
        found_credential = Credential.find_by_site_name("facebook")
        self.assertEqual(found_credential.site_name, test_credential.site_name)

    # def test_generate_password(self):
    #     '''
    #     Test to generate a new password.
    #     '''
    #     self.new_credential.save_credential()
    #     gmail = Credential("Bobby","gmail","bobbyjoe","") #new credential
    #     gmail.save_credential()
    #     gen_password = gmail.password("")
    #     self.assertEqual(gen_password(),gmail.password)

    def test_copy_credential(self):
        '''
        Test to confirm that we are copying the account name from a found credential
        '''
        self.new_credential.save_credential()
        facebook = Credential("Bobby", "facebook", "bobbyjoe",
                              "bobby001")  #new credential
        facebook.save_credential()
        find_credential = None
        for credential in Credential.credentials_list:
            find_credential = Credential.find_by_site_name(
                credential.site_name)
            return pyperclip.copy(find_credential.password)
        Credential.copy_credential(self.new_credential.site_name)
        self.assertEqual("bobby001", pyperclip.paste())

    def test_check_user(self):
        '''
        function to test whether the log in function check_user work as expected
        '''
        self.new_user = User("Kernael", "Apuko", "oketch92")
        self.new_user.save_user()
        user2 = User("Mary", "Jane", "maryja01")
        user2.save_user()

        for user in User.users_list:
            if user.first_name == user2.first_name and user.password == user2.password:
                current_user = user.first_name
        return current_user

        self.assertEqual(current_user, (user2.password, user2.first_name))
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user = User("Kernael", "Apuko",
                          "oketch92")  #create user object
Exemplo n.º 12
0
def create_user(username, password):
    '''
    Function to create a new user with a username and password
    '''
    new_user = User(username, password)
    return new_user
Exemplo n.º 13
0
def create_user(username, password):
    new_user = User(username, password)
    return new_user
Exemplo n.º 14
0
class TestCredential(unittest.TestCase):
    '''
    Tests for credential class functions and methods.
    Args:
        unittest.TestCase: helps in creating test cases
    '''
    def test__init__(self):
        '''
        Test for the initialisation of the created credentials.
        '''
        self.assertEqual(self.new_credential.account_name, 'gmail')
        self.assertEqual(self.new_credential.user_name, 'mjones')
        self.assertEqual(self.new_credential.email, '*****@*****.**')
        self.assertEqual(self.new_credential.pword, 'SGhhn20m')

    def setUp(self):
        '''
        Set up function to run before each test cases.
        '''
        self.new_credential = Credential('gmail', 'mjones',
                                         '*****@*****.**', 'SGhhn20m')

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

    def test_verify_user(self):
        '''
        Test for the verify_user() function
        '''
        self.new_user = User('Mag', 'Um', 'SGhhn20m')
        self.new_user.save_user()
        user1 = User('Mwiin', 'sick', 'SGhhn20m')
        user1.save_user()
        logged_in_user = ''

        for user in User.users_list:
            if user.fname == user1.fname and user.pword == user.pword:
                logged_in_user = user.fname
            return logged_in_user

            self.assertEqual(logged_in_user,
                             Credential.verify_user(user1.pword, user1.fname))

    def test_save_credentials(self):
        '''
        Test for the saving of credentials.
        '''
        self.new_credential.save_credentials()
        instagram = Credential('Instagram', 'Mag', '*****@*****.**',
                               'SGhhn20m')
        instagram.save_credentials()
        self.assertEqual(len(Credential.credentials_list), 2)

    def test_show_credentials(self):
        '''
        Test for the show_credentials method.
        '''
        self.new_credential.save_credentials()
        instagram = Credential('Instagram', 'Mag', '*****@*****.**',
                               'SGhhn20m')
        instagram.save_credentials()
        github = Credential('github', 'Mag', '*****@*****.**',
                            'SGhhn20m')
        github.save_credentials()
        self.assertEqual(len(Credential.show_credentials(instagram.user_name)),
                         2)

    def test_find_account_info(self):
        '''
        Test to find account credentials by accountname.
        '''
        self.new_credential.save_credentials()
        instagram = Credential('Instagram', 'Mag', '*****@*****.**',
                               'SGhhn20m')
        instagram.save_credentials()
        credential_exists = Credential.find_account_info('Instagram')
        self.assertEqual(credential_exists, instagram)

    def test_copy_credential(self):
        '''
		Test to check if the copy a credential method copies the correct credential
		'''
        self.new_credential.save_credentials()
        instagram = Credential('Instagram', 'Mag', '*****@*****.**',
                               'SGhhn20m')
        instagram.save_credentials()
        find_credential = None
        for credential in Credential.user_credentials_list:
            find_credential = Credential.find_account_info(
                credential.account_name)
            return pyperclip.copy(find_credential.pword)
        Credential.copy_credential(self.new_credential.account_name)
        self.assertEqual('SGhhn20m', pyperclip.paste())
        print(pyperclip.paste())
Exemplo n.º 15
0
 def setUP(self):
     '''
     Function to create user account.
     '''
     self.new_user = User('Mag', 'Um', 'SGhhn20m')
Exemplo n.º 16
0
 def setUp(self):
     """
     Method that runs before each individual test methods run.
     """
     self.new_user = User('Abzed','Abzed1z0')
Exemplo n.º 17
0
def display_user():
    return User.display_user()
Exemplo n.º 18
0
def save_user(user):
    '''
    Function to save a new user account
    '''
    User.save_user(user)
Exemplo n.º 19
0
def sign_in(username, password):
    user_exists = User.user_exist(username, password)
    return user_exists
Exemplo n.º 20
0
def create_user(fname, lname, pword):
    '''
    Function to create a new user
    '''
    new_user = User(fname, lname, pword)
    return new_user
Exemplo n.º 21
0
 def setUp(self):
     self.new_user = User('Aoko','Mercy2x0')
Exemplo n.º 22
0
def sign_in(username, password):
    """
    function that checks whether a user exist and then login the user in.
    """
    user_exists = User.user_exist(username,password)
    return user_exists