Beispiel #1
0
def log_in(first_name, last_name, password):
    """
    Function that enables the user to log into his account
    """
    log_in == User.log_in(first_name, last_name, password)
    if log_in != False:
        return User.log_in(first_name, last_name, password)
 def test_log_in(self):
     """
     Test if a user can log in to their account
     """
     self.new_user.save_user()
     test_user = User('Peter', 'Max', 'RAJIV12345')
     test_user.save_user()
     found_credentials = User.log_in('Peter', 'Max', 'RAJIV12345')
     self.assertEqual(found_credentials, Credentials.credentials_list)
 def test_user_exist(self):
     """
     Test to figure out if a user exists
     """
     self.new_user.save_user()
     test_user = User('Peter', 'Max', 'RAJIV12345')
     test_user.save_user()
     user_exists = User.user_exist('Peter')
     self.assertTrue(user_exists)
Beispiel #4
0
    def test_copy_password(self):
        '''
        Test to confirm that we are copying the email address from a found contact
        '''

        self.new_user.save_user()
        User.copy_password("trudent")

        self.assertEqual(self.new_user.password,pyperclip.paste())
 def test_user_exists(self):
     '''
     test to check if we can return a Boolean if we don't find the user
     '''
     self.new_user.save_user()
     test_user = User("Mulki Suleiman", "Facebook", "trudet")
     test_user.save_user()
     user_exists = User.user_exists("Facebook")
     self.assertTrue(user_exists)
    def test_save_multiple_users(self):
        '''
        test_save_multiple_users to check if we can save multiple users in our user_list
        '''

        self.new_user.save_user()
        test_user = User("Mulki Suleiman", "Facebook", "trudet")
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)
    def test_delete_user(self):
        '''
        test_delete_user to test if we can remove a user from object user_list
        '''
        self.new_user.save_user()
        test_user = User("Mulki Suleiman", "Facebook", "trudet")
        test_user.save_user()

        self.new_user.delete_user()
        self.assertEqual(len(User.user_list), 1)
    def test_find_user_by_account(self):
        '''
        test to check if we can find a user by account
        '''

        self.new_user.save_user()
        test_user = User("Mulki Suleiman", "Facebook", "trudet")
        test_user.save_user()

        found_user = User.find_by_account("Facebook")
        self.assertEqual(found_user.account, test_user.account)
class TestUser(unittest.TestCase):
    """
    Class that definres all tests for various behaviours of the application
    """
    def setUp(self):
        """
        function that creates a new account before each test
        """
        self.new_user = User('Peter', 'Max', 'RAJIV12345')

    def test__init__(self):
        """
        Test that checks if formulation of new user instances is correctly done
        """
        self.assertEqual(self.new_user.first_name, 'Peter')
        self.assertEqual(self.new_user.last_name, 'Max')
        self.assertEqual(self.new_user.password, 'RAJIV12345')

    def test_save_user(self):
        """
        Test to check if user description has been added onto the list
        """
        self.new_user.save_user()
        self.assertEqual(len(User.user_list), 3)

    def test_user_exist(self):
        """
        Test to figure out if a user exists
        """
        self.new_user.save_user()
        test_user = User('Peter', 'Max', 'RAJIV12345')
        test_user.save_user()
        user_exists = User.user_exist('Peter')
        self.assertTrue(user_exists)

    def test_display_user(self):
        """
        Tests if a list of users saved cn be shown
        """
        self.assertEqual(User.display_user(), User.user_list)

    def test_log_in(self):
        """
        Test if a user can log in to their account
        """
        self.new_user.save_user()
        test_user = User('Peter', 'Max', 'RAJIV12345')
        test_user.save_user()
        found_credentials = User.log_in('Peter', 'Max', 'RAJIV12345')
        self.assertEqual(found_credentials, Credentials.credentials_list)
Beispiel #10
0
def create_user(first_name, last_name, password):
    """
    Function that facilitates the cretion of new users
    """
    new_user = User(first_name, last_name, password)
    return new_user
 def test_display_user(self):
     """
     Tests if a list of users saved cn be shown
     """
     self.assertEqual(User.display_user(), User.user_list)
Beispiel #12
0
def create_new_user(username, password):
    '''
    Function to create an instance of a user
    '''
    new_user = User(username, password)
    return new_user
Beispiel #13
0
def display_user():
    """
    Function to display existing users
    """
    return User.display_user()
 def test_display_all_users(self):
     '''
     method that returns a list of all users saved
     '''
     self.assertEqual(User.display_users(), User.user_list)
