import unittest
from user import User



class TestUser(unittest.TestCase):
    '''
    Defines test cases for the user class behaviours.

    Args:
        uniitest.TestCase: TestCase class helps in creating test cases
    '''

    def setUp(self):
        '''
        Set up method to run before each test cases.

        '''
        self.new_user = User("Sonia", "Habamba", "Habamba", "voila!")

    def test_init(self):
        '''
        Test if the object is initialized properly
        '''

        self.assertEqual(self.new_user.first_name, "Sonia")
        self.assertEqual(self.new_user.last_name, "Habamba")
        self.assertEqual(self.new_user.username, "Habamba")
        self.assertEqual(self.new_user.password, "<PASSWORD>!")

    def test_save_user(self):
        '''
        Tests if the user has been saved.
        '''
        self.new_user.save_user()
        self.assertEqual(len(User.user_list), 1)

    def test_user_exists(self):
        '''
        test to check if we can find the user.
        '''
        self.new_user.user_exists()
        test_user = User("Sonia", "Habamba", "Habamba","voila")
        test_user.save_user()


        self.assertTrue(User.user_exists('Sonia'))

    def test_display_all_contacts(self):
        '''
        Returns all users saved
        '''
        self.assertEqual(User.display_user(),User.user_list)    


if __name__ == '__main__':
    unittest.main()
import unittest
from user import User



class TestUser(unittest.TestCase):
    '''
    Defines test cases for the user class behaviours.

    Args:
        uniitest.TestCase: TestCase class helps in creating test cases
    '''

    def setUp(self):
        '''
        Set up method to run before each test cases.

        '''
        self.new_user = User("Sonia", "Habamba", "Habamba", "voila!")

    def test_init(self):
        '''
        Test if the object is initialized properly
        '''

        self.assertEqual(self.new_user.first_name, "Sonia")
        self.assertEqual(self.new_user.last_name, "Habamba")
        self.assertEqual(self.new_user.username, "Habamba")
        self.assertEqual(self.new_user.password, "<PASSWORD>!")

    def test_save_user(self):
        '''
        Tests if the user has been saved.
        '''
        self.new_user.save_user()
        self.assertEqual(len(User.user_list), 1)

    def test_user_exists(self):
        '''
        test to check if we can find the user.
        '''
        self.new_user.user_exists()
        test_user = User("Sonia", "Habamba", "Habamba","voila")
        test_user.save_user()


        self.assertTrue(User.user_exists('Sonia'))

    def test_display_all_contacts(self):
        '''
        Returns all users saved
        '''
        self.assertEqual(User.display_user(),User.user_list)    


if __name__ == '__main__':
    unittest.main()
Defines test cases for the user class behaviours.      Args:         uniitest.TestCase: TestCase class helps in creating test cases Set up method to run before each test cases. Test if the object is initialized properly Tests if the user has been saved. test to check if we can find the user. Returns all users saved