def test_sort_recommendations_empty():
    testlist = []
    assert a3_functions.sort_recommendations(testlist) == [], \
           "Empty List"
def test_sort_recommendations_all_same_score():
    testlist = [('george d', 3), ('george d', 3), ('abra', 3),
                ('confusion', 3), ('steain', 3), ('steain', 3)]
    assert a3_functions.sort_recommendations(testlist) == ['abra','confusion','george d','george d','steain', 'steain'], \
           "All same score"
def test_sort_recommendations_multiple_tuples_duplicate_tuples():
    testlist = [('george d', 3), ('george d', 3), ('abra', 3),
                ('confusion', 8), ('steain', 1), ('steain', 3)]
    assert a3_functions.sort_recommendations(testlist) == ['confusion','abra','george d','george d','steain','steain'], \
           "Multiple duplicate tuples"
def test_sort_recommendations_all_duplicate_tuples():
    testlist = [('george d', 3), ('george d', 3), ('george d', 3),
                ('george d', 4), ('george d', 1), ('george d', 3)]
    assert a3_functions.sort_recommendations(testlist) == ['george d','george d','george d','george d','george d', 'george d'], \
           "All duplicate tuples"
Esempio n. 5
0
import a3_functions

if __name__ == '__main__':

    # During testing, we may change the values of these variables.
    friendships = {}
    networks = {}
    profiles_file = open('profiles.txt')

    # Add your code here.
    person = 0
    while person != '':
        a3_functions.load_profiles(profiles_file, friendships, networks)
        person = raw_input("Please enter a person(or press return to exit):")
        recommendations = a3_functions.make_recommendations(
            person, friendships, networks)
        if recommendations == [] and person != '':
            print "There are no recommendations for this person."

        else:
            recomlist = a3_functions.sort_recommendations(recommendations)
            for names in recomlist:
                print names

    print "Thank you for using the recommendation system!"
def test_sort_recommendations_one_tuple():
    testlist = [('george', 3)]
    assert a3_functions.sort_recommendations(testlist) == ['george'], \
           "One tuple"
def test_sort_recommendations_all_same_score():
    testlist = [('george d',3),('george d',3),('abra',3),('confusion',3),('steain',3),('steain',3)]
    assert a3_functions.sort_recommendations(testlist) == ['abra','confusion','george d','george d','steain', 'steain'], \
           "All same score"
def test_sort_recommendations_one_tuple():
    testlist = [('george',3)]
    assert a3_functions.sort_recommendations(testlist) == ['george'], \
           "One tuple"
def test_sort_recommendations_empty():
    testlist = []
    assert a3_functions.sort_recommendations(testlist) == [], \
           "Empty List"
Esempio n. 10
0
def test_sort_recommendations_all_duplicate_tuples():
    testlist = [('george d',3),('george d',3),('george d',3),('george d',4),('george d',1),('george d',3)]
    assert a3_functions.sort_recommendations(testlist) == ['george d','george d','george d','george d','george d', 'george d'], \
           "All duplicate tuples"
Esempio n. 11
0
def test_sort_recommendations_multiple_tuples_duplicate_tuples():
    testlist = [('george d',3),('george d',3),('abra',3),('confusion',8),('steain',1),('steain',3)]
    assert a3_functions.sort_recommendations(testlist) == ['confusion','abra','george d','george d','steain','steain'], \
           "Multiple duplicate tuples"
Esempio n. 12
0
	'Gloria Pritchett': ['Parent Teacher Association']}
	
	result = a3_functions.make_recommendations(\
	person, person_to_friends, person_to_networks)
	assert isinstance(result, list),\
	'''a3_functions.make_recommendations should return 
	a list of (str, int) tuples, but returned %s.''' % (type(result))

	for (name, score) in result:	
		assert isinstance(name, str),\
		'''a3_functions.make_recommendations should return a 
		list of (str, int) tuples, but the first element of a
		list tuple has %s.''' % (type(name))
		assert isinstance(score, int),\
		'''a3_functions.make_recommendations should return a 
		list of (str, int) tuples, but the second element of a 
		list tuple has %s.''' % (type(score))
		
		
	# Type check a3_sort_recommendations
	recommendations_list = [('Cameron Tucker', 1), ('Manny Delgado', 1)]
	
	result = a3_functions.sort_recommendations(recommendations_list)
	assert isinstance(result, list),\
	'''a3_functions.sort_recommendations should return a list of strs,
	 but returned %s.''' % (type(result))
	
	for item in result:
		assert isinstance(item, str),\
		'''a3_functions.sort_recommendations should return a list of strs,
		 but a list element has  %s.''' % (type(item))
Esempio n. 13
0
import a3_functions
       
if __name__ == '__main__':
    
    # During testing, we may change the values of these variables.
    friendships = {}
    networks = {}
    profiles_file = open('profiles.txt')

    # Add your code here.  
    person = 0
    while person != '':
        a3_functions.load_profiles(profiles_file, friendships, networks)
        person = raw_input("Please enter a person(or press return to exit):")
        recommendations = a3_functions.make_recommendations(person, friendships,networks)
        if recommendations == [] and person != '':
            print "There are no recommendations for this person."
            
        else:
            recomlist = a3_functions.sort_recommendations(recommendations)
            for names in recomlist:
                print names
            
            
 
        
    print "Thank you for using the recommendation system!"