def test_save_multiple_users(self): ''' test_save_multiple_users to check if we can save multiple users in our user_list ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") test_user.save_user() self.assertEqual(len(User.user_list), 2)
def test_user_exists(self): ''' test to check if we can return a Boolean if we don't find the user ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") test_user.save_user() user_exists = User.user_exists("Facebook") self.assertTrue(user_exists)
def test_log_in(self): """ Test if a user can log in to their account """ self.new_user.save_user() test_user = User('Peter', 'Max', 'RAJIV12345') test_user.save_user() found_credentials = User.log_in('Peter', 'Max', 'RAJIV12345') self.assertEqual(found_credentials, Credentials.credentials_list)
def test_user_exist(self): """ Test to figure out if a user exists """ self.new_user.save_user() test_user = User('Peter', 'Max', 'RAJIV12345') test_user.save_user() user_exists = User.user_exist('Peter') self.assertTrue(user_exists)
def test_delete_user(self): ''' test_delete_user to test if we can remove a user from object user_list ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") test_user.save_user() self.new_user.delete_user() self.assertEqual(len(User.user_list), 1)
def test_find_user_by_account(self): ''' test to check if we can find a user by account ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") test_user.save_user() found_user = User.find_by_account("Facebook") self.assertEqual(found_user.account, test_user.account)
class TestUser(unittest.TestCase): """ Class that definres all tests for various behaviours of the application """ def setUp(self): """ function that creates a new account before each test """ self.new_user = User('Peter', 'Max', 'RAJIV12345') def test__init__(self): """ Test that checks if formulation of new user instances is correctly done """ self.assertEqual(self.new_user.first_name, 'Peter') self.assertEqual(self.new_user.last_name, 'Max') self.assertEqual(self.new_user.password, 'RAJIV12345') def test_save_user(self): """ Test to check if user description has been added onto the list """ self.new_user.save_user() self.assertEqual(len(User.user_list), 3) def test_user_exist(self): """ Test to figure out if a user exists """ self.new_user.save_user() test_user = User('Peter', 'Max', 'RAJIV12345') test_user.save_user() user_exists = User.user_exist('Peter') self.assertTrue(user_exists) def test_display_user(self): """ Tests if a list of users saved cn be shown """ self.assertEqual(User.display_user(), User.user_list) def test_log_in(self): """ Test if a user can log in to their account """ self.new_user.save_user() test_user = User('Peter', 'Max', 'RAJIV12345') test_user.save_user() found_credentials = User.log_in('Peter', 'Max', 'RAJIV12345') self.assertEqual(found_credentials, Credentials.credentials_list)
class TestUser(unittest.TestCase): ''' Test class that defines tests for User class behaviours Args: unittest.TestCase: TestCase class that helps create test cases ''' def setUp(self): ''' Set up method to run before each test instance ''' self.new_user = User("Saudahabib", "Instagram", "trudet") # Instance of class User def test_init(self): ''' Test case to test if object is initialised properly ''' self.assertEqual(self.new_user.username, "Saudahabib") self.assertEqual(self.new_user.account, "Instagram") self.assertEqual(self.new_user.password, "trudet") def test_save_user(self): ''' test_save_user test case to test if the user object is saved to the user_list ''' self.new_user.save_user() self.assertEqual(len(User.user_list), 1) def tearDown(self): ''' tearDown does clear up after each test case has run ''' User.user_list = [] def test_save_multiple_users(self): ''' test_save_multiple_users to check if we can save multiple users in our user_list ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") 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 object user_list ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") test_user.save_user() self.new_user.delete_user() self.assertEqual(len(User.user_list), 1) def test_find_user_by_account(self): ''' test to check if we can find a user by account ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") test_user.save_user() found_user = User.find_by_account("Facebook") self.assertEqual(found_user.account, test_user.account) def test_user_exists(self): ''' test to check if we can return a Boolean if we don't find the user ''' self.new_user.save_user() test_user = User("Mulki Suleiman", "Facebook", "trudet") test_user.save_user() user_exists = User.user_exists("Facebook") self.assertTrue(user_exists) def test_display_all_users(self): ''' method that returns a list of all users saved ''' self.assertEqual(User.display_users(), User.user_list)
class TestUser(unittest.TestCase): ''' Test class that defines test cases for the contact 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.new_user = User("a.s.s.matic","Instagram","maurinesinami") def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_user.username,"a.s.s.matic") self.assertEqual(self.new_user.account,"Instagram") self.assertEqual(self.new_user.password,"maurinesinami") def test_save_user(self): ''' test_save_user test case to test if the user object is saved to the user_list ''' self.new_user.save_user() self.assertEqual(len(User.user_list),1) def tearDown(self): ''' tearDown does clear up after each test case has run ''' User.user_list = [] def test_save_multiple_users(self): ''' test_save_multiple_users to check if we can save multiple users in our user_list ''' self.new_user.save_user() test_user = User("polokoi", "Facebook", "trudet") 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 object user_list ''' self.new_user.save_user() test_user = User("polokoi", "Facebook", "trudet") test_user.save_user() self.new_user.delete_user() self.assertEqual(len(User.user_list),1) def test_find_user_by_account(self): ''' test to check if we can find a user by account ''' self.new_user.save_user() test_user = User("polokoi", "Facebook", "trudet") test_user.save_user() found_user = User.find_by_account("Facebook") self.assertEqual(found_user.account, test_user.account) def test_user_exists(self): ''' test to check if we can return a Boolean if we don't find the user ''' self.new_user.save_user() test_user = User("polokoi", "Facebook", "trudet") test_user.save_user() user_exists = User.user_exists("Facebook") self.assertTrue(user_exists) def test_display_all_users(self): ''' method that returns a list of all users saved ''' self.assertEqual(User.display_users(),User.user_list) def test_copy_password(self): ''' Test to confirm that we are copying the email address from a found contact ''' self.new_user.save_user() User.copy_password("trudent") self.assertEqual(self.new_user.password,pyperclip.paste())