Exemplo n.º 1
0
 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", "0712345678", "*****@*****.**")  # new user
     test_user.save_user()
     self.assertEqual(len(User.user_list), 2)
Exemplo n.º 2
0
    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", "0712345678", "*****@*****.**")  # new user
        test_user.save_user()

        user_exists = User.user_exist("Test")

        self.assertTrue(user_exists)
Exemplo n.º 3
0
    def test_find_user_by_username(self):
        '''
        test to check if we can find a user by username and display information
        '''

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

        found_user = User.find_by_username("Test")

        self.assertEqual(found_user.email, test_user.email)
Exemplo n.º 4
0
def main():
    print("Welcome")
    print('-' * 20)

    while True:
        print("Use these short codes")
        print("cc - create acc, lo -login, ex - exit app")
        short_code = input().lower()
        if short_code == 'cc':

            print("New User")
            print("-" * 10)

            print("Username ....")
            Username = input()

            print("Password ...")
            password = input()

            print("Email address ...")
            Email = input()
            print('\n')

            save_user(User(Username, password, Email))
            print(f"New User {Username} created")
            print('\n')

        elif short_code == 'lo':
            print("login to your account")
            print("-" * 10)

            print("username....")
            search_user = input()
            if check_existing_user(search_user):
                user_find = find_user(search_user)

                print("input password....")
                password = input()
            if password == input():
                print(f"Welcome {username} logged in")
                print('\n')

    while True:
        print("Use these short codes")
        print("""
        cc - create a new credential, dc - display credential, fc -find a credential, ex -exit the credential list
        """)
        short_code = input().lower()

        if short_code == 'cc':
            print("New Credential")
            print("-" * 10)

            print("Accountname ....")
            accountname = input()

            print("Password ...")
            password = input()

            print("Email address ...")
            e_address = input()

            password = gen_password(username)
            print(f"Your password is{password}")
            save_new_credential(
                create_credential(
                    (accountname, password,
                     e_address)))  # create and save new credential.
            print('\n')
            print(f"New Credential {accountname} created")
            print('\n')

        elif short_code == 'dc':

            if display_credential():
                print("Here is a list of all your credential")
                print('\n')
                for credential in display_credential():
                    print(
                        f"{credential.accountname} .....{credential.password}")

                    print('\n')
            else:
                print('\n')
                print("You dont seem to have any credential saved yet")
                print('\n')

        elif short_code == 'fc':

            print("Enter the password you want for")

            search_password = input()
            if check_existing_credential(search_password):
                search_credential = find_credential(search_password)
                print(f"{search_credential.accountname}")
                print('-' * 20)

                print(f"password.......{search_credential.password}")
                print(f"Email address.......{search_credential.email}")
            else:
                print("That credential does not exist")

        elif short_code == "ex":
            print("Bye .......")
            break

        else:
            print("I really didn't get that. Please use the short codes")
Exemplo n.º 5
0
def check_existing_user(username):
    '''
    Function that check if a user exists with that username
    '''
    return User.user_exist(username)
Exemplo n.º 6
0
def create_user(username, password, email):
    '''
    Function to create a new user
    '''
    new_user = User(username, password, email)
    return new_user
Exemplo n.º 7
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
    '''

    # Items up here .......

    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_user = User("adhiambo16", "katelyne3",
                             "*****@*****.**")  # create user object

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

        self.assertEqual(self.new_user.username, "adhiambo16")
        self.assertEqual(self.new_user.password, "katelyne3")
        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 contact
        self.assertEqual(len(User.user_list), 1)

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

        # Items  here...

    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", "0712345678", "*****@*****.**")  # new user
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)

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

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

        found_user = User.find_by_username("Test")

        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", "0712345678", "*****@*****.**")  # new user
        test_user.save_user()

        user_exists = User.user_exist("Test")

        self.assertTrue(user_exists)
Exemplo n.º 8
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user = User("adhiambo16", "katelyne3",
                          "*****@*****.**")  # create user object