Exemplo n.º 1
0
 def test_get_families_one_person_multiple_friends_diff_families(self):
     param = {'Jay Pritchett': ['Claire Dunphy', 'Manny Delgado']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Jay'], 'Dunphy': ['Claire'], 'Delgado': \
                 ['Manny']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 2
0
 def test_get_families_multiple_people_one_friend_same_families(self):
     param = {'Jay Pritchett': ['Claire Pritchett'], 'McDuck Pritchett': \
              ['Jay Pritchett'], 'Manny Pritchett': ['Cameron Pritchett']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Cameron', 'Claire', 'Jay', 'Manny', 'McDuck']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 3
0
 def test_get_families_multi_person_multi_friend_same_family(self):
     param = {'Jay Pritchett': ['Gloria Pritchett', 'Mitchell Pritchett'], \
              'Gloria Pritchett': ['Mitchell Pritchett']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Gloria', 'Jay', 'Mitchell']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 4
0
 def test_get_families_two_people_multiple_first_friends_diff_family(self):
     param = {'A Sh':['C D Sh', 'B Sh', 'E Ck', 'D Ck'], \
              'B Sh':['C D Sh', 'D Ck']}
     actual = network_functions.get_families(param)
     expected = {'Sh': ['A', 'B', 'C D'], 'Ck': ['D', 'E']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 5
0
 def test_get_families_multiple_people_one_friend_diff_families(self):
     param = {'Jay Pritchett': ['Claire Dunphy'], 'Manny Delgado': \
              ['Jay Pritchett'], 'McDuck Scrooge': ['Cameron Tucker']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Jay'], 'Dunphy': ['Claire'], 'Delgado': \
                 ['Manny'], 'Scrooge': ['McDuck'], 'Tucker': ['Cameron']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 6
0
 def test_get_families_multi_person_multi_friend_diff_family(self):
     param = {'Jay Pritchett': ['Gloria Pritchett', 'Manny Delgado'], \
              'Claire Dunphy': ['Phil Dunphy'], 'Manny Delgado': ['Luke Dunphy']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Gloria', 'Jay'], 'Delgado': ['Manny'], \
                 'Dunphy': ['Claire', 'Luke', 'Phil']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)        
 def test_get_families_with_long_first_name_and_dash(self):
     param = {'Haley Gwendolyn Dunphy': ['Dylan D-Money', 'Gilbert D-Cat'],
          'Dylan D-Money': ['Haley Gwendolyn Dunphy']}
     actual = network_functions.get_families(param)
     expected = {'Dunphy': ['Haley Gwendolyn'],
                 'D-Money': ['Dylan'], 'D-Cat': ['Gilbert']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 8
0
 def test_get_families_two_people_one_friend_reversed_same_family(self):
     param = {
         'Jay Pritchett': ['Gloria Pritchett'],
         'Gloria Pritchett': ['Jay Pritchett']
     }
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Gloria', 'Jay']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 9
0
 def test_get_families_two_firstnames(self):
     param = {'Dylan D-Money': ['Chairman D-Cat', 'Haley Gwendolyn Dunphy']}
     actual = network_functions.get_families(param)
     expected = {
         'Dunphy': ['Haley Gwendolyn'],
         'D-Cat': ['Chairman'],
         'D-Money': ['Dylan']
     }
     msg = 'Expected {}, but returned {}'.format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 10
0
 def test_get_families_multiple_people_multiple_friends_same_families(self):
     param = {'Jay Pritchett': ['Claire Pritchett', 'Chairman Pritchett'], \
              'Cameron Pritchett': ['Jay Pritchett', \
                                    'Haley Gwendolyn Pritchett'], \
              'Manny Pritchett': ['Cameron Pritchett', 'Michael Pritchett']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Cameron', 'Chairman', 'Claire', \
                               'Haley Gwendolyn', 'Jay', 'Manny', 'Michael']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 11
0
 def test_get_families_multiple_people_multiple_friends_diff_families(self):
     param = {'Jay Pritchett': ['Claire Dunphy', 'Chairman D-Cat'], \
              'Cameron Tucker': ['Jay Pritchett', 'Haley Gwendolyn Dun'], \
              'Manny Prit': ['Cameron Tucker', 'Manny Delgado']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Jay'], 'Dunphy': \
                 ['Claire'], 'D-Cat': ['Chairman'], \
                 'Tucker': ['Cameron'], 'Dun': ['Haley Gwendolyn'], 'Prit': \
                 ['Manny'], 'Delgado': ['Manny']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 12
0
 def test_get_families_one_person_one_friend_same_family(self):
     param = {'Jay Pritchett': ['Claire Pritchett']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Claire', 'Jay']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 13
0
 def test_get_families_one_person_one_friend_same_family(self):
     param = {'Luke Dunphy': ['Claire Dunphy']}
     actual = network_functions.get_families(param)
     expected = {'Dunphy': ['Claire', 'Luke']}
     msg = 'Expected {}, but returned {}'.format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 14
0
SAMPLE_P2N = {'Jay Pritchett': ['Parent Teacher Association']}

# Type and simple check nf.load_profiles
p2f = copy.deepcopy(SAMPLE_P2F)
p2n = copy.deepcopy(SAMPLE_P2N)
result = nf.load_profiles(PROF_FILE, p2f, p2n)
assert isinstance(result, type(None)), \
    '''network_functions.load_profiles should return None'''
assert len(p2f) == 3, \
    '''network_functions.load_profiles should add to the person-to-friends dictionary'''
assert len(p2n) == 2, \
    '''network_functions.load_profiles should add to the person-to-networks dictionary'''

# 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'''
 def test_get_families_one_person_one_friend_diff_family(self):
     param = {'Jay Pritchett': ['Claire Dunphy']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Jay'], 'Dunphy': ['Claire']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
 def test_get_families_empty(self):
     param = {}
     actual = network_functions.get_families(param)
     expected = {}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 17
0
# Type and simple check nf.load_profiles
p2f = copy.deepcopy(SAMPLE_P2F)
p2n = copy.deepcopy(SAMPLE_P2N)
result = nf.load_profiles(PROF_FILE, p2f, p2n)
assert isinstance(result, type(None)), \
    '''network_functions.load_profiles should return None'''
assert len(p2f) == 3, \
    '''network_functions.load_profiles should add to the person-to-friends dictionary'''
assert len(p2n) == 2, \
    '''network_functions.load_profiles should add to the person-to-networks dictionary'''


# 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'''
Exemplo n.º 18
0
 def test_get_families_list_in_ascending_order(self):
     param = {'Mitchell Pritchett': ['Luke Dunphy', 'Claire Dunphy']}
     actual = network_functions.get_families(param)
     expected = {'Pritchett': ['Mitchell'], 'Dunphy': ['Claire', 'Luke']}
     msg = 'Expected {}, but returned {}'.format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 19
0
 def test_get_families_empty(self):
     param = {}
     actual = network_functions.get_families(param)
     expected = {}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)
Exemplo n.º 20
0
 def test_get_families_one_person_two_friends_smae_family(self):
     param = {'A Sh': ['C Sh', 'B Sh']}
     actual = network_functions.get_families(param)
     expected = {'Sh': ['A', 'B', 'C']}
     msg = "Expected {}, but returned {}".format(expected, actual)
     self.assertEqual(actual, expected, msg)