class TestCredentials(unittest.TestCase):
    """
    Class to test behaviour of the credentials class
    """
    def setUp(self):
        """
        Setup method that defines instructions
        """
        self.new_credentials = Credentials("LMS", "Charlie", "kanambo")

    def tearDown(self):
        """
        Method that cleans up after each test
        """
        Credentials.credentials_list = []

    def test_init(self):
        """
        Test for correct initialization
        """
        self.assertEqual(self.new_credentials.account_name, "LMS")
        self.assertEqual(self.new_credentials.username, "Charlie")
        self.assertEqual(self.new_credentials.password, "Kanambo")

    def test_save_credentials(self):
        """
        Test to check whether app saves account credentials
        """
        self.new_credentials.save_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_save_multiple_credentials(self):
        """
        Test for saving multiple credentials
        """
        self.new_credentials.save_credentials()
        test_credentials = Credentials("Heavenly", "Angels", "Boatross")
        test_credentials.save_credentials()
        self.assertEqual(len(Credentials.credentials_list), 2)

    def test_view_credentials(self):
        """
        Test to view an account credential
        """
        self.assertEqual(Credentials.display_credentials(),
                         Credentials.credentials_list)

    def test_delete_credentials(self):
        """
        Test to delete account credentials
        """
        self.new_credentials.save_credentials()
        test_credentials = Credentials("EAsport", "Striker4", "makesmewonder")
        test_credentials.save_credentials()
        self.new_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)
Example #2
0
 def test_delete_credentials(self):
     '''
     test method to test if we can remove an account credentials from our credentials_list
     '''
     self.new_credentials.save_credentials()
     test_credentials = Credentials("Facebook", "beatricewambui",
                                    "gladweleva")
     test_credentials.save_credentials()
     test_credentials.delete_credentials()
     self.assertEqual(len(Credentials.credentials_list), 1)
class TestCredentials(unittest.TestCase):
    """
    A test class that defines test cases for credentials class

    """        
    def setUp(self):
        """
        Method that runs before each individual credentials test methods run.

        """
        self.new_credential = Credentials('Gmail','davidhashisoma','yx5Gij43')
    def test_init(self):
        """
        Test case to check if a new Credentials instance has been initialized correctly
        """
        self.assertEqual(self.new_credential.account,'Gmail')
        self.assertEqual(self.new_credential.userName,'davidhashisoma')
        self.assertEqual(self.new_credential.password,'yx5Gij43')

    def save_credential_test(self):
        """
        test case to test if the crential object is saved into the credentials list.

        """
        self.new_credential.save_details()
        self.assertEqual(len(Credentials.credentials_list),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.new_credential.save_details()
        test_credential = Credentials("Twitter","@hashisomadavid","Mfh45hfk") 
        test_credential.save_details()
        self.assertEqual(len(Credentials.credentials_list),2)

    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("Twitter","@hashisomadavid","Mfh45hfk")
        test_credential.save_details()

        self.new_credential.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list),1)

    def test_find_credentialr(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("Twitter","@hashisomadavid","Mfh45hfk") 
        test_credential.save_details()

        the_credential = Credentials.find_credential("Twitter")

        self.assertEqual(the_credential.account,test_credential.account)

    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.new_credential.save_details()
        the_credential = Credentials("Twitter", "@hashisomadavid", "Mfh45hfk")  
        the_credential.save_details()
        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)
Example #4
0
class Test_Credentials(unittest.TestCase):
    '''
    test to define all credentials class instances.
    '''
    def tearDown(self): # tearDown method to clean up after every test has been run.

        Credentials.credentials_list = []

    def setUp(self):
        '''
        function to create user account before each test
        '''
        self.new_credentials = Credentials('whaat!','Waasuup','instanglam','whaashanglam')

    def test_credentials_init(self):
        self.assertEqual(self.new_credentials.user_name,'whaat!')
        self.assertEqual(self.new_credentials.account_name,'Waasuup')
        self.assertEqual(self.new_credentials.site_name,'instanglam')
        self.assertEqual(self.new_credentials.site_password,'whaashanglam')
    
    def test_save_credentials(self):
        '''
        test to check the saving functionality of credentials instances.
        '''

        self.new_credentials.save_credentials()
        self.assertEqual(len(Credentials.credentials_list),1)
    
    def test_save_multiple_credentials(self):
        '''
        test to check if the app saves multiple credentials
        '''
        self.new_credentials.save_credentials()
        test_credentials = Credentials('code','python','fb','cofthon')
        test_credentials.save_credentials()
        self.assertEqual(len(Credentials.credentials_list),2)

    def test_delete_credentials(self):
        '''
        test to check deletion of credentials
        '''

        self.new_credentials.save_credentials()
        test_Credentials = Credentials('code','python','fb','cofthon')
        test_Credentials.save_credentials()
        self.new_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list),1)
    
    def test_display_credentials(self):
        '''
        test to display all the available credentials.
        '''
        self.assertEqual(Credentials.display_credentials(),Credentials.credentials_list)

    def test_find_user_name(self):
        '''
        function to find user credentials using by User name
        '''
        self.new_credentials.save_credentials()
        test_credentials = Credentials('code','python','fb','cofthon')
        test_credentials.save_credentials()
        found_credentials = Credentials.find_by_user_name('code')
        self.assertEqual(found_credentials,test_credentials)
