예제 #1
0
def check_existing_accounts(user_name):
    '''
    Function that check if an account exists with that number and return a Boolean
    '''
    return User.account_exist(user_name)
예제 #2
0
def create_login(fname, lname, password):
    """
    function to create a new User
    """
    new_user = User(fname, lname, password)
    return new_user
예제 #3
0
class TestUser(unittest.TestCase):
    '''
    Test class that defines test cases for the User 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_user = User("Kinyanjui", "Lucy", "account",
                             "*****@*****.**")
        self.new_credential = Credential("Wambui", "account",
                                         "*****@*****.**")

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

        self.assertEqual(self.new_user.first_name, "Kinyanjui")
        self.assertEqual(self.new_user.last_name, "Lucy")
        self.assertEqual(self.new_user.email, "*****@*****.**")

    def test_save_user(self):
        '''
        test_save_user test case to test if the user object is saved into
         the user list
        '''
        self.new_user.save_user()  # saving the new user
        self.assertEqual(len(User.user_list), 1)

    def test_save_credential(self):
        '''
        test case to test if the credential object is saved into
         the  credential list
        '''
        self.new_credential.save_credential()
        self.assertEqual(len(Credential.credential_list), 1)

    def test_save_multiple_user(self):
        '''
            test_save_multiple_user to check if we can save multiple user
            objects to our user_list
            '''
        self.new_user.save_user()
        test_user = User("Test", "user", "account",
                         "*****@*****.**")  # new user
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)

    def test_save_multiple_credential(self):
        '''
        test_save_multiple_credential to check if we can save multiple credential
        objects to our credential_list
        '''
        self.new_credential.save_credential()
        test_credential = Credential("Test", "account",
                                     "*****@*****.**")  # new credential
        test_credential.save_credential()
        self.assertEqual(len(Credential.credential_list), 2)

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

    def test_delete_user(self):
        '''
            test_delete_user to test if we can remove a user from our user list
            '''
        self.new_user.save_user()
        test_user = User("Test", "user", "account",
                         "*****@*****.**")  # new user
        test_user.save_user()

        self.new_user.delete_user()  # Deleting a user object
        self.assertEqual(len(User.user_list), 1)

    def test_delete_credential(self):
        '''
        test_delete_credential to test if we can remove a credential from our credential list
        '''
        self.new_credential.save_credential()
        test_credential = Credential("Test", "account",
                                     "*****@*****.**")  # new user
        test_credential.save_credential()

        self.new_credential.delete_credential()  # Deleting a credential object
        self.assertEqual(len(Credential.credential_list), 1)

    def test_find_user_by_name(self):
        '''
        test to check if we can find a user by user name and display information
        '''

        self.new_user.save_user()
        test_user = User("Test", "user", "account",
                         "*****@*****.**")  # new name

        found_user = User.find_by_name("Kinyanjui")

        self.assertEqual(found_user.email, test_user.email)

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

        self.new_user.save_user()
        test_user = User("Test", "user", "account",
                         "*****@*****.**")  # new user
        test_user.save_user()

        user_exists = User.name_exist("Lucy")

        self.assertTrue(user_exists)

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

        self.new_credential.save_credential()
        test_credential = Credential("Test", "account",
                                     "*****@*****.**")  # new credential
        test_credential.save_credential()

        credential_exists = Credential.password_exist("password")

        self.assertTrue(credential_exists)

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

        self.new_user.save_user()
        User.copy_email("")

        self.assertEqual(self.new_user.email, pyperclip.paste())

    def test_display_all_credential(self):
        """
         returns a list of all password saved.
         """

        self.assertEqual(Credential.display_credential(),
                         Credential.credential_list)
예제 #4
0
 def test_display_credentials(self):
     self.assertEqual(User.display_credentials(), User.User_list)
예제 #5
0
 def verify(self):
     """ This function verifies togin to enable users to access their vault """
     self.test_user = User('Janice', 'somepassword0123')
예제 #6
0
 def test_find_credentials_by_account(self):
     self.new_credentials.save_details()
     test_credentials = User("joz", "whatsapp", "1234567@")
     test_credentials.save_details()
     found_account = User.find_by_account("whatsapp")
     self.assertEqual(found_account.passwords, test_credentials.passwords)
예제 #7
0
 def test_credentials_exists(self):
     self.new_credentials.save_details()
     test_credentials = User("me", "linkedIn", "12@12")
     test_credentials.save_details()
     credentials_exists = User.credentials_exists("linkedIn")
     self.assertTrue(credentials_exists)
예제 #8
0
    def test_display_all_users(self):
        '''
        method that returns a list of all users saved
        '''

        self.assertEqual(User.display_users(), User.user_list)
예제 #9
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user = User("Twitter", "James", "Muriuki", "OG", "0712345678",
                          "*****@*****.**", "123")  # create object object
예제 #10
0
def create_login(firstname, lastname, password):
    """
    Function to create a new login
    """
    new_user = User(firstname, lastname, password)
    return new_user
예제 #11
0
 def setUp(self):
     '''
     test setup method
     '''
     self.new_user = User("Peter", "Welcome123")
예제 #12
0
def del_account():
    '''
    Function that delete the saved account
    '''
    return User.delete_account()  
예제 #13
0
def create_account(user_name,email,password):
    '''
    Function to create a new account
    '''
    new_account = User(user_name,email,password)
    return new_account
예제 #14
0
def display_accounts():
    '''
    Function that returns all the saved account
    '''
    return User.display_accounts()
예제 #15
0
 def test_multiple_saves(self):
     self.new_credentials.save_details()
     test_credential = User("kent", "twitter", "1234ae")
     test_credential.save_details()
     self.assertEqual(len(User.User_list), 2)
예제 #16
0
class TestContact(unittest.TestCase):
    '''
    Test class that defines test cases for the user 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_user = User("Twitter", "James", "Muriuki", "OG", "0712345678",
                             "*****@*****.**", "123")  # create object object

