def test_add_friend(self, friendToAdd):
     """
     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
     """
     Network.add_friend(self, friendToAdd)
     #check that the friend was added to the set
     if (Network.setOfFriends.__contains__(friendToAdd)):
         return True
     else:
         return False
 def test_add_friend(self, friendToAdd):
     """
     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
     """
     Network.add_friend(self, friendToAdd)
     #check that the friend was added to the set
     if (Network.setOfFriends.__contains__(friendToAdd)):
         return True
     else:
         return False
    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)
Beispiel #4
0
    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")