Example #5
0
def del_credentials(service):
    """
    function to delete credentials

    """
    Credentials.delete_credentials(service)
Example #6
0
class TestPassword(unittest.TestCase):
    '''
    Test class that defines the test cases for the Credentials class behaviours
    '''
    def setUp(self):
        '''
        Set up method to run before each test cases
        '''
        self.new_credentials = Credentials("twitter", "montecarlos",
                                           "2bornot2b")

    def test_init(self):
        '''
        test_init case to see in the object is initialized properly
        '''
        self.assertEqual(self.new_credentials.site, "twitter")
        self.assertEqual(self.new_credentials.username, "montecarlos")
        self.assertEqual(self.new_credentials.password, "2bornot2b")

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

    def test_save_credentials(self):
        '''
        test_save_credentials test case to test if the credentials object is saved into the credentials list
        '''
        self.new_credentials.save_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_save_multiple_credentials(self):
        '''
        test_save_multiple_credentials to check if we can save multiple credentials objects into the credentials_list
        '''
        self.new_credentials.save_credentials()
        test_credentials = Credentials("finsta", "boba", "tea")
        test_credentials.save_credentials()
        self.assertEqual(len(Credentials.credentials_list), 2)

    def test_delete_credentials(self):
        '''
        test_delete_credentials to test if we can remove a credential from our credentials list
        '''
        self.new_credentials.save_credentials()
        test_credentials = Credentials("finsta", "boba", "tea")
        test_credentials.save_credentials()
        self.new_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_find_credentials_by_site(self):
        '''
        test to check if we can find the relevant username and password combination whiile searching by username
        '''
        self.new_credentials.save_credentials()
        test_credentials = Credentials("finsta", "boba", "tea")
        test_credentials.save_credentials()
        found_credentials = Credentials.find_by_site("finsta")

        self.assertEqual(found_credentials.site, test_credentials.site)

    def test_credentials_exists(self):
        '''
        test to check if we can return a Boolean if we cannot find the credentials
        '''
        self.new_credentials.save_credentials()
        test_credentials = Credentials("finsta", "boba", "tea")
        test_credentials.save_credentials()

        credential_exists = Credentials.credential_exists("finsta")
        self.assertTrue(credential_exists)

    def test_display_all_credentials(self):
        '''
        method that returns a list of all credentials saved
        '''
        self.assertEqual(Credentials.display_credentials(),
                         Credentials.credentials_list)
Example #7
0
class TestCredentials(unittest.TestCase):
    def setUp(self):

        self.new_credential = Credentials('TestPlat', 'tester', 'testpass')

    def test_init(self):
        self.assertEqual(self.new_credential.platform, 'TestPlat')
        self.assertEqual(self.new_credential.username, 'tester')
        self.assertEqual(self.new_credential.password, 'testpass')

    def test_save_credentials(self):
        self.new_credential.save_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def tearDown(self):

        Credentials.credentials_list = []

    def test_save_multiple_credentials(self):

        self.new_credential.save_credentials()
        test_credential = Credentials('TestPlat', 'tester', 'testpass')
        test_credential.save_credentials()
        self.assertEqual(len(Credentials.credentials_list), 2)

    def test_delete_credentials(self):

        self.new_credential.save_credentials()
        test_credential = Credentials('TestPlat', 'tester', 'testpass')
        test_credential.save_credentials()
        self.new_credential.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_find_credentials(self):

        self.new_credential.save_credentials()
        test_credential = Credentials('TestPlat', 'tester', 'testpass')
        test_credential.save_credentials()
        found_credentials = Credentials.find_credentials('TestPlat')
        self.assertEqual(found_credentials.platform, test_credential.platform)

    def test_credential_exists(self):

        self.new_credential.save_credentials()
        test_credential = Credentials('TestPlat', 'tester', 'testpass')
        test_credential.save_credentials()
        found_credential_exists = Credentials.credential_exists('TestPlat')
        self.assertTrue(found_credential_exists)

    def test_display_credentials(self):

        self.assertEqual(Credentials.display_credentials(),
                         Credentials.credentials_list)

    def test_copy_credentials(self):
        self.new_credential.save_credentials()
        Credentials.copy_credentials('TestPlat')
        test_copy = ('Platform:' + self.new_credential.platform + ', ' +
                     'Username: '******', ' +
                     'Password: ' + self.new_credential.password)
        self.assertEqual(test_copy, pyperclip.paste())
