Example #1
0
 def save_user_details_test(self):
     '''
     save_test to check if we can save multiple accounts/credentials in our user_details
     '''
     self.user_details.create()
     test_userDetails = User("Test", "user", "*****@*****.**")
     test_userDetails.create()
     self.assertEqual(len(User.user_details), 2)
Example #2
0
    def setUp(self):
        """
        This is a set up function that runs every time before each test clauses
        """

        #checks for user details
        self.user_details = User("IanBTrey", "Manchester44",
                                 "*****@*****.**")
Example #3
0
    def check_account_existence_test(self):
        '''
        check_account_existence_test to check for the existence of an account
        '''
        self.user_details.create()
        test_userDetails = User("Test", "user", "*****@*****.**")
        test_userDetails.create()

        account_exist = User.check_account_existence("Test")
        self.assertTrue(account_exist)
Example #4
0
    def find_by_accountName_test(self):
        '''
        find_test to search for a particular account and display them
        '''
        self.user_details.create()
        test_userDetails = User("Test", "user", "*****@*****.**")
        test_userDetails.create()

        found_account = User.find_by_accountName("Test")
        self.assertEqual(found_account.username, test_userDetails.username)
Example #5
0
    def delete_user_details_test(self):
        '''
        delete_test to check if we can erase a credential from our account
        '''
        self.user_details.create()
        test_userDetails = User("Test", "user", "*****@*****.**")
        test_userDetails.create()

        self.user_details.delete_password()  # deletes a password
        self.assertEqual(len(User.user_details), 1)
Example #6
0
def create_user(username, password, accountName):
    '''
    Function to create a new user
    '''
    user_details = User(username, password, accountName)
    return user_details
Example #7
0
def check_account_existence(number):
    '''
    Function to check if account exists
    '''
    return User.check_account_existence(number)
Example #8
0
def search_account(number):
    '''
    Function to search for account
    '''
    return User.find_by_accountName(number)
Example #9
0
def display_passwords():
    '''
    Function to display all passwords
    '''
    return User.display_user()
Example #10
0
def delete_password(username, password, accountName):
    '''
    Function  to delete password
    '''
    user_details = User(username, password, email)
    return user_details
Example #11
0
 def display_all_passwords_test(self):
     '''
     display_all_passwords_test to display all account passwords
     '''
     self.assertEqual(User.display_user(), User.user_details)
Example #12
0
class UserTest(unittest.TestCase):
    '''
    Test class that defines test cases for the user class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    '''

    #test 1
    def tearDown(self):
        '''
        This function ensures that each time the test runs it runs afresh without memory of the previous details
        '''
        User.user_details = []

    def setUp(self):
        """
        This is a set up function that runs every time before each test clauses
        """

        #checks for user details
        self.user_details = User("IanBTrey", "Manchester44",
                                 "*****@*****.**")

    #test 2
    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.user_details.username, "IanBTrey")
        self.assertEqual(self.user_details.password, "Manchester44")
        self.assertEqual(self.user_details.email, "*****@*****.**")

    #test 3
    def create_test(self):
        '''
        create_test to test for creation of new credentials
        '''
        self.user_details.create()  #create a new account/credentials
        self.assertEqual(len(User.user_details), 1)

    #test 4
    def save_user_details_test(self):
        '''
        save_test to check if we can save multiple accounts/credentials in our user_details
        '''
        self.user_details.create()
        test_userDetails = User("Test", "user", "*****@*****.**")
        test_userDetails.create()
        self.assertEqual(len(User.user_details), 2)

    #test 5
    def delete_user_details_test(self):
        '''
        delete_test to check if we can erase a credential from our account
        '''
        self.user_details.create()
        test_userDetails = User("Test", "user", "*****@*****.**")
        test_userDetails.create()

        self.user_details.delete_password()  # deletes a password
        self.assertEqual(len(User.user_details), 1)

    #test 6
    def find_by_accountName_test(self):
        '''
        find_test to search for a particular account and display them
        '''
        self.user_details.create()
        test_userDetails = User("Test", "user", "*****@*****.**")
        test_userDetails.create()

        found_account = User.find_by_accountName("Test")
        self.assertEqual(found_account.username, test_userDetails.username)

    #test 7
    def check_account_existence_test(self):
        '''
        check_account_existence_test to check for the existence of an account
        '''
        self.user_details.create()
        test_userDetails = User("Test", "user", "*****@*****.**")
        test_userDetails.create()

        account_exist = User.check_account_existence("Test")
        self.assertTrue(account_exist)

    #test 8
    def display_all_passwords_test(self):
        '''
        display_all_passwords_test to display all account passwords
        '''
        self.assertEqual(User.display_user(), User.user_details)