예제 #1
0
    def test_find_account_by_login(self):
        '''
        test to check if we can find an account by login name
        '''

        self.new_account.save_account()
        test_account = User("lulumuts","VXg@!9")#new accounts
        test_account.save_account()

        found_account=User.find_account_by_login("VXg@!9")

        self.assertEqual(found_account.login,test_account.login)
예제 #2
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_account= User("lulumuts","VXg@!9") #create account


    def test_init(self):
        '''
        test_init test cases to test if the object is initialized properly
        '''
        self.assertEqual(self.new_account.username,"lulumuts")
        self.assertEqual(self.new_account.password,"VXg@!9")

    def test_save_account(self):
        '''
        test to see whether you account has been account_saved
        '''
        self.new_account.save_account() #saving the new account
        self.assertEqual(len(User.account_list),1)

    def test_find_account_by_login(self):
        '''
        test to check if we can find an account by login name
        '''

        self.new_account.save_account()
        test_account = User("lulumuts","VXg@!9")#new accounts
        test_account.save_account()

        found_account=User.find_account_by_login("VXg@!9")

        self.assertEqual(found_account.login,test_account.login)

    def tearDown(self):
        '''
        tearDown method that does clean up after each test case has run.
        '''
        User.user_list=[]
예제 #3
0
def main():
    print("Welcome to Password locker! Do you have an account with us?")
    print('\n')

    #while True:
    if 1 == 1:
        print("Navigation: yes, no")

        short_code = input().lower()

        if short_code == 'no':

            print("Create new account")
            print("-" * 10)

            print("Choose your Username")
            unx = input().strip(" ")

            print("Type your password")
            psx = input().strip(" ")

            #save_account(create_account(username,password))#create and save new contact
            ob = User()
            ob.save_account(unx, psx, 1)

            #print("testme",ob.username)
            print('\n')
            print(f"New Account created!")
            print('\n')
            print("please log in again to use our service")
            short_code = 'yes'
            #print("allusers:",ob.get_details())

        if short_code == 'yes':

            print("Enter your log in details")
            print("-" * 10)

            shyes = User()
            #shyes.get_details()
            print("Username")
            username = input().strip(" ")

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

            paw = shyes.check_exist(username)

            if paw == password:
                print('\n')
                print(f"Hello {username}. Lets get you started.")
                print('\n')
                print(
                    "Navigation: new - generate new password, exit-exit the service, view-view existing passwords"
                )
                nav_bar = input().lower().strip(" ")
                if nav_bar == "new":
                    print("set your limit for your password")
                    newpw = shyes.randompw(username)
                    print("new password", newpw)
                elif nav_bar == "exit":
                    print("Come back soon!")
                elif nav_bar == "view":
                    shyes.returnpw(username)
            elif paw == 'nonefound000':
                print("user not found")
            else:
                print("Sorry {username}, that is the wrong password")
예제 #4
0
def save_accountx(username, password):
    '''
    Function to save account
    '''
    User.save_account(username, password)
예제 #5
0
from locker import User

testy = User()
print(1)
testy.get_details()

print(2)
testy.save_account('mxx', 'pwxx')
print(3)
testy.get_details()