def test_get_average_one_person_multiple_friend(self): param = {'Popular Dude': ['Jacob Chmura', 'Pior Szaran', \ 'Daniel Efinimnko', 'Will Wang']} actual = network_functions.get_average_friend_count(param) expected = 4.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_multi_person_multi_friend(self): param = {'Jay Pritchett': ['Gloria Pritchett', 'Manny Delgado'], \ 'Claire Dunphy': ['Phil Dunphy'], 'Phil Dunphy': ['Claire Dunphy', 'Luke Dunphy']} actual = network_functions.get_average_friend_count(param) expected = 1.6666666666666667 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_multiple_people_one_friend(self): param = {'Mit Kapadia': ['Jay Patel'], 'John Ventura': \ ['Gamila Jonckers'], 'Jay Patel': ['Mit Kapadia']} actual = network_functions.get_average_friend_count(param) expected = 1.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_multiple_person_no_friend(self): param = {'Anti Social': [], 'No Friends': [], 'Needs Gainz': [], \ 'Yuriy Bilynets': []} actual = network_functions.get_average_friend_count(param) expected = 0.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_two_person_three_friend(self): param = {'Haley Gwendolyn Dunphy': ['Dylan D-Money', 'Gilbert D-Cat'], 'Dylan D-Money': ['Haley Gwendolyn Dunphy']} actual = network_functions.get_average_friend_count(param) expected = 1.5 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_more_than_one_friend_each(self): param = {'Jay Pritchett': ['Gloria Pritchett', 'Manny Delgado', \ 'Claire Dunphy'], 'Claire Dunphy': ['Phil Dunphy', 'Jay Pritchett']} actual = network_functions.get_average_friend_count(param) expected = 2.5 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_multiple_person_one_friend(self): param = {'One Friend': ['Friendly Guy'], 'Mathew Beak': ['Total Guy'], \ 'Last one': ['Also friendly']} actual = network_functions.get_average_friend_count(param) expected = 1.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_float(self): param = { 'Jay Pritchett': ['Claire Dunphy', 'Gloria Pritchett'], 'Claire Dunphy': ['Jay Pritchett'] } actual = network_functions.get_average_friend_count(param) expected = 1.5 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_multiple_people_multiple_friends(self): param = {'Mit Kapadia': ['Alexander Jonckers', 'Jacob Brown', \ 'Jay Kapadia', 'John Ventura'], \ 'John Ventura': ['Gamila Jonckers', 'Rachel Lawerenz', \ 'Claire Dunphy']} actual = network_functions.get_average_friend_count(param) expected = 3.5 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_one_person_multiple_friends(self): param = { 'Jay Pritchett': ['Claire Dunphy', 'Gloria Pritchett', 'Manny Delgado'] } actual = network_functions.get_average_friend_count(param) expected = 3.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_multiple_person_multiple_friend(self): param = {'Popular Dude': ['Jacob Chmura', 'Pior Szaran', \ 'Daniel Efinimnko', 'Will Wang'], \ 'Justin bieber': ['Selena Gomez', 'Dead Mau5', 'Pior Szaran', \ 'White girl', 'Shivam G'], 'Faze Rain': ['Faze Adapt', \ 'Lindsay Bul'], 'Person Name': ['Andrew toast', 'Liam Cheap', \ 'Diego Maro', 'C Ronaldo'], 'fIRST Last': [], 'My name': [], \ 'John Peep': ['Amy Gin'], 'Woody Allen': [], 'Lone mans': []} actual = network_functions.get_average_friend_count(param) expected = 2.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_multiple_person_multiple_friend_constant(self): param = {'Popular Dude': ['Jacob Chmura', 'Pior Szaran', \ 'Daniel Efinimnko', 'Will Wang'], '\ Justin bieber' : ['Selena Gomez', 'Dead Mau5', \ 'Pior Szaran', 'Shivam G'], \ 'Faze Rain': ['Faze Adapt', \ 'Lindsay Bul', \ 'Little DudE', \ 'Turtle Name'], \ 'Person Name': ['Andrew toast', \ 'Liam Cheap', \ 'Diego Maro', \ 'C Ronaldo']} actual = network_functions.get_average_friend_count(param) expected = 4.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_empty(self): param = {} actual = network_functions.get_average_friend_count(param) expected = 0.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
# Type and simple check nf.get_families p2f = copy.deepcopy(SAMPLE_P2F) result = nf.get_families(p2f) assert isinstance(result, dict), \ '''network_functions.get_families should return a dict''' assert result.get('Pritchett', []) != [], \ '''network_functions.get_families should return a dictionary where the keys are last names''' assert isinstance(result.get('Pritchett', ''), list), \ '''network_functions.get_families should return a dictionary where the values are lists''' assert isinstance(result.get('Pritchett', '')[0], str), \ '''network_functions.get_families should return a dictionary where the values are lists of strings''' # Type and simple check nf.get_average_friend_count p2f = copy.deepcopy(SAMPLE_P2F) result = nf.get_average_friend_count(p2f) assert isinstance(result, float), \ '''network_functions.get_average_friend_count should return a float''' # Type and simple check nf.invert_network p2n = copy.deepcopy(SAMPLE_P2N) result = nf.invert_network(p2n) assert isinstance(result, dict), \ '''network_functions.invert_network should return a dict''' assert result.get('Parent Teacher Association', []) != [], \ '''network_functions.invert_network should return a dictionary where the keys are network names''' assert isinstance(result.get('Parent Teacher Association', ''), list), \ '''network_functions.invert_network should return a dictionary where the values are lists''' assert isinstance(result.get('Parent Teacher Association', '')[0], str), \ '''network_functions.invert_network should return a dictionary where the values are lists of strings'''
def test_get_average_more_than_one_friend_more_person(self): param = {'Jay Pritchett': ['Gloria Pritchett', 'Claire Dunphy']} actual = network_functions.get_average_friend_count(param) expected = 2.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_two_person_different_friends(self): param = {'sh': ['you', 'really', 'fine'], 'Ck': ['fine', 'sh']} actual = network_functions.get_average_friend_count(param) expected = 2.5 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_one_person_multiple_friends(self): param = {'sh': ['you', 'really', 'fine']} actual = network_functions.get_average_friend_count(param) expected = 3.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
# Type and simple check nf.get_families p2f = copy.deepcopy(SAMPLE_P2F) result = nf.get_families(p2f) assert isinstance(result, dict), \ '''network_functions.get_families should return a dict''' assert result.get('Pritchett', []) != [], \ '''network_functions.get_families should return a dictionary where the keys are last names''' assert isinstance(result.get('Pritchett', ''), list), \ '''network_functions.get_families should return a dictionary where the values are lists''' assert isinstance(result.get('Pritchett', '')[0], str), \ '''network_functions.get_families should return a dictionary where the values are lists of strings''' # Type and simple check nf.get_average_friend_count p2f = copy.deepcopy(SAMPLE_P2F) result = nf.get_average_friend_count(p2f) assert isinstance(result, float), \ '''network_functions.get_average_friend_count should return a float''' # Type and simple check nf.invert_network p2n = copy.deepcopy(SAMPLE_P2N) result = nf.invert_network(p2n) assert isinstance(result, dict), \ '''network_functions.invert_network should return a dict''' assert result.get('Parent Teacher Association', []) != [], \ '''network_functions.invert_network should return a dictionary where the keys are network names''' assert isinstance(result.get('Parent Teacher Association', ''), list), \ '''network_functions.invert_network should return a dictionary where the values are lists''' assert isinstance(result.get('Parent Teacher Association', '')[0], str), \ '''network_functions.invert_network should return a dictionary where the values are lists of strings'''
def test_get_average_one_person_two_friend(self): param = {'Mit Kapadia': ['Jay Patel', 'John Ventura']} actual = network_functions.get_average_friend_count(param) expected = 2.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_one_person_no_friend(self): param = {'First Last': []} actual = network_functions.get_average_friend_count(param) expected = 0.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_empty(self): param = {} actual = network_functions.get_average_friend_count(param) expected = 0.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_get_average_one_person_one_friend(self): param = {'Jay Pritchett': ['Claire Dunphy']} actual = network_functions.get_average_friend_count(param) expected = 1.0 msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)