class TestCredentials(unittest.TestCase):
    '''
    Test class that defines test cases for Credentials class behaviors
    Args:
      unittest.TestCase: TestCase class that helps in creating test cases
    '''
    def setUp(self):
        '''
        Set Up method to run before each test case"
        '''
        self.new_credential = Credentials("Instagram", "EssyMwangi",
                                          "Sonnie/1")

    def test__init(self):
        '''
        test__init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_credential.account_platform, "Instagram")
        self.assertEqual(self.new_credential.username, "EssyMwangi")
        self.assertEqual(self.new_credential.password, "Sonnie/1")

    def test_save_credential(self):
        '''
        test save credentials to test if the credential object is saved into credentials list
        '''
        self.new_credential.save_details()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def tearDown(self):
        '''
        teaddown method that does clean up after eachtest case has run
        '''
        Credentials.credentials_list = []

    def test_save_multiple_accounts(self):
        '''
        test checks if we can save multiple credential objects to our contact list
        '''
        self.new_credential.save_details()
        test_credentials = Credentials("Gmail", "AshleyMwangi", "Wanjiru/1")
        test_credentials.save_details()
        self.assertEqual(len(Credentials.credentials_list), 2)

    def test_delete_credentials(self):
        '''
        to test if we can remove a credential from our credentials list
        '''
        self.new_credential.save_details()
        test_credentials = Credentials("Gmail", "AshleyMwangi", "Wanjiru/1")
        test_credentials.save_details()

        self.new_credential.delete_credentials()
        self.assertEqual(len(Credentials.credentials_list), 1)

    def test_find_credential(self):
        '''
        test to check if we can find a credential by account platform and display information
        '''
        self.new_credential.save_details()
        test_credentials = Credentials("Gmail", "AshleyMwangi", "Wanjiru/1")
        test_credentials.save_details()

        found_credential = Credentials.find_credential("Gmail")

        self.assertEqual(found_credential.account_platform,
                         test_credentials.account_platform)

    def test_credential_exists(self):
        '''
        test to check if we can return a boolean if we cannot find the contact
        '''

        self.new_credential.save_details()
        test_credentials = Credentials("Gmail", "AshleyMwangi", "Wanjiru/1")
        test_credentials.save_details()

        credential_exists = Credentials.credential_exist("Gmail")
        self.assertTrue(credential_exists)

    def test_display_all_credentials(self):
        '''
        method that returns a list of all credentials saved
        '''
        self.assertEqual(Credentials.display_credentials(),
                         Credentials.credentials_list)

    def test_copy_username(self):
        '''
        Test to confirm that we are copying the username from a found credential
        '''
        self.new_credential.save_details()
        Credentials.copy_username("Instagram")
        self.assertEqual(self.new_credential.username, pyperclip.paste())
Example #9
0
class TestCredentials(unittest.TestCase):
    """
    Defines test cases for Credentials class
    """
    def setUp(self):
        self.new_credentials = Credentials('Facebook', 'Dorothy', 'Dorothy2')

    def test_init(self):
        """
        Checks if a new credential instance has been initialized correctly
        """
        self.assertEqual(self.new_credentials.account_name, 'Facebook')
        self.assertEqual(self.new_credentials.username, 'Dorothy')
        self.assertEqual(self.new_credentials.password, 'Dorothy2')

    def tearDown(self):
        """
        Cleans up after each test case has run
        """
        Credentials.credential_list = []

    def test_save_multiple_accounts(self):
        """
        Check whether we can save multiple credentials in our list
        """
        self.new_credentials.save_credentials()
        test_credentials = Credentials('Twitter', 'Dorothy', 'Muhonja5')
        test_credentials.save_credentials()
        self.assertEqual(len(Credentials.credential_list), 2)

    def test_delete_credentials(self):
        """
        Test if we can remove credentials from our list
        """
        self.new_credentials.save_credentials()
        test_credentials = Credentials('Twitter', 'Dorothy', 'Muhonja5')
        test_credentials.save_credentials()
        self.new_credentials.delete_credentials()
        self.assertEqual(len(Credentials.credential_list), 1)

    def test_find_credentials(self):
        """
        Check if we can find a credential by account name
        """
        self.new_credentials.save_credentials()
        test_credentials = Credentials('Twitter', 'Dorothy', 'Muhonja5')
        test_credentials.save_credentials()
        find_credentials = Credentials.find_account_name('Twitter')
        self.assertEqual(find_credentials.account_name,
                         test_credentials.account_name)

    def test_credentials_exist(self):
        """
        test to check if we can return True or False in regards to finding the credentials
        """
        self.new_credentials.save_credentials()
        test_credentials = Credentials('Twitter', 'Dorothy', 'Muhonja5')
        test_credentials.save_credentials()
        credentials_exist = Credentials.credentials_exist('Twitter')
        self.assertTrue(credentials_exist)

    def display_credentials(self):
        """
        Displays all credentials saved by the user
        """
        self.assertEqual(Credentials.display_credentials(),
                         Credentials.credential_list)

    def test_generate_password(self):
        generated_password = self.new_credentials.generate_password()
        self.assertEqual(len(generated_password), 8)
Example #10
0
def delete_credentials(Credentials):
    '''
    function that deletes credentials from credentials list
    '''
    Credentials.delete_credentials()