def test_save_multiple_users(self):
     '''
     test if multiple user objects have been saved in user_list
     '''
     self.new_user.save_user()
     test_user = Users(2, "Mbugua", "gitu", 467587)
     test_user.save_user()
     self.assertEqual(len(Users.user_list), 2)
 def test_check_display_users(self):
     '''
     test to check if all users in user_list are displayed
     '''
     self.new_user.save_user()
     test_user = Users(2, "Mbugua", "gitu", 467587)
     test_user.save_user()
     self.assertEqual(Users.display_users(), Users.user_list)
 def test_check_authenticate_user(self):
     '''
     test to authenticate user
     '''
     self.new_user.save_user()
     test_user = Users(2, "Mbugua", "gitu", 467587)
     test_user.save_user()
     user_authenticated = Users.authenticate_user(1, "nish", 12345)
     self.assertTrue(user_authenticated)
 def test_check_user_existence(self):
     '''
     test to check if user exists in user_list
     '''
     self.new_user.save_user()
     test_user = Users(2, "Mbugua", "gitu", 467587)
     test_user.save_user()
     user_exists = Users.check_user_existence(2)
     self.assertTrue(user_exists)
 def test_find_user_by_id(self):
     '''
     test to ensure we can find a user by their ID and access their details
     '''
     self.new_user.save_user()
     test_user = Users(2, "Mbugua", "gitu", 467587)
     test_user.save_user()
     search_user = Users.find_user_by_id(2)
     self.assertEqual(search_user.username, test_user.username)
 def setUp(self):
     self.new_user = Users(1, "Virginia", "nish", 12345)
     self.new_account = Credentials(
         1, "Github", "*****@*****.**", "VirginiaNdungu1", "xyz123")
 def setUp(self):
     self.new_user = Users(1, "Virginia", "nish", 12345)
class TestPwdUsers(unittest.TestCase):
    def setUp(self):
        self.new_user = Users(1, "Virginia", "nish", 12345)

    def test_init(self):
        '''
        test if User Object has been properly initialised
        '''
        self.assertEqual(self.new_user.user_id, 1)
        self.assertEqual(self.new_user.fullname, "Virginia")
        self.assertEqual(self.new_user.username, "nish")
        self.assertEqual(self.new_user.user_password, 12345)

    def test_save_user(self):
        '''
        test if User object has been saved in user_list
        '''
        self.new_user.save_user()
        self.assertEqual(len(Users.user_list), 1)

    def tearDown(self):
        '''
        tearDown cleans up after each test case runs
        '''
        Users.user_list = []

    def test_save_multiple_users(self):
        '''
        test if multiple user objects have been saved in user_list
        '''
        self.new_user.save_user()
        test_user = Users(2, "Mbugua", "gitu", 467587)
        test_user.save_user()
        self.assertEqual(len(Users.user_list), 2)

    def test_find_user_by_id(self):
        '''
        test to ensure we can find a user by their ID and access their details
        '''
        self.new_user.save_user()
        test_user = Users(2, "Mbugua", "gitu", 467587)
        test_user.save_user()
        search_user = Users.find_user_by_id(2)
        self.assertEqual(search_user.username, test_user.username)

    def test_check_user_existence(self):
        '''
        test to check if user exists in user_list
        '''
        self.new_user.save_user()
        test_user = Users(2, "Mbugua", "gitu", 467587)
        test_user.save_user()
        user_exists = Users.check_user_existence(2)
        self.assertTrue(user_exists)

    def test_check_authenticate_user(self):
        '''
        test to authenticate user
        '''
        self.new_user.save_user()
        test_user = Users(2, "Mbugua", "gitu", 467587)
        test_user.save_user()
        user_authenticated = Users.authenticate_user(1, "nish", 12345)
        self.assertTrue(user_authenticated)

    def test_check_display_users(self):
        '''
        test to check if all users in user_list are displayed
        '''
        self.new_user.save_user()
        test_user = Users(2, "Mbugua", "gitu", 467587)
        test_user.save_user()
        self.assertEqual(Users.display_users(), Users.user_list)
def create_users(user_id, fullname, username, user_password):
    new_user = Users(user_id, fullname, username, user_password)
    return new_user
def display_all_users():
    return Users.display_users()
def authenticate_users(user_id, username, user_password):
    return Users.authenticate_user(user_id, username, user_password)
def check_users(user_id):
    return Users.check_user_existence(user_id)
def find_user(user_id):
    return Users.find_user_by_id(user_id)