def main(): print("Safest password locker\n") register = welcome() print(register) print("you can now proceed\n") if register: login = True while login: options = int( input( "1)create account\n2)view account\n3)delete account\n4)Exit\n" )) if options == 1: account = input("enter account name") email = input("enter email") num = int(input("length password")) password = actual(num) Credential(account, password, email) elif options == 2: Credential.display_account() elif options == 3: acc = input("which account to delete ? ") Credential.delete(acc) elif options == 4: login = False
def copypasswordTest(self): """ this functions helps to copy password and test if it was successfully copied on clipboard """ self.newAccount.saveAccount() Credential.copyPwd('moriinga03') self.assertEqual(self.newAccount.l_password, pyperclip.paste())
def test_saveMoreAccount(self): """ this function helps us to save more than one account and test them """ self.newAccount.saveAccount() testAccount = Credential("facebook", "hernandez", "moringa02") testAccount.saveAccount() self.assertEqual(len(Credential.accountList), 2)
def test_save_credentials(self): ''' Test to check if the new credential info is saved into the credentials list ''' self.new_credential.save_credentials() account = Credential("shema", "Instagram", "shema") account.save_credentials() self.assertEqual(len(Credential.credentials_list), 2)
def deleteAccountTest(self): """ this function delete account check if test has passed from account list """ self.newAccount.saveAccount() testAccount = Credential("Twitter", "dennishg250", "moriinga03") testAccount.saveAccount() self.newAccount.deleteAccount() self.assertEqual(len(Credential.accountList), 1)
def findByUsername(self): """ function to test account by username """ self.newAccount.saveAccount() testAccount = Credential("Pinterest", "Dennis Hg" "momo05") testAccount.saveAccount() findbyUsername = Credential.findByuser() self.assertEqual(findbyUsername.l_username.testAccount.l_username)
def testCheckExistingAccount(self): """ Function to test and check if account exist or not """ self.newAccount.saveAccount() testAccount = Credential("Ayoba", "deno", "dano") testAccount.saveAccount() existingAccount = Credential.existingAccount("Ayoba") self.assertTrue(existingAccount)
class TestCredentials(unittest.TestCase): ''' Test class that defines test cases for the credentials class behaviours. Args: unittest.TestCase: helps in creating test cases ''' def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User("", "", "", "") self.new_user.save_user() user2 = User("", "", "", "") user2.save_user() for user in User.user_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name)) def setUp(self): ''' Function to create an account's credentials before each test ''' self.new_credential = Credential("Nancy", "Twitter", "nancy") def test__init__(self): ''' Test to if check the initialization/creation of credential instances is properly done ''' self.assertEqual(self.new_credential.user_name, 'Nancy') self.assertEqual(self.new_credential.site_name, 'Twitter') self.assertEqual(self.new_credential.password, 'nancy') def test_save_credentials(self): ''' Test to check if the new credential info is saved into the credentials list ''' self.new_credential.save_credentials() account = Credential("shema", "Instagram", "shema") account.save_credentials() self.assertEqual(len(Credential.credentials_list), 2)
def test_check_user(self): ''' Function to test whether the login in function check_user works as expected ''' self.new_user = User("", "", "", "") self.new_user.save_user() user2 = User("", "", "", "") user2.save_user() for user in User.user_list: if user.first_name == user2.first_name and user.password == user2.password: current_user = user.first_name return current_user self.assertEqual( current_user, Credential.check_user(user2.password, user2.first_name))
def rema_konti(konti, username, password): ''' Function to create a new credential ''' account = Credential(konti, username, password) return account
def check_existing_credential(string): ''' Function that check if credential exists ''' return Credential.genzura_neza_konti(string)
def setUp(self): ''' Function to create an account's credentials before each test ''' self.new_credential = Credential("Nancy", "Twitter", "nancy")
def pwd_random(creds): """ generating a random password """ pwd = Credential.pwd_random(creds) return pwd
def display_credential(): ''' Function that returns all the saved credentials ''' return Credential.konti_zose()
def findAll(): """ display all account """ return Credential.findAll()
def existingAccount(creds): """ checks exist account credential """ return Credential.existingAccount(creds)
def createAccount(accountName, l_username, l_password): """ function to create new account """ newAccount = Credential(accountName, l_username, l_password) return newAccount
def findByusername(creds): """ find account by username """ return Credential.findByusername(creds)
def setUp(self): """ set up function to run before each test """ self.newAccount = Credential("Instagram", "dennis_250", "moringa01")
def search_credential(string): ''' Function that searchs credential ''' return Credential.search_konti(string)
def findallTest(self): """ Function to test if we can find all accounts registered """ self.assertEqual(Credential.findAll(), Credential.accountList)
def randomPwdGenerate(self): """ Function to generate random password """ random = Credential.pwd_random() self.assertTrue(random)
class TestAccount(unittest.TestCase): """ Test class defines test cases for credentials class behaviours Args: unittest.Testcase this class will helps creating cases """ def setUp(self): """ set up function to run before each test """ self.newAccount = Credential("Instagram", "dennis_250", "moringa01") def test_init(self): """ this function is all about initial save test them if are properly initializeed """ self.assertEqual(self.newAccount.accountName, "Instagram") self.assertEqual(self.newAccount.l_username, "dennis_250") self.assertEqual(self.newAccount.l_password, "moringa01") def test_saveAccount(self): """ this is about save account and test them using account list """ self.newAccount.saveAccount() self.assertEqual(len(Credential.accountList), 1) def tearDown(self): Credential.accountList = [] def test_saveMoreAccount(self): """ this function helps us to save more than one account and test them """ self.newAccount.saveAccount() testAccount = Credential("facebook", "hernandez", "moringa02") testAccount.saveAccount() self.assertEqual(len(Credential.accountList), 2) def deleteAccountTest(self): """ this function delete account check if test has passed from account list """ self.newAccount.saveAccount() testAccount = Credential("Twitter", "dennishg250", "moriinga03") testAccount.saveAccount() self.newAccount.deleteAccount() self.assertEqual(len(Credential.accountList), 1) def copypasswordTest(self): """ this functions helps to copy password and test if it was successfully copied on clipboard """ self.newAccount.saveAccount() Credential.copyPwd('moriinga03') self.assertEqual(self.newAccount.l_password, pyperclip.paste()) def randomPwdGenerate(self): """ Function to generate random password """ random = Credential.pwd_random() self.assertTrue(random) def findallTest(self): """ Function to test if we can find all accounts registered """ self.assertEqual(Credential.findAll(), Credential.accountList) def testCheckExistingAccount(self): """ Function to test and check if account exist or not """ self.newAccount.saveAccount() testAccount = Credential("Ayoba", "deno", "dano") testAccount.saveAccount() existingAccount = Credential.existingAccount("Ayoba") self.assertTrue(existingAccount) def findByUsername(self): """ function to test account by username """ self.newAccount.saveAccount() testAccount = Credential("Pinterest", "Dennis Hg" "momo05") testAccount.saveAccount() findbyUsername = Credential.findByuser() self.assertEqual(findbyUsername.l_username.testAccount.l_username)