Esempio n. 1
0
class TestUser(unittest.TestCase):
    '''
    defining test cases for user
    Args:
        unittest.TestCase: it creates test cases
    '''
    def setUp(self):
        '''
        user account setup for testing each case
        '''
        self.n_user = User('Ben','Jackson','test01')

    # Test one
    def test__init__(self):
        '''
        test to check if user instances created follows the rule set
        '''
        self.assertEqual(self.n_user.f_name,'Ben')
        self.assertEqual(self.n_user.l_name,'Jackson')
        self.assertEqual(self.n_user.password,'test01')

    # Test two
    def test_save(self):
        '''
        Check if user details is saved
        '''
        self.n_user.save_user_details()
Esempio n. 2
0
class TestUser(unittest.TestCase):

    '''
    Test class that defines test cases for the user 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.user_details = User("jimmy","jim123")


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


        self.assertEqual(self.user_details.user_name,"jimmy")
        self.assertEqual(self.user_details.password,"jim123")

    def test_save_user(self):
        '''
        test_save_credentials test case to test if the credentials object is saved into
         the credentials list
        '''
        self.user_details.save_user() # saving the new credentials
        self.assertEqual(len(User.user_details),1)

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

# saving multiple users
    def test_save_multiple_user(self):
            '''
            test_save_multiple_credentials to check if we can save multiple credentials
            objects to our user_details
            '''
            self.user_details.save_user()
            test_user = User("jimmy","jim123") # new credentials
            test_user.save_user()
            self.assertEqual(len(User.user_details),2)



    def test_display_user(self):
        '''
        method that returns a list of all user saved
        '''

        self.assertEqual(User.display_user(),User.user_details)
Esempio n. 3
0
 def test_save_multiple_user(self):
         '''
         test_save_multiple_credentials to check if we can save multiple credentials
         objects to our user_details
         '''
         self.user_details.save_user()
         test_user = User("jimmy","jim123") # new credentials
         test_user.save_user()
         self.assertEqual(len(User.user_details),2)
class TestUser(unittest.TestCase):
    '''
    Test class that defines test cases for the user class behaviours.
    Args:
    unittest.TestCase: TestCase class that helps in creating test cases.
    '''
    def setUp(self):
        '''
        Method to run before test cases.
        '''
        self.new_user = User("Dolphine", "Atieno", "dolphine0123")

    def test__init__(self):
        '''
        Test case to see if the object is initialised properly.
        '''
        self.assertEqual(self.new_user.first_name, "Dolphine")
        self.assertEqual(self.new_user.last_name, "Atieno")
        self.assertEqual(self.new_user.password, "dolphine0123")

    def tearDown(self):
        '''
        A method that clears the users list after every test.
        '''
        User.users_list = []

    def test_save_user(self):
        '''
        Test case to confirm if user object is saved to the users list.
        '''
        self.new_user.save_user()
        self.assertEqual(len(User.users_list), 1)

    def test_check_user(self):
        '''
        Test whether login feature is functioning.
        '''
        self.new_user = User('Dolphine', 'Atieno', 'dolphine0123')
        self.new_user.save_user()
        user2 = User('Israel', 'Hawi', '@israel01')
        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,
                         User.check_user(user2, password, user2.first_name))
class TestUser(unittest.TestCase):
    def setUp(self):
        self.new_user = User("Rowena", "Rono", "1234")

    def test_init(self):
        self.assertEqual(self.new_user.first_name, "Rowena")
        self.assertEqual(self.new_user.second_name, "Rono")
        self.assertEqual(self.new_user.password, "1234")
        '''
        test_init_details user can add more than credential that is first name,secondname and password
        '''

    def test_save(self):
        self.new_user.signup()
        self.assertEqual(len(User.user), 1)
        '''
        test_save_details test case to test if the details are saved into
         the user list
        '''

    def test_sign_up(self):
        self.new_user.signup()
        self.assertEqual(len(User.user), 1)

    def test_login(self):
        self.assertTrue(self.new_user.first_name, 'Rowena')
        self.assertTrue(self.new_user.second_name, 'Rono')
        self.assertTrue(self.new_user.password, '1234')

    def test_login(self):
        self.new_user.login()
        self.assertEqual(len(User.user), 1)
        '''
        test_login if user can add more than one login details
        '''

    def test_delete(self):
        self.new_user.delete_cred()
        self.assertEqual(len(Credentials.user), 1)
        '''
        test_delete test to check is user can delete details

        '''

    def test_view(self):
        self.new_user.view()
        self.assertEqual(len(User.user), 1)
        '''
    def test_check_user(self):
        '''
        Test whether login feature is functioning.
        '''
        self.new_user = User('Dolphine', 'Atieno', 'dolphine0123')
        self.new_user.save_user()
        user2 = User('Israel', 'Hawi', '@israel01')
        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,
                         User.check_user(user2, password, user2.first_name))
