def create_profile(): print( "\nCreate a profile by answering the following questions: \nWhat account does this profile belong to? \nWhat is the username for this account? \nWhat is the password for this account?" ) account = input("\naccount >>> ") account_username = input("\naccount_username >>> ") print("\nDo you want a generated password? \ny: Yes \nn: No") answer = input("\nanswer? >>> ") # condition if if answer == "y": account_password = PasswordGenerator.generate_password() elif answer == "n": print("\nEnter a password for your new account.") account_password = getpass.getpass( prompt="\n account_password >>> ") else: print("\nPlease enter valid options!") new_cred = Credentials(account, account_username, account_password) new_cred.save_user_profile() print("Profile for: " + "\n\naccount = " + account + "\n\nusername = "******"\n\npassword = " + account_password)
class TestForClassUsers(unittest.TestCase): """setting up our test""" def setUp(self): # creating an object instance of class users self.new_profile = Credentials("twitter", "loisaK", "loisa123") """testing if user profile can be saved""" def test_if_can_save(self): # run test case self.new_profile.save_user_profile() file = open("userprofiles.txt", "r") data = file.readline() self.assertTrue(data) file.close() """testing to find user profile by account""" def test_if_can_find_profile(self): self.new_profile.save_user_profile() file = open("userprofiles.txt", "r") data = file.read() self.assertTrue(data) file.close() """clean up after test""" def tearDown(self): # deleting our object instances Credentials.profile_database = []