Hello I just need help creating test cases for the functions below. examples: assertequal, assertnotequal, asserttrue, assertfalse...

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

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...

Expert Solution
steps

Step by step

Solved in 2 steps with 18 images

Blurred answer
Knowledge Booster
Data Binding
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning