class TestUser(unittest.TestCase):
    '''
    TestUser class to define test cases for the user class behaviours
    '''
    def setUp(self):
        '''
        setUp method to run before each test cases
        '''
        self.new_user = User('Carine','hideme') # Create user object
    #The end!
    
    def test_init(self):
        '''
        test_init to test if the object is initialized properly
        '''
        self.assertEqual(self.new_user.username,'Carine')
        self.assertEqual(self.new_user.password,'hideme')
    #The End!
    
    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.save_user()
        self.assertEqual(len(User.user_list),1)
예제 #2
0
 def test_user_exists(self):
     '''
     test to check if we can return a Boolean  if we cannot find the user.
     '''
     self.new_user.save_user()
     test_user = User('2','Anne','Boleyn')
     test_user.save_user()
     user_exists = User.user_exists('2') 
     self.assertTrue(user_exists)
예제 #3
0
 def test_find_user_by_idNumber(self):
     '''
     test to check if we can find a user by id number and display information
     '''
     self.new_user.save_user()
     test_user = User('2','Ferdinand','Isabella')
     test_user.save_user()
     found_user = User.find_by_idNumber('2')
     self.assertEqual(found_user.user,test_user.user)      
예제 #4
0
 def test_delete_user(self):
     '''
     test_delete_user to test if we can remove a user from our user list
     '''
     self.new_user.save_user()
     test_user = User('3','Pope','Clement')
     test_user.save_user()
     self.new_user.delete_user()
     self.assertEqual(len(User.user_list), 1)
예제 #5
0
 def test_save_multiple_user(self):
     '''
     test_save_multiple_user to check if we can save multiple user
     objects to our user_list
     '''
     self.new_user.save_user()
     test_user = User('2','Mary','Aragon')
     test_user.save_user()
     self.assertEqual(len(User.user_list),2)
예제 #6
0
 def test_user_matches(self):
     '''
     test to check if we can return a Boolean  if we cannot match username && password.
     '''
     self.new_user.save_user()
     test_user = User('2','Anne','Boleyn')
     test_user.save_user()
     user_matches = User.match_user_password('Anne','Boleyn')
     self.assertTrue(user_matches)
예제 #7
0
 def test_save_multiple_users(self):
     '''
     test case to check if we can save multiple user
     objects to our users_list
     '''
     self.new_user.save_user()
     test_user = User("Test", "unlock")
     test_user.save_user()
     self.assertEqual(len(User.users_list), 2)
예제 #8
0
def create_user(username,password):

    '''
    Function to create a new user
    '''
    new_user = User(username,password)
    return new_user
예제 #9
0
class TestClassUser(unittest.TestCase):
    """
    A Test class that defines test cases for the User class.
    """
    def setUp(self):
        self.new_user = User("uwase-diane", "@August2016")
        """
        Method that runs before each individual test methods run.
        """

    def test_init(self):
        """
        test case to chek if the object has been initialized correctly
        """

        self.assertEqual(self.new_user.userName, 'uwase-diane')
        self.assertEqual(self.new_user.password, '@August2016')

    def test_save_user(self):
        """
        test case to test if a new user instance has been saved into the User list
        """
        self.new_user.save_user()
        self.assertEqual(len(User.user_list), 1)
예제 #10
0
def find_users(user):
    return User.users_list(user)
