class TestContact(unittest.TestCase):
    '''
    Test class that defines the test cases for the the user class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    '''
    def setUp(self):
        '''
        Setup method to run before each test case 
        '''
        self.new_user = User('Joseph', 'Adediji', '123456')

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

        self.assertEqual(self.new_user.first_name, "Joseph")
        self.assertEqual(self.new_user.last_name, "Adediji")
        self.assertEqual(self.new_user.password, "123456")

    def test_save_user(self):
        '''
		Test to check if the new users info is saved into the users list
		'''
        self.new_user.save_user()
        self.assertEqual(len(User.users_list), 1)

    def tearDown(self):
        '''
            tearDown method that does clean up after each test case has run.
            '''
        User.users_list = []
Exemple #2
0
 def test_save_multiple_user(self):
     '''
   check if we can hold multiple user accounts
   '''
     self.new_user.save_user()
     test_user = User("andrew", "password")
     test_user.save_user()
     self.assertEqual(len(User.user_list), 2)
Exemple #3
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("michael", "password")
        test_user.save_user()

        self.new_user.delete_user()
        self.assertEqual(len(User.user_list), 1)
    def test_save_multiple_user(self):
        '''
         to check if we can save multiple user
        objects to our contact_list
        '''

        self.new_user.save_user()
        test_user = User("test", "user", "babigando")  # new contact
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)
    def test_user_check(self):
        '''
		Function to test whether the function for user log in works user_check
		'''
        self.new_user = User("joseph", "Karanja", "yousahaud")
        self.new_user.save_user()
        user2 = User("michael", "cheng", "burudika")
        user2.save_user()

        for user in User.user_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,
                    Credential.check_user(user2.password, user2.first_name))
class TestUserCred(unittest.TestCase):
    '''
    test to test for credentials and their respective behaviours self.

    args:
    unittest.TestCase: helps create test caseself
    '''
    def test_user_check(self):
        '''
		Function to test whether the function for user log in works user_check
		'''
        self.new_user = User("joseph", "Karanja", "yousahaud")
        self.new_user.save_user()
        user2 = User("michael", "cheng", "burudika")
        user2.save_user()

        for user in User.user_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,
                    Credential.check_user(user2.password, user2.first_name))

    def setUp(self):
        '''
        Function that creates a default account's credentials before each test
        '''
        self.new_credential = Credential("niklaus", "instagram", "Klausmnoma",
                                         "sikupei")

    def test_init_(self):
        '''
        test to check if credential instances have been initialized well
        '''
        self.assertEqual(self.new_credential.user_name, "niklaus")
        self.assertEqual(self.new_credential.site_name, "instagram")
        self.assertEqual(self.new_credential.account_name, "klausmnoma")
        self.assertEqual(self.new_credential.password, "niklaus")
class TestUser(unittest.TestCase):
    def setUp(self):
        '''
        set up method to run before each test caseself.
        '''
        self.new_user = User("klaus", "peter",
                             "abracadabra")  #creates new object

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

        self.assertEqual(self.new_user.first_name, "klaus")
        self.assertEqual(self.new_user.last_name, "peter")
        self.assertEqual(self.new_user.password, "abracadabra")

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

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

    def test_save_multiple_user(self):
        '''
         to check if we can save multiple user
        objects to our contact_list
        '''

        self.new_user.save_user()
        test_user = User("test", "user", "babigando")  # new contact
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)
Exemple #8
0
class TestUser(unittest.TestCase):
    '''
   Test class that checks the behaviours of the User class.
   '''
    def setUp(self):

        self.new_user = User("michael", "password")  # create user object

    def test_init(self):

        self.assertEqual(self.new_user.username, "michael")
        self.assertEqual(self.new_user.password, "password")

    def test_save_user(self):

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

    def tearDown(self):
        '''
      this will clean up after each test run.
      '''
        User.user_list = []

    def test_save_multiple_user(self):
        '''
      check if we can hold multiple user accounts
      '''
        self.new_user.save_user()
        test_user = User("andrew", "password")
        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("michael", "password")
        test_user.save_user()

        self.new_user.delete_user()
        self.assertEqual(len(User.user_list), 1)
Exemple #9
0
def save_user(user):
    '''
	function saves new vault user.
	'''
    User.save_user(user)
def save_user(user):
	'''
	Function to save a new user account
	'''
	User.save_user(user)
Exemple #11
0
def saveUser(user):
    '''
    function that saves new user account instance
    '''
    User.save_user(user)
Exemple #12
0
def save_user(user):
    '''
   Saves created credentials
   '''
    User.save_user(user)