#init test

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

        self.assertEqual(self.new_user.first_name, "James")
        self.assertEqual(self.new_user.last_name, "Muriuki")
        self.assertEqual(self.new_user.username, "OG")
        self.assertEqual(self.new_user.phone_number, "0712345678")
        self.assertEqual(self.new_user.email, "*****@*****.**")
        self.assertEqual(self.new_user.password, "123")

#saving contact

    def test_save_user(self):
        '''
        test case to test if the user object is saved into the user list
        '''
        self.new_user.save_user()  # saving the new user
        self.assertEqual(len(User.user_list), 1)

#adding 1 contact

    def tearDown(self):
        '''
            method that does clean up after each test case has run.
            '''
        User.user_list = []  #creating empty list

#adding multiple contacts

    def test_save_multiple_user(self):
        '''
            to check if we can save multiple user objects to our contact_list
            '''
        self.new_user.save_user()
        test_user = User("account", "Test", "user", "username", "0712345678",
                         "*****@*****.**", "password")  # new contact
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)

# delete

    def test_delete_user(self):
        '''
            to test if we can remove a user from our user list
            '''
        self.new_user.save_user()
        test_user = User("account", "Test", "user", "username", "0712345678",
                         "*****@*****.**", "password")
        test_user.save_user()

        self.new_user.delete_user()  # Deleting a contact object
        self.assertEqual(len(User.user_list), 1)

#find by username

    def test_find_user_by_username(self):
        '''
            test to check if we can find a user by their username and display information
            '''

        self.new_user.save_user()
        test_user = User("account", "Test", "user", "username", "0711223344",
                         "*****@*****.**", "password")  # new contact
        test_user.save_user()

        found_user = User.find_by_username("username")

        self.assertEqual(found_user.password, test_user.password)

#check if contact exists

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

        self.new_user.save_user()
        test_user = User("account", "Test", "user", "username", "0711223344",
                         "*****@*****.**", "password")
        test_user.save_user()

        user_exists = User.user_exist("username")

        self.assertTrue(user_exists)


#display all contacts

    def test_display_all_users(self):
        '''
        method that returns a list of all users saved
        '''

        self.assertEqual(User.display_users(), User.user_list)
예제 #17
0
 def test_delete_credentials(self):
     self.new_credentials.save_details()
     test_credential = User("ken", "intagram", "iii111")
     test_credential.save_details()
     self.new_credentials.delete_credential()
     self.assertEqual(len(User.User_list), 1)
예제 #18
0
def find_account(fname):
    '''
    function to search account.
    '''
    return User.find_by_name(fname)
