Question: Need a pytest file for this code. import string import json def set_users_pasword(username, accounts): password = str(input(Enter desired password: )) name(accounts) # getting first and
Need a pytest file for this code.
import string
import json
def set_users_pasword(username, accounts):
password = str(input("Enter desired password: "))
name(accounts) # getting first and last name
special_symb = set(string.punctuation)
if len(password) < 8:
print("Length of password must be at least 8 characters. ")
set_users_pasword(username)
elif len(password) > 12:
print("Length of password must be less than 12 characters. ")
set_users_pasword(username)
elif not any(char.isupper() for char in password):
print("Password must contain at least one capital letter. ")
set_users_pasword(username)
elif not any(char.islower() for char in password):
print("Password must contain at least one lower case letter. ")
set_users_pasword(username)
elif not any(char.isdigit() for char in password):
print("Password must contain at least one digit. ")
set_users_pasword(username)
elif not any(char in special_symb for char in password):
print("Password must contain at least one special character. ")
set_users_pasword(username)
else:
accounts[username] = password
return accounts
return accounts
def success_login(account):
print("Options to search for a job, find someone that they know, or learn a new skill.")
selection = input("Type J for job, S for searching someone, L for learning a skill: ")
if selection == "J":
post_job(account)
print("Under construction")
elif selection == "S":
search_user()
print("Under construction")
elif selection == "L":
skillChoice = input("Would you like to select a skill? yes or no: ")
while skillChoice == "yes":
skill = input("Learn a new skill (Type the following skill): 1.) Communication 2.) Program 3.) Self-Management 4.) Writing 5.) Public Speaking ")
if skill == "Communication":
print("Under construction")
break
elif skill == "Program":
print("Under construction")
break
elif skill == "Self-Management":
print("Under construction")
break
elif skill == "Writing":
print("Under Construction")
break
elif skill == "Public Speaking":
print("Under Construction")
break
else:
print("Invalid skill selected. Please try again.")
skillChoice = input("Would you like to select a skill? yes or no: ")
if skillChoice == "no":
print()
main()
else:
print("Invalid selection. Please try again.")
def existing_account(accounts):
username = str(input("Enter existing username: "))
if username in accounts.keys():
password = str(input("Enter password: "))
if accounts[username] != password:
print("Incorrect username/password, please try again.")
existing_account(accounts)
else:
success_login()
else:
print("There is no account with the inserted username. Please try again. ")
main()
def new_account(accounts):
username = str(input("Enter new username: "))
if username in accounts.keys():
print("Username already exists.")
new_account(accounts) #added because if username given already says write a new that does not exist
existing_account(accounts)
else:
accounts = set_users_pasword(username, accounts)
with open('Information.json', 'w') as file:
file.write(json.dumps(accounts))
print("Account created successfully. ")
success_login()
def name(accounts):
accounts = str(input("Enter first and last name: "))
def loadFile():
try:
f = open("Information.json")
return json.load(f)
except Exception as e:
return {}
def search_user():
name = str(input("Enter first and last name:"))
if name in account:
print("They are a part of the InCollege")
else:
print("They are not yet a part of the InCollege System")
def post_job(account):
title = str(input("Title: "))
desc = str(input("Job Description: "))
employer = str(input("Employer Name: "))
loc = str(input("Enter Location: "))
salary = str(input("Enter Salary: "))
job = {
"job posted by":account.name,
"title": title,
"job Description": desc,
"employer": employer,
"job location": loc,
"job salary": salary,
}
f = json.dumps(job, indent=4)
with open("Information.json", "w") as outfile:
outfile.write(f)
def main():
print('''The platform of InCollege is able to convey its value proposition to potential users
who have not yet joined up by displaying a real-life example of a student who utilized InCollege to land a job.
This may be a powerful method to entice users to explore the platform more and create an account.
As consumers can see that InCollege has already assisted others in accomplishing their goals, it can also serve to increase trust in the site .''')
video = str(input(("Type \"yes\" or \"no\" for a video to be displaying explaining why they would want ot join InCollege: ")))
if video == "yes":
print("Video is now playing")
account_type = str(input(" Do you wish to create a new InCollege account or log into existing account? "
"(Insert N for new account or E for existing account): "))
accounts = loadFile()
if account_type == "N":
if len(accounts.keys()) == 5:
print("All permitted accounts have ben created, please come back later. ")
new_account(accounts)
elif account_type == "E":
existing_account(accounts)
else:
print("Invalid input. ")
main()
if __name__ == "__main__":
main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
