예제 #1
0
    def setUp(self):
        """
        function that provides default values for the test cases
        """

        self.new_user_credentials = Credentials('facebook', 'diella',
                                                'diella26')
예제 #2
0
    def test_save_multiple_credenials(self):
        """
        test to see if user can save multiple credentials
        """

        self.new_user_credentials.save_existing_acc()
        test_credentials = Credentials('instagram', 'micha', 'micha8')
        test_credentials.save_existing_acc()
        self.assertEqual(len(Credentials.user_credential_list), 2)
예제 #3
0
		def test_save_many_credentials(self):
				"""
				test method to check if we can save multiple credentials
				"""
				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				self.assertEqual(len(Credentials.credential_list),2)
예제 #4
0
 def test_save_multiple_account(self):
     '''
         test_save_multiple_account to check if multiple accounts
         can be saved
         '''
     self.new_account.save_account()
     test_account = Credentials("Instagram", "Test",
                                "user123")  # new account
     test_account.save_account()
     self.assertEqual(len(Credentials.accounts_list), 2)
예제 #5
0
    def test_account_exists(self):
        """
        Test to check if a certain account exists and returns a boolean value
        """
        self.new_user_credentials.save_existing_acc()
        test_account = Credentials('Facebook', 'diella', 'diella26')
        test_account.save_existing_acc()

        account_exists = Credentials.account_exists('diella')
        self.assertTrue(account_exists)
예제 #6
0
		def test_delete_credential(self):
				"""
				method that deletes user credentials account from a list
				"""
				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				self.new_credential.delete_credential() #deletes a credenial
				self.assertEqual(len(Credentials.credential_list),1)
예제 #7
0
		def test_find_credential(self):
				"""
				method to test whether we can find the specific credential in our credential list
				"""
				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				find_credential = Credentials.find_by_name("Twitter")
				self.assertEqual(find_credential.description,test_credential.description)
예제 #8
0
    def test_find_credentials(self):
        """
        Test to see if a user can search for a specific account in the application
        """

        self.new_user_credentials.save_existing_acc()
        test_account = Credentials('Facebook', 'diella', 'diella26')
        test_account.save_existing_acc()

        found_account = Credentials.find_by_username('diella')
        self.assertEqual(found_account.acc_name, test_account.acc_name)
예제 #9
0
    def test_delete_credentials(self):
        """
        test to see if user can delete existing credentials
        """

        self.new_user_credentials.save_existing_acc()
        test_credential = Credentials('slack', 'micha', 'micha8')
        test_credential.save_existing_acc()

        self.new_user_credentials.delete_user_credentials()
        self.assertEqual(len(Credentials.user_credential_list), 1)
예제 #10
0
    def test_delete_account(self):
        '''
            test_delete_account to test if an account can be removed from list
            '''
        self.new_account.save_account()
        test_account = Credentials("Instagram", "Test",
                                   "user123")  # new account
        test_account.save_account()

        self.new_account.delete_account()  # Deleting account
        self.assertEqual(len(Credentials.accounts_list), 1)
예제 #11
0
		def test_credential_exists(self):
				"""
				test to see if a credential is in the credentials list
				"""

				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				credential_exist = Credentials.credential_check("Twitter")
				self.assertTrue(credential_exist)
