Example #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
Example #2
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
Example #3
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
Example #4
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
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
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
Example #9
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'
    ]