Esempio n. 1
0
class TestCredentials(unittest.TestCase):
    def setUp(self):
        self.new_credential = Credentials('Gmail','Tony_ishangu','yx5Gij43')

    def test_init(self):
        self.assertEqual(self.new_credential.account,'Gmail')
        self.assertEqual(self.new_credential.userName,'Tony_ishangu')
        self.assertEqual(self.new_credential.password,'yx5Gij43')

    def save_credential_test(self):
        self.new_credential.save_details()
        self.assertEqual(len(Credentials.credentials_list),1)

    def tearDown(self):
        Credentials.credentials_list = []

    def test_save_many_accounts(self):
        self.new_credential.save_details()
        test_credential = Credentials("Twitter","tonnieishangu","Mfh45hfk") 
        test_credential.save_details()
        self.assertEqual(len(Credentials.credentials_list),2)

    def test_delete_credential(self):
        self.new_credential.save_details()
        test_credential = Credentials("Twitter","tonnieishangu","Mfh45hfk")
        test_credential.save_details()

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

    def test_find_credentialr(self):

        self.new_credential.save_details()
        test_credential = Credentials("Twitter","tonnieishangu","Mfh45hfk") 
        test_credential.save_details()

        the_credential = Credentials.find_credential("Twitter")

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

    def test_credential_exist(self):
        self.new_credential.save_details()
        the_credential = Credentials("Twitter", "tonnieishangu", "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):   
        self.assertEqual(Credentials.display_credentials(),Credentials.credentials_list)
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_credentials = Credentials('Gmail', 'lekamcharity',
                                           'kulangombe')

    def test_ini_(self):
        """
        Test case to check if a new Credentials instance has been initialized correctly
        """

        self.assertEqual(self.new_credentials.account, 'Gmail')
        self.assertEqual(self.new_credentials.userName, 'lekamcharity')
        self.assertEqual(self.new_credentials.password, 'kulangombe')

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

        """
        self.new_credentials.save_credentials()
        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_account(self):
        '''
        test to check if we can save multiple credentials objects to our credentials list
        '''
        self.new_credentials.save_credentials()
        test_credential = Credentials("Facebook", "Brian Duke", "kulangombe")
        test_credential.save_credentials()
        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_credentials.save_credentials()
        test_credential = Credentials("Facebook", "Brian Duke", "kulangombe")
        test_credential.save_credentials()

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

    def test_find_credentials(self):
        """
        test to check if we can find a credential entry by account name and display the details of the credential
        """

        self.new_credentials.save_credentials()
        test_credential = Credentials("Facebook", "Brian Duke", "kulangombe")
        test_credential.save_credentials()

        the_credential = Credentials.find_credential("Facebook")
        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_credentials.save_credentials()
        test_credential = Credentials("Facebook", "Brian Duke", "kulangombe")
        test_credential.save_credentials()

        found_credential = Credentials.if_credential_exist("Facebook")
        self.assertTrue(found_credential)
Esempio n. 3
0
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', 'byusagisele', 'byusa123')

    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, 'byusagisele')
        self.assertEqual(self.new_credential.password, 'uwase123')

    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", "byusadiamant", "byusa123")
        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", "byusadiamant", "byusa123")
        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", "byusadiamant", "byusa123")
        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", "byusagisele", "byusa123")
        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)