Esempio n. 7
0
    def test_check_user(self):
        '''
        checking if the user credentials works
        '''
        self.n_user = User('Ben','Jackson','test01')
        self.n_user.save_user_details()

        user2 = User('Joe','Jackson','test01')
        user2.save_user_details()

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

        self.assertEqual(current_user,Details.check_user(user2.password,user2.f_name))
Esempio n. 8
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.user_details = User("jimmy","jim123")
Esempio n. 9
0
def create_user(fname, lname, password):
    '''
    Function creates a new user account.
    '''
    new_user = User(fname, lname, password)
    return new_user
Esempio n. 10
0
def verify_user(first_name,password):
    '''
    Function verify if user exist.
    '''
    checking_user = User.check_user(first_name, password)
    return checking_user
Esempio n. 11
0
def save_user(user):
    '''
    Function saves a new user.
    '''
    User.save_user(user)
 def setUp(self):
     self.new_user = User("Rowena", "Rono", "1234")
Esempio n. 13
0
def new_user(fname, lname, password):
    '''
    create new user
    '''
    n_user = User(fname, lname, password)
    return n_user
 def setUp(self):
     '''
     Method to run before test cases.
     '''
     self.new_user = User("Dolphine", "Atieno", "dolphine0123")
Esempio n. 15
0
class TestDetails(unittest.TestCase):
    '''
    test for user credentials

    Args:
        unittest.TestCase: it creates test cases
    '''

    # Test three
    def test_check_user(self):
        '''
        checking if the user credentials works
        '''
        self.n_user = User('Ben','Jackson','test01')
        self.n_user.save_user_details()

        user2 = User('Joe','Jackson','test01')
        user2.save_user_details()

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

        self.assertEqual(current_user,Details.check_user(user2.password,user2.f_name))


    def setUp(self):
        '''

        '''
        self.new_details = Details('Ben','Instagram','Benny','test01')

    def tearDown(self):
        '''

        '''
        Details.details_list = []
        User.users_list = []

    # Test four
    def test__init__(self):
        self.assertEqual(self.new_details.username, 'Ben')
        self.assertEqual(self.new_details.site, 'Instagram')
        self.assertEqual(self.new_details.account, 'Benny')
        self.assertEqual(self.new_details.password, 'test01')

    
    # Test five
    def test_save_details(self):
        '''

        '''
        self.new_details.save_details()
        facebook = Details('Joe','Facebook','Benny','test01')
        facebook.save_details()
        self.assertEqual(len(Details.details_list),2)

    
    # Test six
    def test_display_details(self):
        '''

        '''
        self.new_details.save_details()
        facebook = Details('Ben','Facebook','Benny','test01')
        facebook.save_details()
        twitter = Details('Ben','Twitter','Benny','test01')
        twitter.save_details()
        # self.assertEqual(len(Details.display_details(facebook.username)),2)

    # Test seven
    def test_find_by_site_name(self):
        '''

        '''
        self.new_details.save_details()
        facebook = Details('Ben','Facebook','Benny','test01')
        facebook.save_details()
        details_exists = Details.find_by_site_name('Facebook')
        self.assertEqual(details_exists,facebook)


    # Test eight
    def test_copy_details(self):
        '''

        '''
        self.new_details.save_details()
        facebook = Details('Ben','Facebook','Benny','test01')
        facebook.save_details()
        find_details = None
        for details in Details.user_details_list:
            find_details=Details.find_by_site_name(details.site)
            return pyperclip.copy(find_details.password)
        Details.copy_details(self.new_details.site)
        self.assertEqual('test01',pyperclip.paste())
        print(pyperclip.paste())
Esempio n. 16
0
 def setUp(self):
     '''
     user account setup for testing each case
     '''
     self.n_user = User('Ben','Jackson','test01')
Esempio n. 17
0
    def test_display_user(self):
        '''
        method that returns a list of all user saved
        '''

        self.assertEqual(User.display_user(),User.user_details)
Esempio n. 18
0
def save_user(user):
    '''
    save new user account
    '''
    User.save_user_details(user)