Hello I just need help creating test cases for the functions below. examples: assertequal, assertnotequal, asserttrue, assertfalse...
Code is here-
def validate_name(passed_name):
'''This function is used to validate the first and last name'''
valid = False
valid_chars = ['"', '\'']
for character in passed_name:
if character.isalpha() or character.isspace() and character in valid_chars:
valid = True
else:
valid = False
break
return valid
def validate_company(passed_model):
'''This function is used to test the company name'''
bad_chars = ['"']
if passed_model:
for character in passed_model:
if character in bad_chars:
print("Company name is incorrect. Please try again. ")
return False
return True
else:
print("Please try again.")
return False
def validate_address(passed_model):
'''This function is used to validate the vehicle model'''
bad_chars = [ "!", '"', "@", "$", "%", "^", "$", "*", "_", "=", "+", "<", ">", "?", ";", "[", "]", "{", "}"]
if passed_model:
for character in passed_model:
if character in bad_chars:
print("Address is incorrect. Please try again.")
return False
return True
else:
print("Please try again.")
return False
def validate_city(passed_name):
'''This function is used to validate the city from the user'''
valid = False
valid_chars = ['\'']
for character in passed_name:
if character.isalpha() or character.isspace() and character in valid_chars:
valid = True
else:
valid = False
break
return valid
def validate_state(state):
'''This function is used to validate the state'''
if len(str(state)) == 2 and state.isalpha():
try:
return state
except ValueError:
input("Please enter only the two upper case state letters")
def validate_zip(zip):
'''This function is used to validate the zip code'''
if zip.isdigit() and len(zip) == 4 or len(zip) == 5:
return zip
else:
print("Please enter a valid zip code")
def validate_number(passed_number):
'''This function is used to validate the city from the user'''
valid = False
valid_chars = ['-']
for character in passed_number:
if character.isnumeric(): #and character in valid_chars:
valid = True
else:
valid = False
break
return valid
def isEmailOK(passed_user_email):
'''This function is used to validate the user email'''
bad_chars = ["!", '"', "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", ",", "<", ">", "/", "?", ";", ":", "[", "]", "{", "}", "\\"]
if passed_user_email:
for character in passed_user_email:
if character in bad_chars:
print("Address is incorrect. Please try again.")
return False
return True
else:
print("Please try again.")
return False
Hello I just need help creating test cases for the functions below. examples: assertequal, assertnotequal, asserttrue, assertfalse...
Step by step
Solved in 2 steps with 18 images