def test_set_get_name(self): """ tests the set_name() and get_name() functions accepts name1 and sets the user's name returns True if the function returns the user's correct name """ personV = Person() personV.set_name("Vanessa") self.assertEqual(personV.get_name(), "Vanessa")
def test_set_get_name(self): """ tests the set_name() and get_name() functions accepts name1 and sets the user's name returns True if the function returns the user's correct name """ personV = Person() personV.set_name("Vanessa") self.assertEqual(personV.get_name(), "Vanessa")
def friend_info(self): """interacts with the user asking for his friend's information and returns a friend Person""" friendName = input("Please enter your friend's name: ") friendAge = input ("Please enter their age: ") #create friend Person friend = Person() #set that Perosn's name and age friend.set_name(friendName) friend.set_age(friendAge) return friend
def user_info(self): """prompts the user for his information and returns a user Person""" userName = input("What is your name: ") userAge = input ("What is your age: ") #create user Person user = Person() #set that Person's name and age user.set_name(userName) user.set_age(userAge) return user
def friend_info(self): """interacts with the user asking for his friend's information and returns a friend Person""" friendName = input("Please enter your friend's name: ") friendAge = input("Please enter their age: ") #create friend Person friend = Person() #set that Perosn's name and age friend.set_name(friendName) friend.set_age(friendAge) return friend
def user_info(self): """prompts the user for his information and returns a user Person""" userName = input("What is your name: ") userAge = input("What is your age: ") #create user Person user = Person() #set that Person's name and age user.set_name(userName) user.set_age(userAge) return user
def test_get_friends_same_age(self): """ tests that get_friends_same_age() returns a set of the names of the friends of the same age returns true if the get_friends_same_age() method returns the correct set of names of the friends of the same age which are in the set """ #creates a user person object userM = Person() userM.set_name("Marilyn") userM.set_age(18) Network.get_friends_same_age(self,userM) self.assertTrue("Vanessa" in Network.get_friends_same_age)
def test_get_friends_same_age(self): """ tests that get_friends_same_age() returns a set of the names of the friends of the same age returns true if the get_friends_same_age() method returns the correct set of names of the friends of the same age which are in the set """ #creates a user person object userM = Person() userM.set_name("Marilyn") userM.set_age(18) Network.get_friends_same_age(self, userM) self.assertTrue("Vanessa" in Network.get_friends_same_age)
def test_add_friend(self): """ Tests that the add_friend() function adds the specified person to the set Takes a Person, friendToAdd and returns True if the specified friend was added to the set or False if it wasn't """ #creates a friend Person object and sets their name and age friendV = Person() friendV.set_name("Vanessa") friendV.set_age(18) Network.add_friend(self, friendV) #check that the friend was added to the set self.assertTrue(friendV in Network.setOfFriends)
def test_add_friend(self): """ Tests that the add_friend() function adds the specified person to the set Takes a Person, friendToAdd and returns True if the specified friend was added to the set or False if it wasn't """ #creates a friend Person object and sets their name and age friendV = Person() friendV.set_name("Vanessa") friendV.set_age(18) Network.add_friend(self, friendV) #check that the friend was added to the set self.assertTrue(friendV in Network.setOfFriends)
def main(): """ calls the test functions and will print whether or not the functions in the Network class work depending if the test functions return True or False """ #create a network object socialN = Network() #creates a user person object userM = Person() userM.set_name("Marilyn") userM.set_age(18) #creates a friend Person object and sets their name and age friendV = Person() friendV.set_name("Vanessa") friendV.set_age(18) #call test_add_friend() passing the friend as parameters #if the method returns True then the add_friend() function works if (TestNetwork.test_add_friend(socialN, friendV) == True): print("add_friend() function works") else: print("add_friend() function doesn't work") #creates another friend object and adds her to the set friendA = Person() friendA.set_name("Andrea") friendA.set_age(15) Network.add_friend(socialN, friendA) #call the test_get_friend() passing socialN as parameters #if the method returns True then the get_friend() function works if (TestNetwork.test_get_friends(socialN) == True): print("get_friends() function works") else: print("get_friends() function doesn't work") #call the test_get_friends_same_age() passing socialN as parameters #if the method returns True then the get_friend_same_age() function works if (TestNetwork.test_get_friends_same_age(socialN, userM) == True): print("get_friends_same_age() function works") else: print("get_friends_same_age() function doesn't work") #call the test_friend_to_remove() function #if the function returns True then the friend_to_remove() function works if (TestNetwork.test_friend_to_remove(socialN) == True): print("friend_to_remove() function works") else: print("friend_to_remove() function doesn't work") #call test_remove_friend() passing the friend as parameters #if the method returns True then the remove_friend() function works if (TestNetwork.test_remove_friend(socialN, friendV) == True): print("remove_friend() function works") else: print("remove_friend() function doesn't work") #call test_remove_all_friends() #if the method returns True then the remove_all_friends() function works if (TestNetwork.test_remove_all_friends(socialN) == True): print("remove_all_friends() function works") else: print("remove_all_friends() function doesn't work")
def main(): """ calls the test functions and will print whether or not the functions in the Network class work depending if the test functions return True or False """ #create a network object socialN = Network() #creates a user person object userM = Person() userM.set_name("Marilyn") userM.set_age(18) #creates a friend Person object and sets their name and age friendV = Person() friendV.set_name("Vanessa") friendV.set_age(18) #call test_add_friend() passing the friend as parameters #if the method returns True then the add_friend() function works if (TestNetwork.test_add_friend(socialN,friendV) == True): print ("add_friend() function works") else: print ("add_friend() function doesn't work") #creates another friend object and adds her to the set friendA = Person() friendA.set_name("Andrea") friendA.set_age(15) Network.add_friend(socialN, friendA) #call the test_get_friend() passing socialN as parameters #if the method returns True then the get_friend() function works if(TestNetwork.test_get_friends(socialN)==True): print("get_friends() function works") else: print("get_friends() function doesn't work") #call the test_get_friends_same_age() passing socialN as parameters #if the method returns True then the get_friend_same_age() function works if(TestNetwork.test_get_friends_same_age(socialN, userM)==True): print("get_friends_same_age() function works") else: print("get_friends_same_age() function doesn't work") #call the test_friend_to_remove() function #if the function returns True then the friend_to_remove() function works if(TestNetwork.test_friend_to_remove(socialN) == True): print("friend_to_remove() function works") else: print("friend_to_remove() function doesn't work") #call test_remove_friend() passing the friend as parameters #if the method returns True then the remove_friend() function works if (TestNetwork.test_remove_friend(socialN, friendV) == True): print ("remove_friend() function works") else: print ("remove_friend() function doesn't work") #call test_remove_all_friends() #if the method returns True then the remove_all_friends() function works if (TestNetwork.test_remove_all_friends(socialN) == True): print ("remove_all_friends() function works") else: print ("remove_all_friends() function doesn't work")