예제 #12
0
    def test_account_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find account.
        '''

        self.new_account.save_account()
        test_account = Credentials("Instagram", "Test",
                                   "user123")  # new account
        test_account.save_account()

        account_exists = Credentials.account_exist("Instagram")

        self.assertTrue(account_exists)
예제 #13
0
    def test_find_account(self):
        '''
        test to check accounts by accountName and display information
        '''

        self.new_account.save_account()
        test_account = Credentials("Instagram", "Test",
                                   "user123")  # new account
        test_account.save_account()

        found_account = Credentials.find_account("Instagram")

        self.assertEqual(found_account.password, test_account.password)
예제 #14
0
    def test_display_accounts(self):
        '''
        method that returns a list of accounts saved
        '''

        self.assertEqual(Credentials.display_accounts(),
                         Credentials.accounts_list)
예제 #15
0
    def test_display_credentials(self):
        """
        method that returns a list of all saved credentials
        """

        self.assertEqual(Credentials.display_user_credentials(),
                         Credentials.user_credential_list)
예제 #16
0
    def test_gen_password(self):
        '''
        Test to generate password for account
        '''

        account = Credentials.gen_password("Facebook")
        test_account = Credentials("Facebook", "Nakish", account)
        test_account.save_account()
        test_account.password = Credentials.gen_password(test_account)

        self.assertEqual(test_account.password, account)
예제 #17
0
    def test_check_user(self):
        '''
		Function to test whether the login in function check_user works as expected.
		'''
        self.new_user = User("Loise", "Mwangi", "tcmwangi", "peppermint")
        self.new_user.save_user()
        user2 = User("Ian", "Kabugi", "iankabugi", "laptop")
        user2.save_user()

        for user in User.users_list:
            if user.first_name == user2.first_name and user.user_password == user2.password:
                this_user = user.first_name
        return this_user

        self.assertEqual(
            this_user, Credentials.check_user(user2.password,
                                              user2.first_name))
예제 #18
0
def create_new_credentials(acc_name, acc_username, acc_password):
    """
    Funtion for creating new user credentials
    """
    new_user_credentials = Credentials(acc_name, acc_username, acc_password)
    return new_user_credentials
예제 #19
0
def dis_user_credentials():
    """
    funtion that returns all saved contacts
    """

    return Credentials.display_user_credentials()
예제 #20
0
def generate_password():
    """Funtion that generates random password for the user"""

    gen_password = Credentials.generate_password()
    return gen_password
예제 #21
0
		def setUp(self):
				"""
				set up method to run before each test cases.
				"""
				self.new_credential = Credentials("Facebook","social media account","space\11")
예제 #22
0
def find_account(username):
    """
    a method funtion for the user to search for a specific account using its username.
    """
    return Credentials.find_by_username(username)
예제 #23
0
def check_existing_accounts(username):
    """
    Function that checks if an account exists and returns a boolean value
    """
    return Credentials.account_exists(username)
예제 #24
0
class TestCredentials(unittest.TestCase):
    "class that runs the test cases for credentials"

    def setUp(self):
        """
        function that provides default values for the test cases
        """

        self.new_user_credentials = Credentials('facebook', 'diella',
                                                'diella26')

    def tearDown(self):
        """funtion that does clean up after each test case"""

        Credentials.user_credential_list = []

    # 1st test- correct initialization
    def test_init(self):

        self.assertEqual(self.new_user_credentials.acc_name, 'facebook')
        self.assertEqual(self.new_user_credentials.acc_username, 'diella')
        self.assertEqual(self.new_user_credentials.acc_password, 'diella26')

    # 2nd test - to check if created user credentials are being appended
    def test_save_credentials(self):
        """
        checks is new credentials are being appended to the list
        """
        self.new_user_credentials.save_existing_acc()
        self.assertEqual(len(Credentials.user_credential_list), 1)

    # 3rd test
    def test_save_multiple_credenials(self):
        """
        test to see if user can save multiple credentials
        """

        self.new_user_credentials.save_existing_acc()
        test_credentials = Credentials('instagram', 'micha', 'micha8')
        test_credentials.save_existing_acc()
        self.assertEqual(len(Credentials.user_credential_list), 2)

    # 4th test
    def test_display_credentials(self):
        """
        method that returns a list of all saved credentials
        """

        self.assertEqual(Credentials.display_user_credentials(),
                         Credentials.user_credential_list)

    def test_find_credentials(self):
        """
        Test to see if a user can search for a specific account in the application
        """

        self.new_user_credentials.save_existing_acc()
        test_account = Credentials('Facebook', 'diella', 'diella26')
        test_account.save_existing_acc()

        found_account = Credentials.find_by_username('diella')
        self.assertEqual(found_account.acc_name, test_account.acc_name)

    def test_account_exists(self):
        """
        Test to check if a certain account exists and returns a boolean value
        """
        self.new_user_credentials.save_existing_acc()
        test_account = Credentials('Facebook', 'diella', 'diella26')
        test_account.save_existing_acc()

        account_exists = Credentials.account_exists('diella')
        self.assertTrue(account_exists)

    def test_delete_credentials(self):
        """
        test to see if user can delete existing credentials
        """

        self.new_user_credentials.save_existing_acc()
        test_credential = Credentials('slack', 'micha', 'micha8')
        test_credential.save_existing_acc()

        self.new_user_credentials.delete_user_credentials()
        self.assertEqual(len(Credentials.user_credential_list), 1)
예제 #25
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_account = Credentials("Twitter", "Muriuki",
                                    "Muri5678")  # create Credentials object
예제 #26
0
def list_credentials():
    """
				returns all of the saved credentials
				"""
    return Credentials.show_credentials()
예제 #27
0
		def test_show_credentials(self):
				"""
				method will show a list of the credentials
				"""

				self.assertEqual(Credentials.show_credentials(),Credentials.credential_list)
예제 #28
0
class TestContact(unittest.TestCase):
    '''
    Test class that defines test cases for the Credentials 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_account = Credentials("Twitter", "Muriuki",
                                       "Muri5678")  # create Credentials object

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

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

        self.assertEqual(self.new_account.accountName, "Twitter")
        self.assertEqual(self.new_account.username, "Muriuki")
        self.assertEqual(self.new_account.password, "Muri5678")

    def test_save_account(self):
        '''
        test_save_account test case to test if the object is saved into
         the accounts list
        '''
        self.new_account.save_account()  # saving new account
        self.assertEqual(len(Credentials.accounts_list), 1)

    def test_save_multiple_account(self):
        '''
            test_save_multiple_account to check if multiple accounts
            can be saved
            '''
        self.new_account.save_account()
        test_account = Credentials("Instagram", "Test",
                                   "user123")  # new account
        test_account.save_account()
        self.assertEqual(len(Credentials.accounts_list), 2)

    def test_delete_account(self):
        '''
            test_delete_account to test if an account can be removed from list
            '''
        self.new_account.save_account()
        test_account = Credentials("Instagram", "Test",
                                   "user123")  # new account
        test_account.save_account()

        self.new_account.delete_account()  # Deleting account
        self.assertEqual(len(Credentials.accounts_list), 1)

    def test_find_account(self):
        '''
        test to check accounts by accountName and display information
        '''

        self.new_account.save_account()
        test_account = Credentials("Instagram", "Test",
                                   "user123")  # new account
        test_account.save_account()

        found_account = Credentials.find_account("Instagram")

        self.assertEqual(found_account.password, test_account.password)

    def test_account_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find account.
        '''

        self.new_account.save_account()
        test_account = Credentials("Instagram", "Test",
                                   "user123")  # new account
        test_account.save_account()

        account_exists = Credentials.account_exist("Instagram")

        self.assertTrue(account_exists)

    def test_display_accounts(self):
        '''
        method that returns a list of accounts saved
        '''

        self.assertEqual(Credentials.display_accounts(),
                         Credentials.accounts_list)

    def test_copy_password(self):
        '''
        Test to copy password from a found account
        '''

        self.new_account.save_account()

        self.new_account.copy_password("Twitter")

        self.assertEqual(self.new_account.password, pyperclip.paste())

    def test_gen_password(self):
        '''
        Test to generate password for account
        '''

        account = Credentials.gen_password("Facebook")
        test_account = Credentials("Facebook", "Nakish", account)
        test_account.save_account()
        test_account.password = Credentials.gen_password(test_account)

        self.assertEqual(test_account.password, account)
예제 #29
0
class TestCredentials(unittest.TestCase):
		"""
		Test case defines test cases for the credentials 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_credential = Credentials("Facebook","social media account","space\11")

		def tearDown(self):
				"""
				clean/refreshes after each test case runs
				"""

				Credentials.credential_list = []			

		def test_init(self):
				"""
				this tests if the object is initialized properly
				"""

				self.assertEqual(self.new_credential.account_name,"Facebook")
				self.assertEqual(self.new_credential.description,"social media account")
				self.assertEqual(self.new_credential.password,"space\11")

		def test_save_credential(self):
				"""
				this test method test to see whether we can save a new credential account
				"""
				self.new_credential.save_credential() #save the credential
				self.assertEqual(len(Credentials.credential_list),1)

		def test_save_many_credentials(self):
				"""
				test method to check if we can save multiple credentials
				"""
				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				self.assertEqual(len(Credentials.credential_list),2)

		def test_delete_credential(self):
				"""
				method that deletes user credentials account from a list
				"""
				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				self.new_credential.delete_credential() #deletes a credenial
				self.assertEqual(len(Credentials.credential_list),1)

		def test_find_credential(self):
				"""
				method to test whether we can find the specific credential in our credential list
				"""
				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				find_credential = Credentials.find_by_name("Twitter")
				self.assertEqual(find_credential.description,test_credential.description)

		def test_credential_exists(self):
				"""
				test to see if a credential is in the credentials list
				"""

				self.new_credential.save_credential()
				test_credential = Credentials("Twitter","instant messenger","2222")
				test_credential.save_credential()

				credential_exist = Credentials.credential_check("Twitter")
				self.assertTrue(credential_exist)

		def test_show_credentials(self):
				"""
				method will show a list of the credentials
				"""

				self.assertEqual(Credentials.show_credentials(),Credentials.credential_list)

		#def test_copy_password(self):
				#"""
				#test to see if I can copy my credentials to the clipboard
				#"""

				#self.new_credential.save_credential()
				#Credentials.copy_password("Twitter")

				#self.assertEqual(self.new_credential.password,pyperclip.paste()) 

		def test_generate_random_password(self):
			'''
			test to see if method can auto generate passwords
			'''
			generate_random_password = self.new_credential.generate_random_password()
			self.assertEqual(len(generate_random_password),8)
예제 #30
0
def check_credential(name):
    """
				checks to find if a credential exists and returns a true/false value
				"""
    return Credentials.credential_check(name)