Beispiel #15
0
class TestUser(unittest.TestCase):

    '''
    Test class that defines test cases for the contact 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_user =  User("a.s.s.matic","Instagram","maurinesinami")

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

        self.assertEqual(self.new_user.username,"a.s.s.matic")
        self.assertEqual(self.new_user.account,"Instagram")
        self.assertEqual(self.new_user.password,"maurinesinami")
    def test_save_user(self):
        '''
        test_save_user test case to test if the user object is saved to the user_list
        '''
        self.new_user.save_user()
        self.assertEqual(len(User.user_list),1)
    def tearDown(self):
        '''
        tearDown does clear up after each test case has run
        '''
        User.user_list = []
    def test_save_multiple_users(self):
        '''
        test_save_multiple_users to check if we can save multiple users in our user_list
        '''

        self.new_user.save_user()
        test_user = User("polokoi", "Facebook", "trudet")
        test_user.save_user()
        self.assertEqual(len(User.user_list),2)
    def test_delete_user(self):
        '''
        test_delete_user to test if we can remove a user from object user_list
        '''
        self.new_user.save_user()
        test_user = User("polokoi", "Facebook", "trudet")
        test_user.save_user()

        self.new_user.delete_user()
        self.assertEqual(len(User.user_list),1)
    def test_find_user_by_account(self):
        '''
        test to check if we can find a user by account
        '''

        self.new_user.save_user()
        test_user = User("polokoi", "Facebook", "trudet")
        test_user.save_user()

        found_user = User.find_by_account("Facebook")
        self.assertEqual(found_user.account, test_user.account)
    def test_user_exists(self):
        '''
        test to check if we can return a Boolean if we don't find the user
        '''
        self.new_user.save_user()
        test_user = User("polokoi", "Facebook", "trudet")
        test_user.save_user()
        user_exists = User.user_exists("Facebook")
        self.assertTrue(user_exists)

    def test_display_all_users(self):
        '''
        method that returns a list of all users saved
        '''
        self.assertEqual(User.display_users(),User.user_list)
    def test_copy_password(self):
        '''
        Test to confirm that we are copying the email address from a found contact
        '''

        self.new_user.save_user()
        User.copy_password("trudent")

        self.assertEqual(self.new_user.password,pyperclip.paste())
Beispiel #16
0
def display_users():
    '''
    Function that returns all saved users
    '''
    return User.display_users()
Beispiel #17
0
def find_user(account):
    '''
    Function that finds a user by account name and returns the  user
    '''
    return User.find_by_account(account)
 def setUp(self):
     '''
     Set up method to run before each test instance
     '''
     self.new_user = User("Saudahabib", "Instagram",
                          "trudet")  # Instance of class User
 def setUp(self):
     """
     function that creates a new account before each test
     """
     self.new_user = User('Peter', 'Max', 'RAJIV12345')
Beispiel #20
0
def check_existing_user(account):
    '''
    Function that checks if a user exists with that account and returns Boolean
    '''
    return User.user_exists(account)
class TestUser(unittest.TestCase):
    '''
    Test class that defines tests for User class behaviours
    Args:
        unittest.TestCase: TestCase class that helps create test cases
    '''
    def setUp(self):
        '''
        Set up method to run before each test instance
        '''
        self.new_user = User("Saudahabib", "Instagram",
                             "trudet")  # Instance of class User

    def test_init(self):
        '''
        Test case to test if object is initialised properly
        '''
        self.assertEqual(self.new_user.username, "Saudahabib")
        self.assertEqual(self.new_user.account, "Instagram")
        self.assertEqual(self.new_user.password, "trudet")

    def test_save_user(self):
        '''
        test_save_user test case to test if the user object is saved to the user_list
        '''
        self.new_user.save_user()
        self.assertEqual(len(User.user_list), 1)

    def tearDown(self):
        '''
        tearDown does clear up after each test case has run
        '''
        User.user_list = []

    def test_save_multiple_users(self):
        '''
        test_save_multiple_users to check if we can save multiple users in our user_list
        '''

        self.new_user.save_user()
        test_user = User("Mulki Suleiman", "Facebook", "trudet")
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)

    def test_delete_user(self):
        '''
        test_delete_user to test if we can remove a user from object user_list
        '''
        self.new_user.save_user()
        test_user = User("Mulki Suleiman", "Facebook", "trudet")
        test_user.save_user()

        self.new_user.delete_user()
        self.assertEqual(len(User.user_list), 1)

    def test_find_user_by_account(self):
        '''
        test to check if we can find a user by account
        '''

        self.new_user.save_user()
        test_user = User("Mulki Suleiman", "Facebook", "trudet")
        test_user.save_user()

        found_user = User.find_by_account("Facebook")
        self.assertEqual(found_user.account, test_user.account)

    def test_user_exists(self):
        '''
        test to check if we can return a Boolean if we don't find the user
        '''
        self.new_user.save_user()
        test_user = User("Mulki Suleiman", "Facebook", "trudet")
        test_user.save_user()
        user_exists = User.user_exists("Facebook")
        self.assertTrue(user_exists)

    def test_display_all_users(self):
        '''
        method that returns a list of all users saved
        '''
        self.assertEqual(User.display_users(), User.user_list)
Beispiel #22
0
def create_user(username, account, password):
    '''
    Function to create a new user
    '''
    new_user = User(username, account, password)
    return new_user
Beispiel #23
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user =  User("a.s.s.matic","Instagram","maurinesinami")