コード例 #1
0
class Testpassword(unittest.TestCase):
    def setUp(self):
        self.new_password = Password("Instagram", "Lorderonnie", "421145")

    def tearDown(self):
        Password.password_list = []

    def test_init(self):
        self.assertEqual(self.new_password.app_name, "Instagram")
        self.assertEqual(self.new_password.user_name, "Lorderonnie")
        self.assertEqual(self.new_password.password_number, "421145")

    def test_save_password(self):
        self.new_password.save_password()
        self.assertEqual(len(Password.password_list), 1)

    def test_save_multiple_passwords(self):
        self.new_password.save_password()
        test_password = Password("Instagram", "Lorderonnie", "421145")
        test_password.save_password()
        self.assertEqual(len(Password.password_list), 2)

    def test_delete_password(self):
        self.new_password.save_password()
        test_password = Password("Instagram", "Lorderonnie", "421145")
        test_password.save_password()
        self.new_password.delete_password()
        self.assertEqual(len(Password.password_list), 1)

    def test_display_all_contacts(self):
        self.assertEqual(Password.display_passwords(), Password.password_list)
コード例 #2
0
class TestPassword(unittest.TestCase):
    def setUp(self):
        self.new_account = Password(
            "James", "Muriuki", "0712345678", "*****@*****.**")  # create password object

    def tearDown(self):
        Password.password_list = []

    def test_init(self):
        self.assertEqual(self.new_account.first_name, "James")
        self.assertEqual(self.new_account.last_name, "Muriuki")
        self.assertEqual(self.new_account.phone_number, "0712345678")
        self.assertEqual(self.new_account.email, "*****@*****.**")

    def test_save_password(self):
        self.new_account.save_password()  # saving the new password
        self.assertEqual(len(Password.password_list), 1)

    def test_save_multiple_password(self):
        self.new_account.save_password()
        test_password = Password("Test", "user", "0712345678",
                               "*****@*****.**")  # new password
        test_password.save_password()
        self.assertEqual(len(Password.password_list), 2)

    def test_delete_password(self):
        self.new_account.save_password()
        test_password = Password("Test", "user", "0712345678",
                               "*****@*****.**")  # new password
        test_password.save_password()

        self.new_account.delete_password()  # deleting a password objeect
        self.assertEqual(len(Password.password_list), 1)

    def test_find_password_by_number(self):
        self.new_account.save_password()
        test_password = Password("Test", "user", "0711223344",
                               "*****@*****.**")  # new password
        test_password.save_password()

        found_password = Password.find_by_number("0711223344")

        self.assertEqual(found_password.email, test_password.email)

    def test_password_exist(self):
        self.new_account.save_password()
        test_password = Password("Test", "user", "0711223344",
                               "*****@*****.**")  # new password
        test_password.save_password()

        password_exists = Password.password_exist("0711223344")
        self.assertTrue(password_exists)

    def test_display_all_passwords(self):
        self.assertEqual(Password.display_passwords(), Password.password_list)
コード例 #3
0
class Testpasswordnew_password(unittest.TestCase):

    # Items up here .......

    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_password = Password(
            'Evans', 'Opindi', '0740772578', '*****@*****.**',
            'evracheche1999')  # create passwordnew_password object

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

        self.assertEqual(self.new_password.first_name, "Evans")
        self.assertEqual(self.new_password.last_name, "Opindi")
        self.assertEqual(self.new_password.phone_number, "0740772578")
        self.assertEqual(self.new_password.email, "*****@*****.**")
        self.assertEqual(self.new_password.password, "evracheche1999")

    def test_save_password(self):
        '''
        test_save_password test case to test if the password object is saved into
         the password list
        '''
        self.new_password.save_password()  # saving the new password
        self.assertEqual(len(Password.password_list), 1)

# setup and class creation up here

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