예제 #11
0
class TestLocker(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 tearDown(self):
        '''
        tearDown method to clean up after each test case has run.
        '''
        User.users_list = []

    def save_user(self):
        User.users_list.append(self)

    def setUp(self):
        '''
        method to run before each test cases.
        '''
        self.new_user = User("Jamesnduge", "tj193345")

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

        self.assertEqual(self.new_user.username, "Jamesnduge")
        self.assertEqual(self.new_user.password, "tj193345")

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

    def test_save_multiple_users(self):
        '''
        test case to check if we can save multiple user
        objects to our users_list
        '''
        self.new_user.save_user()
        test_user = User("Test", "unlock")
        test_user.save_user()
        self.assertEqual(len(User.users_list), 2)

    def test_display_all_users(self):
        '''
        method that returns a list of all accounts saved
        '''

        self.assertEqual(User.display_users(), User.users_list)

    def tearDown2(self):
        '''
        tearDown method to clean up after each test case has run.
        '''
        Credentials.accounts_list = []

    def setUp2(self):
        '''
        method to run before each test cases of Credentials.
        '''
        self.new_account = Credentials("Twitter", "darknight", "unlock")

    def test_init2(self):
        '''
        test case to test if the object is initialized properly
        '''
        self.new_account = Credentials("Twitter", "darknight", "unlock")

        self.assertEqual(self.new_account.account_name, "Twitter")
        self.assertEqual(self.new_account.user_name, "darknight")
        self.assertEqual(self.new_account.key, "unlock")

    def test_display_all_accounts(self):
        '''
        method that returns a list of all accounts saved
        '''

        self.assertEqual(Credentials.display_accounts(),
                         Credentials.accounts_list)

    def test_generate_password(self):
        '''
        method that returns a list of all accounts saved
        '''
        self.twitter = Credentials('Twitter', 'maryjoe', '')
        self.twitter.password = Credentials.generate_password(8)
        self.assertEqual(len(Credentials.generate_password(8)), 8)
예제 #12
0
 def setUp(self):
     '''
     method to run before each test cases.
     '''
     self.new_user = User("Jamesnduge", "tj193345")
 def setUp(self):
     '''
     setUp method to run before each test cases
     '''
     self.new_user = User('Carine','hideme') # Create user object
예제 #14
0
class TestUser(unittest.TestCase):
    '''
    Test class that  defines test cases for the user class behaviours.
    '''
    
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_user = User('1','Junius','Brutus') # create user object
                             
    def tearDown(self):
        '''
        tearDown method that does clean up after each test case has run.
        '''
        User.user_list = []
        
    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_user.id,'1')
        self.assertEqual(self.new_user.user,'Junius')
        self.assertEqual(self.new_user.psw,'Brutus')

    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.save_user() # saving the new user
        self.assertEqual(len(User.user_list),1)
        
    def test_save_multiple_user(self):
        '''
        test_save_multiple_user to check if we can save multiple user
        objects to our user_list
        '''
        self.new_user.save_user()
        test_user = User('2','Mary','Aragon')
        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 our user list
        '''
        self.new_user.save_user()
        test_user = User('3','Pope','Clement')
        test_user.save_user()
        self.new_user.delete_user()
        self.assertEqual(len(User.user_list), 1)
        
    def test_find_user_by_idNumber(self):
        '''
        test to check if we can find a user by id number and display information
        '''
        self.new_user.save_user()
        test_user = User('2','Ferdinand','Isabella')
        test_user.save_user()
        found_user = User.find_by_idNumber('2')
        self.assertEqual(found_user.user,test_user.user)      
            
    def test_user_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the user.
        '''
        self.new_user.save_user()
        test_user = User('2','Anne','Boleyn')
        test_user.save_user()
        user_exists = User.user_exists('2') 
        self.assertTrue(user_exists)
    
    def test_user_matches(self):
        '''
        test to check if we can return a Boolean  if we cannot match username && password.
        '''
        self.new_user.save_user()
        test_user = User('2','Anne','Boleyn')
        test_user.save_user()
        user_matches = User.match_user_password('Anne','Boleyn')
        self.assertTrue(user_matches)
    
    def test_display_all_users(self):
        '''
        method that returns a list of all users saved
        '''
        self.assertEqual(User.display_users(),User.user_list)
예제 #15
0
def display_user():
    """
    Function to display existing user
    """
    return User.display_user()
예제 #16
0
def create_user(username, password):
    '''
    create_user method to create a new user
    '''
    new_user = User(username, password)
    return new_user
예제 #17
0
def display_user():
    """
    display_user method to display an existing user
    """
    return User.display_user()
예제 #18
0
    def test_display_all_users(self):
        '''
        method that returns a list of all accounts saved
        '''

        self.assertEqual(User.display_users(), User.users_list)
예제 #19
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user = User('1','Junius','Brutus') # create user object
예제 #20
0
 def setUp(self):
   '''
   Set up method that runs before each taste case, creating the results we expect.
   '''
   self.new_account = User("David","boot")
   self.new_application = Credentials("Facebook", "word")
예제 #21
0
def user_authentication(username, password):
    '''
  Function to authenticate users.
  '''
    return User.username_authentication(username, password)
예제 #22
0
def signin_user(username, password):
    """
    signin_user method to check a user and then sign in they exist
    """
    check_user = User.user_check_me(username, password)
    return check_user
예제 #23
0
def create_account(user_name, user_password):
    '''
  Function to create a new account.
  '''
    new_account = User(user_name, user_password)
    return new_account
예제 #24
0
def login_user(username, password):
    '''
    Function that returns all the saved users
    '''
    return User.match_user_password(username, password)
예제 #25
0
 def setUp(self):
     self.new_user = User("uwase-diane", "@August2016")
     """