示例#1
0
def test_example_unit_tests():
    # Example tests, these do not count as your tests

    # Basic search, function #3
    assert search('dog') == DOG

    # Advanced search option 1, function #4
    expected = {'Black dog (ghost)': {'author': 'SmackBot', 'timestamp': 1220471117, 'length': 14746}, 'Mexican dog-faced bat': {'author': 'AnomieBOT', 'timestamp': 1255316429, 'length': 1138}, 'Dalmatian (dog)': {'author': 'J. Spencer', 'timestamp': 1207793294, 'length': 26582}, 'Guide dog': {'author': 'Sarranduin', 'timestamp': 1165601603, 'length': 7339}, 'Sun dog': {'author': 'Hellbus', 'timestamp': 1208969289, 'length': 18050}}
    assert article_info(deepcopy(DOG), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = ['Mexican dog-faced bat', 'Guide dog']
    assert article_length(8000, deepcopy(DOG), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {'Black dog (ghost)': 1220471117, 'Mexican dog-faced bat': 1255316429, 'Dalmatian (dog)': 1207793294, 'Guide dog': 1165601603, 'Sun dog': 1208969289}
    assert title_timestamp(deepcopy(DOG), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('J. Spencer', deepcopy(DOG), TITLE_TO_INFO) == True
    assert favorite_author('Andrea', deepcopy(DOG), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['Black dog (ghost)', 'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog', 'Sun dog', 'Spain national beach soccer team', 'Will Johnson (soccer)', 'Steven Cohen (soccer)']
    assert multiple_keywords('soccer', deepcopy(DOG)) == expected
示例#2
0
def test_example_unit_tests():
    # Example tests, these do not count as your tests

    # Basic search, function #1
    assert search('dog') == DOG

    # Advanced search option 1, function #2
    expected = [['Mexican dog-faced bat', 'AnomieBOT', 1255316429, 1138], ['Guide dog', 'Sarranduin', 1165601603, 7339]]
    assert article_length(8000, DOG.copy()) == expected

    # Advanced search option 2, function #3
    expected = [['Black dog (ghost)', 'SmackBot', 1220471117, 14746], ['Mexican dog-faced bat', 'AnomieBOT', 1255316429, 1138], ['Dalmatian (dog)', 'J. Spencer', 1207793294, 26582]]
    assert article_count(3, DOG.copy()) == expected

    # Advanced search option 3, function #4
    expected = ['Guide dog', 'Sarranduin', 1165601603, 7339]
    assert random_article(3, DOG.copy()) == expected

    # Advanced search option 4, function #5
    assert favorite_author('J. Spencer', DOG.copy()) == True

    # Advanced search option 5, function #6
    expected = [['Black dog (ghost)', 'SmackBot'], ['Mexican dog-faced bat', 'AnomieBOT'], ['Dalmatian (dog)', 'J. Spencer'], ['Guide dog', 'Sarranduin'], ['Sun dog', 'Hellbus']]
    assert title_author(DOG.copy()) == expected

    # Advanced search option 6, function #7
    expected = [['Black dog (ghost)', 'SmackBot', 1220471117, 14746], ['Mexican dog-faced bat', 'AnomieBOT', 1255316429, 1138], ['Dalmatian (dog)', 'J. Spencer', 1207793294, 26582], ['Guide dog', 'Sarranduin', 1165601603, 7339], ['Sun dog', 'Hellbus', 1208969289, 18050], ['Spain national beach soccer team', 'Pegship', 1233458894, 1526], ['Will Johnson (soccer)', 'Mayumashu', 1218489712, 3562], ['Steven Cohen (soccer)', 'Scouselad10', 1237669593, 2117]]
    assert multiple_keywords('soccer', DOG.copy()) == expected
示例#3
0
def test_unit_tests2():
    # Basic search, function #3
    assert search('photo') == PHOTO

    # Advanced search option 1, function #4
    expected = {'Digital photography': {'author': 'Mintleaf', 'timestamp': 1095727840, 'length': 18093}}
    assert article_info(deepcopy(PHOTO), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = []
    assert article_length(5, deepcopy(PHOTO), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {'Digital photography': 1095727840}
    assert title_timestamp(deepcopy(PHOTO), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('Mintleaf', deepcopy(SCHOOL), TITLE_TO_INFO) == False
    assert favorite_author('Bhatta', deepcopy(PHOTO), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['Digital photography', 'Fisk University']
    assert multiple_keywords('education', deepcopy(PHOTO)) == expected
示例#4
0
def test_unit_tests3():
    # Basic search, function #3
    assert search('dance') == DANCE

    # Advanced search option 1, function #4
    expected = {'List of Canadian musicians': {'author': 'Bearcat', 'timestamp': 1181623340, 'length': 21023}, '2009 in music': {'author': 'SE KinG', 'timestamp': 1235133583, 'length': 69451}, 'Old-time music': {'author': 'Badagnani', 'timestamp': 1124771619, 'length': 12755}, '1936 in music': {'author': 'JohnRogers', 'timestamp': 1243745950, 'length': 23417}, 'Indian classical music': {'author': 'Davydog', 'timestamp': 1222543238, 'length': 9503}}
    assert article_info(deepcopy(DANCE), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = ['List of Canadian musicians', '2009 in music', 'Old-time music', '1936 in music', 'Indian classical music']
    assert article_length(80000, deepcopy(DANCE), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {'List of Canadian musicians': 1181623340, '2009 in music': 1235133583, 'Old-time music': 1124771619, '1936 in music': 1243745950, 'Indian classical music': 1222543238}
    assert title_timestamp(deepcopy(DANCE), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('JohnRogers', deepcopy(SCHOOL), TITLE_TO_INFO) == False
    assert favorite_author('google', deepcopy(DANCE), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['List of Canadian musicians', '2009 in music', 'Old-time music', '1936 in music', 'Indian classical music', 'List of Canadian musicians', 'French pop music', 'Noise (music)', '1922 in music', '1986 in music', 'Kevin Cadogan', '2009 in music', 'Rock music', 'Lights (musician)', 'Tim Arnold (musician)', 'Old-time music', 'Arabic music', 'Joe Becker (musician)', 'Richard Wright (musician)', 'Voice classification in non-classical music', '1936 in music', '1962 in country music', 'List of dystopian music, TV programs, and games', 'Steve Perry (musician)', 'David Gray (musician)', 'Alex Turner (musician)', 'List of gospel musicians', 'Indian classical music', '1996 in music', 'Traditional Thai musical instruments', '2006 in music', 'Tony Kaye (musician)', 'Texture (music)', '2007 in music', '2008 in music']
    assert multiple_keywords('music', deepcopy(DANCE)) == expected
示例#5
0
def test_unit_tests1():
    # Basic search, function #3
    assert search('school') == SCHOOL

    # Advanced search option 1, function #4
    expected = {'Edogawa, Tokyo': {'author': 'Ciphers', 'timestamp': 1222607041, 'length': 4526}, 'Fisk University': {'author': 'NerdyScienceDude', 'timestamp': 1263393671, 'length': 16246}, 'Annie (musical)': {'author': 'Piano non troppo', 'timestamp': 1223619626, 'length': 27558}, 'Alex Turner (musician)': {'author': 'CambridgeBayWeather', 'timestamp': 1187010135, 'length': 9718}}
    assert article_info(deepcopy(SCHOOL), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = ['Edogawa, Tokyo', 'Fisk University', 'Alex Turner (musician)']
    assert article_length(20000, deepcopy(SCHOOL), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {'Edogawa, Tokyo': 1222607041, 'Fisk University': 1263393671, 'Annie (musical)': 1223619626, 'Alex Turner (musician)': 1187010135}
    assert title_timestamp(deepcopy(SCHOOL), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('Ciphers', deepcopy(SCHOOL), TITLE_TO_INFO) == True
    assert favorite_author('Aayush', deepcopy(SCHOOL), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['Edogawa, Tokyo', 'Fisk University', 'Annie (musical)', 'Alex Turner (musician)', 'C Sharp (programming language)', 'Fisk University', 'Python (programming language)']
    assert multiple_keywords('program', deepcopy(SCHOOL)) == expected
def test_unit_programming():

    # Basic search, function #3
    assert search('PROGRAMMING') == PROGRAMMING

    # Advanced search option 1, function #4
    expected = {'C Sharp (programming language)': {'author': 'Eaglizard', 'timestamp': 1232492672, 'length': 52364}, 'Python (programming language)': {'author': 'Lulu of the Lotus-Eaters', 'timestamp': 1137530195, 'length': 41571}, 'Lua (programming language)': {'author': 'Makkuro', 'timestamp': 1113957128, 'length': 0}, 'Covariance and contravariance (computer science)': {'author': 'Wakapop', 'timestamp': 1167547364, 'length': 7453}, 'Personal computer': {'author': 'Darklock', 'timestamp': 1220391790, 'length': 45663}, 'Ruby (programming language)': {'author': 'Hervegirod', 'timestamp': 1193928035, 'length': 30284}}
    assert article_info(deepcopy(PROGRAMMING), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = ['Lua (programming language)']
    assert article_length(0, deepcopy(PROGRAMMING), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {'C Sharp (programming language)': 1232492672, 'Python (programming language)': 1137530195, 'Lua (programming language)': 1113957128, 'Covariance and contravariance (computer science)': 1167547364, 'Personal computer': 1220391790, 'Ruby (programming language)': 1193928035}
    assert title_timestamp(deepcopy(PROGRAMMING), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('Wakapop', deepcopy(PROGRAMMING), TITLE_TO_INFO) == True
    assert favorite_author('Louis Fitz', deepcopy(PROGRAMMING), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['C Sharp (programming language)', 'Python (programming language)', 'Lua (programming language)', 'Covariance and contravariance (computer science)', 'Personal computer', 'Ruby (programming language)', 'Edogawa, Tokyo', 'Fisk University', 'Annie (musical)', 'Alex Turner (musician)']
    assert multiple_keywords('SCHOOL', deepcopy(PROGRAMMING)) == expected
def test_unit_music():

    # Basic search, function #3
    assert search('MusIc') == MUSIC

    # Advanced search option 1, function #4
    expected = {'List of Canadian musicians': {'author': 'Bearcat', 'timestamp': 1181623340, 'length': 21023}, 'French pop music': {'author': 'Brandon', 'timestamp': 1172208041, 'length': 5569}, 'Noise (music)': {'author': 'Epbr123', 'timestamp': 1194207604, 'length': 15641}, '1922 in music': {'author': 'Jafeluv', 'timestamp': 1242717698, 'length': 11576}, '1986 in music': {'author': 'Michael', 'timestamp': 1048918054, 'length': 6632}, 'Kevin Cadogan': {'author': 'Renesis', 'timestamp': 1144136316, 'length': 3917}, '2009 in music': {'author': 'SE KinG', 'timestamp': 1235133583, 'length': 69451}, 'Rock music': {'author': 'Sabrebd', 'timestamp': 1258069053, 'length': 119498}, 'Lights (musician)': {'author': 'Espo3699', 'timestamp': 1213914297, 'length': 5898}, 'Tim Arnold (musician)': {'author': 'Sohohobo', 'timestamp': 1181480380, 'length': 4551}, 'Old-time music': {'author': 'Badagnani', 'timestamp': 1124771619, 'length': 12755}, 'Arabic music': {'author': 'Badagnani', 'timestamp': 1209417864, 'length': 25114}, 'Joe Becker (musician)': {'author': 'Gary King', 'timestamp': 1203234507, 'length': 5842}, 'Richard Wright (musician)': {'author': 'Bdubiscool', 'timestamp': 1189536295, 'length': 16185}, 'Voice classification in non-classical music': {'author': 'Iridescent', 'timestamp': 1198092852, 'length': 11280}, '1936 in music': {'author': 'JohnRogers', 'timestamp': 1243745950, 'length': 23417}, '1962 in country music': {'author': 'Briguy52748', 'timestamp': 1249862464, 'length': 7954}, 'List of dystopian music, TV programs, and games': {'author': 'Notinasnaid', 'timestamp': 1165317338, 'length': 13458}, 'Steve Perry (musician)': {'author': 'Woohookitty', 'timestamp': 1254812045, 'length': 22204}, 'David Gray (musician)': {'author': 'RattleandHum', 'timestamp': 1159841492, 'length': 7203}, 'Alex Turner (musician)': {'author': 'CambridgeBayWeather', 'timestamp': 1187010135, 'length': 9718}, 'List of gospel musicians': {'author': 'Absolon', 'timestamp': 1197658845, 'length': 3805}, 'Indian classical music': {'author': 'Davydog', 'timestamp': 1222543238, 'length': 9503}, '1996 in music': {'author': 'Kharker', 'timestamp': 1148585201, 'length': 21688}, 'Traditional Thai musical instruments': {'author': 'Badagnani', 'timestamp': 1191830919, 'length': 6775}, '2006 in music': {'author': 'Suduser85', 'timestamp': 1171547747, 'length': 105280}, 'Tony Kaye (musician)': {'author': 'Bondegezou', 'timestamp': 1141489894, 'length': 8419}, 'Texture (music)': {'author': 'J Lorraine', 'timestamp': 1161070178, 'length': 3626}, '2007 in music': {'author': 'Squilly', 'timestamp': 1169248845, 'length': 45652}, '2008 in music': {'author': 'Ba11innnn', 'timestamp': 1217641857, 'length': 107605}}
    assert article_info(deepcopy(MUSIC), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = ['List of Canadian musicians', 'French pop music', 'Noise (music)', '1922 in music', '1986 in music', 'Kevin Cadogan', 'Lights (musician)', 'Tim Arnold (musician)', 'Old-time music', 'Arabic music', 'Joe Becker (musician)', 'Richard Wright (musician)', 'Voice classification in non-classical music', '1936 in music', '1962 in country music', 'List of dystopian music, TV programs, and games', 'Steve Perry (musician)', 'David Gray (musician)', 'Alex Turner (musician)', 'List of gospel musicians', 'Indian classical music', '1996 in music', 'Traditional Thai musical instruments', 'Tony Kaye (musician)', 'Texture (music)']
    assert article_length(28000, deepcopy(MUSIC), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {'List of Canadian musicians': 1181623340, 'French pop music': 1172208041, 'Noise (music)': 1194207604, '1922 in music': 1242717698, '1986 in music': 1048918054, 'Kevin Cadogan': 1144136316, '2009 in music': 1235133583, 'Rock music': 1258069053, 'Lights (musician)': 1213914297, 'Tim Arnold (musician)': 1181480380, 'Old-time music': 1124771619, 'Arabic music': 1209417864, 'Joe Becker (musician)': 1203234507, 'Richard Wright (musician)': 1189536295, 'Voice classification in non-classical music': 1198092852, '1936 in music': 1243745950, '1962 in country music': 1249862464, 'List of dystopian music, TV programs, and games': 1165317338, 'Steve Perry (musician)': 1254812045, 'David Gray (musician)': 1159841492, 'Alex Turner (musician)': 1187010135, 'List of gospel musicians':  1197658845, 'Indian classical music': 1222543238, '1996 in music':  1148585201, 'Traditional Thai musical instruments':  1191830919, '2006 in music': 1171547747, 'Tony Kaye (musician)': 1141489894, 'Texture (music)': 1161070178, '2007 in music': 1169248845, '2008 in music': 1217641857}
    assert title_timestamp(deepcopy(MUSIC), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('Squilly', deepcopy(MUSIC), TITLE_TO_INFO) == True
    assert favorite_author('A2chainz', deepcopy(MUSIC), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['List of Canadian musicians', 'French pop music', 'Noise (music)', '1922 in music', '1986 in music', 'Kevin Cadogan', '2009 in music', 'Rock music', 'Lights (musician)', 'Tim Arnold (musician)', 'Old-time music', 'Arabic music', 'Joe Becker (musician)', 'Richard Wright (musician)', 'Voice classification in non-classical music', '1936 in music', '1962 in country music', 'List of dystopian music, TV programs, and games', 'Steve Perry (musician)', 'David Gray (musician)', 'Alex Turner (musician)', 'List of gospel musicians', 'Indian classical music', '1996 in music', 'Traditional Thai musical instruments', '2006 in music', 'Tony Kaye (musician)', 'Texture (music)', '2007 in music', '2008 in music', 'List of Canadian musicians', '2009 in music', 'Old-time music', '1936 in music', 'Indian classical music']
    assert multiple_keywords('dance', deepcopy(MUSIC)) == expected
def test_unit_travel():

    # Basic search, function #3
    assert search('travel') == TRAVEL

    # Advanced search option 1, function #4
    expected = {'Time travel': {'author': 'Thug outlaw69', 'timestamp': 1140826049, 'length': 35170}}
    assert article_info(deepcopy(TRAVEL), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = ['Time travel']
    assert article_length(48000, deepcopy(TRAVEL), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {'Time travel': 1140826049}
    assert title_timestamp(deepcopy(TRAVEL), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('Thug outlaw69', deepcopy(TRAVEL), TITLE_TO_INFO) == True
    assert favorite_author('Miazaa', deepcopy(TRAVEL), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['Time travel', 'Black dog (ghost)', 'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog', 'Sun dog']
    assert multiple_keywords('Dog', deepcopy(TRAVEL)) == expected
def test_unit_empty():

    # Basic search, function #3
    assert search('') == []

    # Advanced search option 1, function #4
    expected = {}
    assert article_info(deepcopy([]), TITLE_TO_INFO) == expected

    # Advanced search option 2, function #5
    expected = []
    assert article_length(0, deepcopy([]), TITLE_TO_INFO) == expected

    # Advanced search option 3, function #6
    expected = {}
    assert title_timestamp(deepcopy([]), TITLE_TO_INFO) == expected

    # Advanced search option 4, function #7
    assert favorite_author('Louis Fitz', deepcopy([]), TITLE_TO_INFO) == False

    # Advanced search option 5, function #8
    expected = ['Edogawa, Tokyo', 'Fisk University', 'Annie (musical)', 'Alex Turner (musician)']
    assert multiple_keywords('SCHOOL', deepcopy([])) == expected
示例#10
0
def test_unit_tests():
    empty_string = []
    aayush_search_result = []

    # Basic search, function #1
    assert search('photo') == PHOTOGRAPHY
    assert search('Programming') == PROGRAMMING
    assert search('') == empty_string
    assert search('Aayush') == aayush_search_result 


    # Advanced search option 1, function #2
    expected = [['Digital photography', 'Mintleaf', 1095727840, 18093]]
    assert article_length(20000, PHOTOGRAPHY.copy()) == expected
    
    expected = [['Lua (programming language)', 'Makkuro', 1113957128, 0], ['Covariance and contravariance (computer science)', 'Wakapop', 1167547364, 7453]]
    assert article_length(15000, PROGRAMMING.copy()) == expected
    
    expected = []
    assert article_length(2500, empty_string.copy()) == expected
    
    expected = []
    assert article_length(500, aayush_search_result.copy()) == expected


    # Advanced search option 2, function #3
    expected = [['Digital photography', 'Mintleaf', 1095727840, 18093]]
    assert article_count(3, PHOTOGRAPHY.copy()) == expected
    
    expected = [['C Sharp (programming language)', 'Eaglizard', 1232492672, 52364], ['Python (programming language)', 'Lulu of the Lotus-Eaters', 1137530195, 41571], ['Lua (programming language)', 'Makkuro', 1113957128, 0], ['Covariance and contravariance (computer science)', 'Wakapop', 1167547364, 7453], ['Personal computer', 'Darklock', 1220391790, 45663]]
    assert article_count(5, PROGRAMMING.copy()) == expected
    
    expected = []
    assert article_count(20, empty_string.copy()) == expected
    
    expected = []
    assert article_count(0, aayush_search_result.copy()) == expected
    
    expexted = []
    assert article_count(0, PROGRAMMING.copy()) == expected


    # Advanced search option 3, function #4
    expected = ['Digital photography', 'Mintleaf', 1095727840, 18093]
    assert random_article(0, PHOTOGRAPHY.copy()) == expected
    
    expected = ['Ruby (programming language)', 'Hervegirod', 1193928035, 30284]
    assert random_article(5, PROGRAMMING.copy()) == expected
    
    expected = ''
    assert random_article(3, empty_string.copy()) == expected
    
    expected = ''
    assert random_article(50, aayush_search_result.copy()) == expected


    # Advanced search option 4, function #5
    assert favorite_author('Mintleaf', PHOTOGRAPHY.copy()) == True
    assert favorite_author('Hervegirod', PROGRAMMING.copy()) == True
    assert favorite_author('Buddha', empty_string.copy()) == False
    assert favorite_author('Gandhi', aayush_search_result.copy()) == False


    # Advanced search option 5, function #6
    expected = [['Digital photography', 'Mintleaf']]
    assert title_author(PHOTOGRAPHY.copy()) == expected
    
    expected = [['C Sharp (programming language)', 'Eaglizard'], ['Python (programming language)', 'Lulu of the Lotus-Eaters'], ['Lua (programming language)', 'Makkuro'], ['Covariance and contravariance (computer science)', 'Wakapop'], ['Personal computer', 'Darklock'], ['Ruby (programming language)', 'Hervegirod']]
    assert title_author(PROGRAMMING.copy()) == expected
    
    expected = []
    assert title_author(empty_string.copy()) == expected
    
    expected = []
    assert title_author(aayush_search_result.copy()) == expected


    # Advanced search option 6, function #7
    expected = [['Digital photography', 'Mintleaf', 1095727840, 18093], ['Edogawa, Tokyo', 'Ciphers', 1222607041, 4526], ['Fisk University', 'NerdyScienceDude', 1263393671, 16246], ['Annie (musical)', 'Piano non troppo', 1223619626, 27558], ['Alex Turner (musician)', 'CambridgeBayWeather', 1187010135, 9718]]
    assert multiple_keywords('school', PHOTOGRAPHY.copy()) == expected
    
    expected = [['C Sharp (programming language)', 'Eaglizard', 1232492672, 52364], ['Python (programming language)', 'Lulu of the Lotus-Eaters', 1137530195, 41571], ['Lua (programming language)', 'Makkuro', 1113957128, 0], ['Covariance and contravariance (computer science)', 'Wakapop', 1167547364, 7453], ['Personal computer', 'Darklock', 1220391790, 45663], ['Ruby (programming language)', 'Hervegirod', 1193928035, 30284], ['2009 in music', 'SE KinG', 1235133583, 69451], ['List of dystopian music, TV programs, and games', 'Notinasnaid', 1165317338, 13458], ['2006 in music', 'Suduser85', 1171547747, 105280], ['2007 in music', 'Squilly', 1169248845, 45652], ['2008 in music', 'Ba11innnn', 1217641857, 107605]]
    assert multiple_keywords('place', PROGRAMMING.copy()) == expected
    
    expected = [['List of Canadian musicians', 'Bearcat', 1181623340, 21023], ['French pop music', 'Brandon', 1172208041, 5569], ['Noise (music)', 'Epbr123', 1194207604, 15641], ['1922 in music', 'Jafeluv', 1242717698, 11576], ['1986 in music', 'Michael', 1048918054, 6632], ['Kevin Cadogan', 'Renesis', 1144136316, 3917], ['2009 in music', 'SE KinG', 1235133583, 69451], ['Rock music', 'Sabrebd', 1258069053, 119498], ['Lights (musician)', 'Espo3699', 1213914297, 5898], ['Tim Arnold (musician)', 'Sohohobo', 1181480380, 4551], ['Old-time music', 'Badagnani', 1124771619, 12755], ['Arabic music', 'Badagnani', 1209417864, 25114], ['Joe Becker (musician)', 'Gary King', 1203234507, 5842], ['Richard Wright (musician)', 'Bdubiscool', 1189536295, 16185], ['Voice classification in non-classical music', 'Iridescent', 1198092852, 11280], ['1936 in music', 'JohnRogers', 1243745950, 23417], ['1962 in country music', 'Briguy52748', 1249862464, 7954], ['List of dystopian music, TV programs, and games', 'Notinasnaid', 1165317338, 13458], ['Steve Perry (musician)', 'Woohookitty', 1254812045, 22204], ['David Gray (musician)', 'RattleandHum', 1159841492, 7203], ['Alex Turner (musician)', 'CambridgeBayWeather', 1187010135, 9718], ['List of gospel musicians', 'Absolon', 1197658845, 3805], ['Indian classical music', 'Davydog', 1222543238, 9503], ['1996 in music', 'Kharker', 1148585201, 21688], ['Traditional Thai musical instruments', 'Badagnani', 1191830919, 6775], ['2006 in music', 'Suduser85', 1171547747, 105280], ['Tony Kaye (musician)', 'Bondegezou', 1141489894, 8419], ['Texture (music)', 'J Lorraine', 1161070178, 3626], ['2007 in music', 'Squilly', 1169248845, 45652], ['2008 in music', 'Ba11innnn', 1217641857, 107605]]
    assert multiple_keywords('music', empty_string.copy()) == expected
    
    expected = [['Spain national beach soccer team', 'Pegship', 1233458894, 1526], ['Will Johnson (soccer)', 'Mayumashu', 1218489712, 3562], ['Steven Cohen (soccer)', 'Scouselad10', 1237669593, 2117]]
    assert multiple_keywords('soccer', aayush_search_result.copy()) == expected
示例#11
0
def test_favorite_author():
    assert favorite_author('Thug outlaw69', 'travel') == True
    assert favorite_author('Johnny', 'music') == False
    assert favorite_author('Susan', 'photography') == False
示例#12
0
def tests_functions():
    # function 3
    assert search('PLACE') == PLACE
    assert search('Travel') == TRAVEL
    assert search('school') == SCHOOL
    assert search('') == []
    # function 4
    assert article_info(deepcopy(TRAVEL), TITLE_TO_INFO) == {
        'Time travel': {
            'author': 'Thug outlaw69',
            'timestamp': 1140826049,
            'length': 35170
        }
    }
    assert article_info(deepcopy(PLACE), TITLE_TO_INFO) == {
        '2009 in music': {
            'author': 'SE KinG',
            'timestamp': 1235133583,
            'length': 69451
        },
        'List of dystopian music, TV programs, and games': {
            'author': 'Notinasnaid',
            'timestamp': 1165317338,
            'length': 13458
        },
        '2006 in music': {
            'author': 'Suduser85',
            'timestamp': 1171547747,
            'length': 105280
        },
        '2007 in music': {
            'author': 'Squilly',
            'timestamp': 1169248845,
            'length': 45652
        },
        '2008 in music': {
            'author': 'Ba11innnn',
            'timestamp': 1217641857,
            'length': 107605
        }
    }
    assert article_info(deepcopy(PHOTO), TITLE_TO_INFO) == {
        'Digital photography': {
            'author': 'Mintleaf',
            'timestamp': 1095727840,
            'length': 18093
        }
    }
    # function 5
    assert article_length(8000, deepcopy(PROGRAMMING), TITLE_TO_INFO) == [
        'Lua (programming language)',
        'Covariance and contravariance (computer science)'
    ]
    assert article_length(7000, deepcopy(TRAVEL), TITLE_TO_INFO) == []
    assert article_length(3000, deepcopy(''), TITLE_TO_INFO) == []
    # function 6
    assert title_timestamp(deepcopy(PHOTO), TITLE_TO_INFO) == {
        'Digital photography': 1095727840
    }
    assert title_timestamp(deepcopy(SCHOOL), TITLE_TO_INFO) == {
        'Edogawa, Tokyo': 1222607041,
        'Fisk University': 1263393671,
        'Annie (musical)': 1223619626,
        'Alex Turner (musician)': 1187010135
    }
    assert title_timestamp(deepcopy(''), TITLE_TO_INFO) == {}
    # function 7
    assert favorite_author('Sarranduin', deepcopy(DOG), TITLE_TO_INFO) == True
    assert favorite_author('Godson', deepcopy(MUSIC), TITLE_TO_INFO) == False
    assert favorite_author('', deepcopy(MUSIC), TITLE_TO_INFO) == False
    assert favorite_author('Ciphers', deepcopy(SCHOOL), TITLE_TO_INFO) == True
    # function 8
    assert multiple_keywords('Nature', deepcopy(DOG)) == DOG
    assert multiple_keywords('travel', deepcopy(SCHOOL)) == [
        'Edogawa, Tokyo', 'Fisk University', 'Annie (musical)',
        'Alex Turner (musician)', 'Time travel'
    ]
    assert multiple_keywords('place', deepcopy(PROGRAMMING)) == [
        'C Sharp (programming language)', 'Python (programming language)',
        'Lua (programming language)',
        'Covariance and contravariance (computer science)',
        'Personal computer', 'Ruby (programming language)', '2009 in music',
        'List of dystopian music, TV programs, and games', '2006 in music',
        '2007 in music', '2008 in music'
    ]