# other test cases here

    def test_save_multiple_password(self):
        '''
            test_save_multiple_contact to check if we can save multiple contact
            objects to our contact_list
            '''
        self.new_password.save_password()
        test_password = Password("Test", "user", "0740772578", "*****@*****.**",
                                 "evracheche1999")  # new contact
        test_password.save_password()
        self.assertEqual(len(Password.password_list), 2)

    # More tests above
    def test_delete_password(self):
        '''
            test_delete_contact to test if we can remove a contact from our contact list
            '''
        self.new_password.save_password()
        test_password = Password("Test", "user", "0740772575", "*****@*****.**",
                                 "evracheche1999")  # new contact
        test_password.save_password()

        self.new_password.delete_password()  # Deleting a contact object
        self.assertEqual(len(Password.password_list), 1)

    def test_find_password_by_number(self):
        '''
        test to check if we can find a contact by phone number and display information
        '''

        self.new_password.save_password()
        test_password = Password("Test", "user", "0740772578",
                                 "*****@*****.**",
                                 "evracheche1999")  # new contact
        test_password.save_password()

        found_password = Password.find_by_number("0740772578")

        self.assertEqual(found_password.email, test_password.email)

    def test_password_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the contact.
        '''

        self.new_password.save_password()
        test_password = Password("Test", "user", "0740772578", "*****@*****.**",
                                 "evracheche1999")  # new contact
        test_password.save_password()

        password_exists = Password.password_exist("0740772578")

        self.assertTrue(password_exists)

    def test_display_all_password(self):
        '''
        method that returns a list of all contacts saved
        '''

        self.assertEqual(Password.display_password(), Password.password_list)

    def test_copy_email(self):
        '''
        Test to confirm that we are copying the email address from a found contact
        '''

        self.new_password.save_password()
        Password.copy_email("0740772578")

        self.assertEqual(self.new_password.email, pyperclip.paste())
コード例 #4
0
class TestPassword(unittest.TestCase):
    def setUp(self):

        self.new_password = Password("james", "nyoro", "jymo", "3114")

    def test_init(self):

        self.assertEqual(self.new_password.first_name, "james")
        self.assertEqual(self.new_password.last_name, "nyoro")
        self.assertEqual(self.new_password.user_name, "jymo")
        self.assertEqual(self.new_password.password, "3114")

    def test_save_password(self):

        self.new_password.save_Password()
        self.assertEqual(len(Password.password_list), 1)

    def test_save_multiple_password(self):

        self.new_password.save_Password()
        test_password = Password("Test", "flo", "boel", "flock", "7350")
        self.assertEqual(len(Password.password_list), 2)

    def tearDown(self):

        Password.password_list = []

    def test_save_multiple_password(self):

        self.new_password.save_Password()
        test_password = Password("flo", "boel", "flock", "7350")
        test_password.save_Password()
        self.assertEqual(len(Password.password_list), 2)

    def test_save_multiple_password(self):

        self.new_password.save_Password()
        test_password = Password("flo", "boel", "flock", "7350")
        test_password.save_Password()
        self.assertEqual(len(Password.password_list), 2)

    def test_delete_password(self):

        self.new_password.save_Password()
        test_password = Password("flo", "boel", "flock", "7350")
        test_password.save_Password()

        self.new_password.delete_password()
        self.assertEqual(len(Password.password_list), 1)

    def test_find_password_by_user_name(self):

        self.new_password.save_Password()
        test_password = Password("flo", "boel", "flock", "7350")
        test_password.save_Password()

        found_password = Password.find_by_user_name("flock")

        self.assertEqual(found_password.password, test_password.password)

    def test_password_exist(self):

        self.new_password.save_Password
        test_password = Password("flo", "boel", "flock", "7350")
        test_password.save_Password()

        password_exist = Password.password_exist("flock")

        self.assertTrue(password_exist)

    def test_display_all_passwords(self):

        self.assertEqual(Password.display_passwords(), Password.password_list)
コード例 #5
0
class TestPassword(unittest.TestCase):
    '''
    Test class that defines test cases for the password 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_password = Password("jasonmk",
                                     "RJXP2I5")  # create password object

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

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

        self.assertEqual(self.new_password.user_name, "jasonmk")
        self.assertEqual(self.new_password.pass_word, "RJXP2I5")

    def test_save_password(self):
        '''
        test_save_pasword test case to test if the password object is saved into the password locker
        '''
        self.new_password.save_password()  # saving the new password
        self.assertEqual(len(Password.password_locker), 1)

    def test_save_multiple_password(self):
        '''
        test_save_multiple_password to check if we can save multiple password
        objects to our password-locker
        '''
        self.new_password.save_password()
        test_password = Password("jasonmk", "RJXP2I5")
        test_password.save_password()
        self.assertEqual(len(Password.password_locker), 2)

    def test_delete_password(self):
        '''
        test_delete_password to test if we can remove a password from our password_locker
        '''
        self.new_password.save_password()
        test_password = Password("jasonmk", "RJXP2I5")
        test_password.save_password()

        self.new_password.delete_password()
        self.assertEqual(len(Password.password_locker), 1)

    def test_password_exists(self):
        '''
        test to check if we can return a Boolean if we cannot find the password.
        '''

        self.new_password.save_password()
        test_password = Password("jasonmk", "RJXP2I5")
        test_password.save_password()

        password_exists = Password.password_exist("jasonmk")
        self.assertTrue(password_exists)

    def test_display_all_passwords(self):
        '''
        method that returns a list of all passwords saved
        '''

        self.assertEqual(Password.display_passwords(),
                         Password.password_locker)
