示例#1
0
def main():
    '''
        main function that make everything happen
    '''
    # print("Welcome!")
    # Create_User()

    while True:
        print("Please use these short codes to navigate:ac -create a new account, dc -display credentials, log -if you already have an account and ex to exit the application, de -delete your credentials, ex -exit the application")
        short_code = input().lower()

        if short_code == 'ac':
            Add_user()

        elif short_code == 'dc':
            Account.Display()

        elif short_code == 'log':
            Sign_in()

        elif short_code == 'de':
            # print("Nothing was deleted")
            Account.Remove(myAccount)
            # Sign_in()

        elif short_code == 'ex':
            print("See you soon ! :)")
            break

        else:
            print("User does not exist please create an account first")
            break
示例#2
0
 def test_save_multiple_users(self):
     """
     test_save_multiple_users to check if we can save multiple usernames to our user_names
     """
     self.new_user.save_account()
     test_user = Account("aris", "1234567890")
     test_user.save_account()
     self.assertEqual(len(Account.credentials), 2)
示例#3
0
    def test_Remove(self):
        '''
        test_Remove to test if we can remove a user credentials from our credentials array
        '''
        self.new_user.save_account()
        test_contact = Account("aris", "1234567890")  # new contact
        test_contact.save_account()

        self.new_user.Remove()  # Deleting a contact object
        self.assertEqual(len(Account.credentials), 1)
示例#4
0
    def test_check_user(self):
        """
        test to check if we can return a Boolean if we cannot find the users
        """
        self.new_user.save_account()
        test_user = Account("aris", "1234567890")
        test_user.save_account()

        user_exists = Account.check_user("aris", "1234567890")
        self.assertTrue(user_exists)
示例#5
0
def Sign_in():
    '''
        Sign_in method helps to retrieve data from the user and pass it into Account class to perform the sign in action
    '''
    print("Welcome to Login Interface")
    print("Fill in the required details")
    print("Please enter a username")
    usernameLog = input()
    print("Please add a password")
    passwordLog = input().lower()
    Account.check_user(usernameLog, passwordLog)
示例#6
0
def Add_user():
    '''
        add_user method creates unlimited amount of account that the user will want to create
    '''

    print("Add an Account")
    print("\n")
    print("Enter username")
    username = input()
    print("Do you want us to generate a password for you ? y-Yes, n-No")
    confirm = input().lower()
    if(confirm == 'y'):
        password = "******"
        print("Your Paasword is "+password)
    else:
        password = input().lower()

    myAccount = Account(username, password)
    myAccount.save_account()
    print(f"Log in details for {username}  have been saved")
示例#7
0
print("Welcome to Password Locker")
print("\n")
print("Please create an account")
print("\n")
print("Enter username")
username = input()
print("Do you want us to generate a password for you ? y-Yes, n-No")
confirm = input().lower()
if(confirm == 'y'):
    password = "******"
    print("Your Paasword is "+password)
else:
    print("Now create your own password")
    password = input().lower()

myAccount = Account(username, password)
myAccount.save_account()
print(f"Log in details for {username}  have been saved")


def Sign_in():
    '''
        Sign_in method helps to retrieve data from the user and pass it into Account class to perform the sign in action
    '''
    print("Welcome to Login Interface")
    print("Fill in the required details")
    print("Please enter a username")
    usernameLog = input()
    print("Please add a password")
    passwordLog = input().lower()
    Account.check_user(usernameLog, passwordLog)
示例#8
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 = Account("aris", "1234567890")

    def tearDown(self):
        """
        tearDown method that does clean up after each test case runs
        """
        Account.credentials = []

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

        self.assertEqual(self.new_user.username, "aris")
        self.assertEqual(self.new_user.password, "1234567890")

    def test_save_user(self):
        """
        test case to see if the user name is saved into the user usernames
        """
        self.new_user.save_account()
        self.assertEqual(len(Account.credentials), 1)

    def test_save_multiple_users(self):
        """
        test_save_multiple_users to check if we can save multiple usernames to our user_names
        """
        self.new_user.save_account()
        test_user = Account("aris", "1234567890")
        test_user.save_account()
        self.assertEqual(len(Account.credentials), 2)

    def test_check_user(self):
        """
        test to check if we can return a Boolean if we cannot find the users
        """
        self.new_user.save_account()
        test_user = Account("aris", "1234567890")
        test_user.save_account()

        user_exists = Account.check_user("aris", "1234567890")
        self.assertTrue(user_exists)

    def test_Remove(self):
        '''
        test_Remove to test if we can remove a user credentials from our credentials array
        '''
        self.new_user.save_account()
        test_contact = Account("aris", "1234567890")  # new contact
        test_contact.save_account()

        self.new_user.Remove()  # Deleting a contact object
        self.assertEqual(len(Account.credentials), 1)
示例#9
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user = Account("aris", "1234567890")