예제 #19
0
class TestUser(unittest.TestCase):
    def setUp(self):
        self.new_credentials = User("Rovet", "facebook", "wwww45")
        self.new_account = Account("clent", "iurt45")

    def tearDown(self):
        User.User_list = []
        Account.account_list = []

    def test_init(self):
        """
        test init help test if the object is initialized properly
        """
        self.assertEqual(self.new_credentials.username, "rovel")
        self.assertEqual(self.new_credentials.account, "facebook")
        self.assertEqual(self.new_credentials.passwords, "wwww45")
        self.assertEqual(self.new_account.name, "clent")
        self.assertEqual(self.new_account.passright, "iurt45")

    def test_save_details(self):
        self.new_credentials.save_details()
        self.assertEqual(len(User.User_list), 1)

    def test_save_account(self):
        self.new_account.save_account()
        self.assertEqual(len(Account.account_list), 1)

    def test_multiple_saves(self):
        self.new_credentials.save_details()
        test_credential = User("kent", "twitter", "1234ae")
        test_credential.save_details()
        self.assertEqual(len(User.User_list), 2)

    def test_multiple_saves(self):
        self.new_account.save_account()
        test_account = Account("Dan", "12jt3er")
        test_account.save_account()
        self.assertEqual(len(Account.account_list), 2)

    def test_delete_credentials(self):
        self.new_credentials.save_details()
        test_credential = User("ken", "intagram", "iii111")
        test_credential.save_details()
        self.new_credentials.delete_credential()
        self.assertEqual(len(User.User_list), 1)

    def test_delete_account(self):
        self.new_account.save_account()
        test_account = Account("joice", "@12rews")
        test_account.save_account()
        self.new_account.delete_account()
        self.assertEqual(len(Account.account_list), 1)

    def test_find_credentials_by_account(self):
        self.new_credentials.save_details()
        test_credentials = User("joz", "whatsapp", "1234567@")
        test_credentials.save_details()
        found_account = User.find_by_account("whatsapp")
        self.assertEqual(found_account.passwords, test_credentials.passwords)

    def test_credentials_exists(self):
        self.new_credentials.save_details()
        test_credentials = User("me", "linkedIn", "12@12")
        test_credentials.save_details()
        credentials_exists = User.credentials_exists("linkedIn")
        self.assertTrue(credentials_exists)

    def test_display_credentials(self):
        self.assertEqual(User.display_credentials(), User.User_list)

    def test_copy_passwords(self):
        """
        this method tests coping the password to clip board
        """
        self.new_credentials.save_details()
        User.copy_passwords("facebook")
        self.assertEqual(self.new_credentials.passwords, pyperclip.paste())
예제 #20
0
def display_accounts():
    '''
     function to display all user accounts.
     '''
    return User.display_users()
예제 #21
0
 def setUp(self):
     self.new_credentials = User("Rovet", "facebook", "wwww45")
     self.new_account = Account("clent", "iurt45")
예제 #22
0
def create_account(fname, lname, password, mail):
    '''
    Function to create a new user
    '''
    new_account = User(fname, lname, password, mail)
    return new_account
예제 #23
0
    def setUp(self):
        ''' Function to create a user account before each test '''

        self.test_user = User('Janice', 'somepassword0123')
예제 #24
0
def account_verification(first_name, last_name, password):
    '''
    function to verify an account login.
    '''
    return User.confirm_user(first_name, last_name, password)
 def setUp(self):
     """
 method to run before each test
 """
     self.new_user = User("George", "ptex")
예제 #26
0
def new_user(username, passwords):
    """
  creates a new user
  """
    new_user = User(username, passwords)
    return new_user
 def setUp(self):
     """
     Method that runs before each individual test methods run.
     """
     self.new_user = User('DavidHashisoma','XyZ3thf1')
예제 #28
0
 def setUp(self):
     """
 method to run before each test
 """
     self.new_user = User("Chelsea", "12345")
예제 #29
0
def check_existing_users(username):
    '''
    Function that check if a user exists with that usename and return a Boolean
    '''
    return User.user_exist(username)
예제 #30
0
def find_user_name(user_name):
    '''
    Function that finds an account by number and returns the account
    '''
    return User.find_by_user_name(user_name)