コード例 #6
0
class TestPassword(unittest.TestCase):
    '''
    Test class that defines test cases for the password 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_password = Password("Micah", "Mutugi",
                                     "python")  # create password object

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

        self.assertEqual(self.new_password.first_name, "Micah")
        self.assertEqual(self.new_password.last_name, "Mutugi")
        self.assertEqual(self.new_password.password, "python")

    def test_save_password(self):
        '''
        test_save_password test case to test if the password object is saved into
         the password list
        '''
        self.new_password.save_password()  # saving the new password
        self.assertEqual(len(Password.password_list), 1)

    def test_save_multiple_password(self):
        '''
        test_save_multiple_password to check if we can save multiple password
        objects to our password_list
        '''
        self.new_password.save_password()
        test_password = Password("Micah", "Mutugi", "python")  # new password
        test_password.save_password()
        self.assertEqual(len(Password.password_list), 2)

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

    def test_save_multiple_password(self):
        '''
        test_save_multiple_password to check if we can save multiple password
        objects to our password_list
        '''
        self.new_password.save_password()
        test_password = Password("Micah", "Mutugi", "python")  # new password
        test_password.save_password()
        self.assertEqual(len(Password.password_list), 2)

    def test_delete_password(self):
        '''
        test_delete_password to test if we can remove a password from our password list
        '''
        self.new_password.save_password()
        test_password = Password("Micah", "Mutugi", "python")  # new password
        test_password.save_password()

        self.new_password.delete_password()  # Deleting a password object
        self.assertEqual(len(Password.password_list), 1)

    def test_find_password_by_number(self):
        '''
        test to check if we can find a password by phone number and display information
        '''

        self.new_password.save_password()
        test_password = Password("Micah", "Mutugi", "python")  # new password
        test_password.save_password()

        found_password = Password.find_by_number("python")

    def test_password_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the contact.
        '''

        self.new_password.save_password()
        test_password = Password("Micah", "Mutugi", "python")  # new password
        test_password.save_password()

        password_exists = Password.password_exist("python")

        self.assertTrue(password_exists)

    def test_display_all_passwords(self):
        '''
        method that returns a list of all passwords saved
        '''

        self.assertEqual(Password.display_passwords(), Password.password_list)