def test_save_multiple_credentials(self): self.new_credentials.save_credentials() test_credentials = Credentials("test","testusername","testpassword") test_credentials.save_credentials() # new credentilas self.assertEqual(len(Credentials.credentials_List),2)
class TestCredentials(unittest.TestCase): def setUp(self): self.new_user = Credentials(1, "Dan", "programmer") def tearDown(self): Credentials.users_list = [] def test_init(self): self.assertEqual(self.new_user.identify, 1) self.assertEqual(self.new_user.user_name, "Dan") self.assertEqual(self.new_user.password, "programmer") def test_create(self): self.new_user.create_account() self.assertEqual(len(Credentials.users_list), 1) def test_authenticate(self): self.new_user.create_account() test_account = Credentials(1, "Test", "Password") test_account.create_account() found_user = Credentials.authenticate_account("Test", "Password") self.assertEqual(found_user.identify, test_account.identify)
class TestCredentials(unittest.TestCase): ''' Class to test application's credentails behaviour ''' def setUp(self): ''' Set's up variable to be used ''' self.new_user = Credentials("minion", "123456") self.existing_user = Credentials("iris", "12345678") def test_user_login(self): ''' Test to see if a user can login in ''' self.assertEqual(self.new_user.username, "minion") self.assertEqual(self.new_user.password, "123456") def test_save_user(self): ''' Test to see if new user is being saved ''' self.new_user.save_user() self.assertEqual(len(Credentials.login_details), 1) '''
def setUp(self): """ Method that runs before each individual test methods run. """ self.user = User('WangechiKimani', '123Pass') self.credentials = Credentials('instagram', 'WangechiKimani', '123Pass')
def setUp(self): ''' Set's up variable to be used ''' self.new_user = Credentials("minion", "123456") self.existing_user = Credentials("iris", "12345678")
def test_save_many_accounts(self): ''' test to check if we can save multiple credentials objects to our credentials list ''' self.new_credential.save_details() test_credential = Credentials("instagram", "feistydory", "qwerty") test_credential.save_details() self.assertEqual(len(Credentials.credentials_list), 2)
def setUp(self): ''' Set Up method to run before each test cases. ''' self.new_user = User("Derrick", "Kariuki", "0718016066", "*****@*****.**") # creates user object self.new_account = Credentials( "Instagram", "dero1234") # creates credentials object
def test_authenticate(self): self.new_user.create_account() test_account = Credentials(1, "Test", "Password") test_account.create_account() found_user = Credentials.authenticate_account("Test", "Password") self.assertEqual(found_user.identify, test_account.identify)
def test_save_many_accounts(self): """ test to check if we can save multiple credentials objects to our credentials list """ self.credentials.save_credential() test_credential = Credentials("Twitter", "WangechiKimani", "123Pass") test_credential.save_credential() self.assertGreater(len(Credentials.credentials_list), 1)
def test_credential_exist(self): ''' test to check if we can return a boolean based on whether we can or can't find the credential. ''' self.new_credential.save_details() get_credential = Credentials("instagram", "feistydory", "qwerty") get_credential.save_details() credential_is_found = Credentials.if_credential_exist("instagram") self.assertTrue(credential_is_found)
def test_delete_credentials(self): self.new_credentials.save_credentials() test_credentials = Credentials("test","testusername","testpassword") test_credentials.save_credentials() self.new_credentials.delete_credentials()#del credentils self.assertEqual(len(Credentials.credentials_List),1)
def test_save_multiple_account(self): ''' test_save_multiple_account to check if we can save multiple account objects to our account_list ''' self.new_account.save_account() test_account = Credentials("Test", "account12") # the new account test_account.save_account() self.assertEqual(len(Credentials.account_list), 2)
def test_authenticate(self): ''' Testing to check if the authenticate function can sign in a user properly ''' self.new_user.create_account() test_account = Credentials(1, "Test", "Password") test_account.create_account() found_user = Credentials.authenticate_account("Test", "Password") self.assertEqual(found_user.identify, test_account.identify)
def test_delete_credential(self): ''' test method to test if we can remove an account credentials from our credentials_list ''' self.new_credential.save_details() test_credential = Credentials("instagram", "feistydory", "qwerty") test_credential.save_details() self.new_credential.delete_credentials() self.assertEqual(len(Credentials.credentials_list), 1)
def find_credentials_by_account_name(self): self.new_credentials.save_credentials() test_credentials = Credentials("test","testusername","testpassword") test_credentials.save_credentials found_credentials = Credentials.find_by_account_name("test") self.assertEqual(found_credentials.testusername,test_credentials.testusername)
def test_find_credential(self): ''' test to check if we can find a credential entry by account name and display the details of the credential ''' self.new_credential.save_details() test_credential = Credentials("instagram", "feistydory", "qwerty") test_credential.save_details() get_credential = Credentials.find_credential("instagram") self.assertEqual(get_credential.account, test_credential.account)
def test_credentials_exists(self): ''' returns boolean if credentials not found test ''' self.new_credentials.save_credentials() test_credentials = Credentials("test","testusername","testpassword") test_credentials.save_credentials() credentials_exists = Credentials.credentials_exist("test") self.assertTrue(credentials_exists)
def test_delete_account(self): ''' test_delete_account to test if we can remove an account from our account list ''' self.new_account.save_account() test_account = Credentials("Test", "account12") # new account test_account.save_account() self.new_account.delete_account() # Deleting a account object self.assertEqual(len(Credentials.account_list), 1)
def setUp(self): ''' Set up method to run before each test cases. ''' self.new_credentials = Credentials("facebook","tu276","nathan") # create credentials object ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_credentials.account_name,"facebook") self.assertEqual(self.new_credentials.account_username,"tu276") self.assertEqual(self.new_credentials.account_password,"nathan")
def test_find_credential_by_account(self): ''' test to check if we can find a credential by account number and display information ''' self.new_credentials.save_credentials() test_credentials = Credentials("twitter","kwengu","0000") # new credentials test_credentials.save_credentials() found_credentials = Credentials.find_by_account("twitter") self.assertEqual(found_credentials.account,test_credentials.account)
class TestClass(unittest.TestCase): """ A Test class that defines test cases for the User class. """ def setUp(self): """ Method that runs before each individual test methods run. """ self.user = User('WangechiKimani', '123Pass') self.credentials = Credentials('instagram', 'WangechiKimani', '123Pass') def test_init(self): """ test case to check if the object has been initialized correctly """ self.assertEqual(self.user.username, 'WangechiKimani') self.assertEqual(self.user.password, '123Pass') def test_save_user(self): """ test case to test if a new user instance has been saved into the User list """ self.user.save_user() self.assertGreater(len(User.user_list), 0) def test_get_user(self): self.user.save_user() self.assertIsNot(User.get_user(User('WangechiKimani', '123Pass')), False) def test_save_credentials(self): self.credentials.save_credential() self.assertGreater(len(Credentials.credentials_list), 0) def test_generate_random_password_with_predefined_length(self): credentials = Credentials('twitter', 'WangechiKimani') password = credentials.generate_random_password(2) self.assertEqual(len(password), 2) def test_generate_random_password_with_standard_length(self): credentials = Credentials('twitter', 'WangechiKimani') password = credentials.generate_random_password() self.assertEqual(len(password), 10) def test_find_credentials(self): self.credentials.save_credential() self.assertEqual(len(self.user.find_credentials()), 0)
def test_display_all_saved_credentials(self): ''' method that returns a list of all credentials saved ''' self.assertEqual(Credentials.display_credentials(), Credentials.credentials_list)
def create_new_locker(uname, pwd): ''' Function to create a new locker ''' new_locker = Credentials(uname, pwd) return new_locker
class TestCredentials(unittest.TestCase): ''' Test class that defines the test cases for creating and authenticating credentials ''' def setUp(self): ''' Setting up the structure before each test ''' self.new_user = Credentials(1, "richie", "uiui") def tearDown(self): ''' Cleans up after each test has run ''' Credentials.users_list = [] def test_init(self): ''' Test case to test if the case has been initialized properly ''' self.assertEqual(self.new_user.identify, 1) self.assertEqual(self.new_user.user_name, "mark") self.assertEqual(self.new_user.password, "olol") def test_create(self): ''' Testing if the new credential is saved into the list ''' self.new_user.create_account() self.assertEqual(len(Credentials.users_list), 1) def test_authenticate(self): ''' Testing to check if the authenticate function can sign in a user properly ''' self.new_user.create_account() test_account = Credentials(1, "Test", "Password") test_account.create_account() found_user = Credentials.authenticate_account("Test", "Password") self.assertEqual(found_user.identify, test_account.identify)
class TestCredentials(unittest.TestCase): ''' Test class that defines the test cases for creating and authenticating credentials ''' def setUp(self): self.new_user = Credentials(1, "john", "doe") def tearDown(self): ''' Clean up after each test has run ''' Credentials.users_list = [] def test_init(self): ''' Test case to test if the case has been initialized properly ''' self.assertEqual(self.new_user.auth, 1) self.assertEqual(self.new_user.user_name, "john") self.assertEqual(self.new_user.password, "doe") def test_create(self): ''' Testing if the new credential is saved into the list ''' self.new_user.create_account() self.assertEqual(len(Credentials.users_list), 1) def test_authenticate(self): ''' Test to check if the authenticate function can sign in a user properly ''' self.new_user.create_account() test_account = Credentials(1, "Test", "Password") test_account.create_account() found_user = Credentials.auth_user("Test", "Password") self.assertEqual(found_user.auth_user, test_account.auth_user)
def setUp(self): ''' Setting up the structure before each test ''' self.new_user = Credentials(1, "richie", "uiui")
def test_display_all_saved_credentials(self): """ method that displays all the credentials that has been saved by the user """ self.assertEqual(Credentials.display_credentials(), Credentials.credentials_list)
def test_generate_random_password_with_standard_length(self): credentials = Credentials('twitter', 'WangechiKimani') password = credentials.generate_random_password() self.assertEqual(len(password), 10)
class TestClass(unittest.TestCase): """ A Test class that defines test cases for the User class. """ def setUp(self): """ Method that runs before each individual test methods run. """ self.user = User('WangechiKimani', '123Pass') self.credentials = Credentials('Twitter', 'WangechiKimani', '123Pass') def test_init(self): """ test case to chek if the object has been initialized correctly """ self.assertEqual(self.user.username, 'WangechiKimani') self.assertEqual(self.user.password, '123Pass') def test_save_user(self): """ test case to test if a new user instance has been saved into the User list """ self.user.save_user() self.assertGreater(len(User.user_list), 0) def test_get_user(self): self.user.save_user() self.assertIsNot(User.get_user(User('WangechiKimani', '123Pass')), False) def test_save_credentials(self): self.credentials.save_credential() self.assertGreater(len(Credentials.credentials_list), 0) def test_generate_random_password_with_predefined_length(self): credentials = Credentials('twitter', 'WangechiKimani') password = credentials.generate_random_password(2) self.assertEqual(len(password), 2) def test_generate_random_password_with_standard_length(self): credentials = Credentials('twitter', 'WangechiKimani') password = credentials.generate_random_password() self.assertEqual(len(password), 10) def test_find_credentials(self): self.credentials.save_credential() self.assertEqual(len(self.user.find_credentials()), 1) def tearDown(self): """ method that does clean up after each test case has run. """ Credentials.credentials_list = [] def test_save_many_accounts(self): """ test to check if we can save multiple credentials objects to our credentials list """ self.credentials.save_credential() test_credential = Credentials("Twitter", "WangechiKimani", "123Pass") test_credential.save_credential() self.assertGreater(len(Credentials.credentials_list), 1) def test_delete_credential(self): """ test method to test if we can remove an account credentials from our credentials_list """ self.credentials.save_credential() self.credentials.delete_credentials() self.assertEqual(len(Credentials.credentials_list), 0) def test_find_credential(self): """ test to check if we can find a credential entry by account name and display the details of the credential """ self.credentials.save_credential() credential = self.credentials.find_credential("Twitter") self.assertEqual(self.credentials.credential, credential.credential) # def test_credential_exist(self): # """ # test to check if we can return a true or false based on whether we find or can't find the credential. # """ # self.credentials.save_credential() # the_credential = Credentials("Twitter", "WangechiKimani", "123Pass") # the_credential.save_credential() # credential_is_found = Credentials.if_credential_exist("Twitter") # self.assertTrue(credential_is_found) def test_display_all_saved_credentials(self): """ method that displays all the credentials that has been saved by the user """ self.assertEqual(Credentials.display_credentials(), Credentials.credentials_list)
def new_account(id, user_name, password): ''' Function to creating new account ''' new_user = Credentials(id, user_name, password) return new_user