Example #1
0
def test_unit_tests2():
    travel_search_results = [
        'Medical value travel', 'Time travel',
        'List of video games with time travel'
    ]

    # Basic search, function #1
    assert search('travel') == travel_search_results

    # Advanced search option 1, function #2
    expected = ['Medical value travel', 'Time travel']
    assert title_length(23, travel_search_results.copy()) == expected

    expected = ['Time travel']
    assert title_length(15, travel_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(2, travel_search_results.copy()) == [
        'Medical value travel', 'Time travel'
    ]
    assert article_count(50, travel_search_results.copy()) == [
        'Medical value travel', 'Time travel',
        'List of video games with time travel'
    ]

    # Advanced search option 3, function #4
    assert random_article(
        2,
        travel_search_results.copy()) == 'List of video games with time travel'
    assert random_article(
        0, travel_search_results.copy()) == 'Medical value travel'

    # Advanced search option 4, function #5
    assert favorite_article('Time travel',
                            travel_search_results.copy()) == True
    assert favorite_article('Time travels',
                            travel_search_results.copy()) == False

    # Advanced search option 5, function #6
    expected = [
        'Medical value travel', 'Time travel',
        'List of video games with time travel',
        'Spain national beach soccer team', 'Will Johnson (soccer)',
        'Steven Cohen (soccer)', 'Craig Martin (soccer)',
        "United States men's national soccer team 2009 results",
        'China national soccer team', "Wake Forest Demon Deacons men's soccer"
    ]
    assert multiple_keywords('soccer',
                             travel_search_results.copy()) == expected

    expected = [
        'Medical value travel', 'Time travel',
        'List of video games with time travel', '2007 Bulldogs RLFC season',
        'Will Johnson (soccer)', 'Personal computer',
        'Charles McPherson (musician)',
        'Comparison of programming languages (basic instructions)'
    ]
    assert multiple_keywords('son', travel_search_results.copy()) == expected
Example #2
0
def test_unit_test_photography():
    photography_search_results = [
        'Digital photography', 'Wildlife photography'
    ]

    # Basic search, function #1
    assert search('photography') == photography_search_results

    # Advanced search option 1, function #2
    expected = ['Digital photography', 'Wildlife photography']
    assert title_length(40, photography_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(5, photography_search_results.copy()) == [
        'Digital photography', 'Wildlife photography'
    ]

    # Advanced search option 3, function #4
    assert random_article(3, photography_search_results.copy()) == ''

    # Advanced search option 4, function #5
    assert favorite_article('photography and the world',
                            photography_search_results.copy()) == False

    # Advanced search option 5, function #6
    expected = [
        'Digital photography', 'Wildlife photography',
        'C Sharp (programming language)', 'Reflection-oriented programming',
        'B (programming language)', 'Python (programming language)',
        'Lua (programming language)',
        'Comparison of programming languages (basic instructions)',
        'Ruby (programming language)', 'Semaphore (programming)'
    ]
    assert multiple_keywords('programming',
                             photography_search_results.copy()) == expected
Example #3
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
def test_unit_search_photo():
    # Basic search, function #1
    assert search('photo') == PHOTOGRAPHY

    # Advanced search option 1, function #2
    expected = [['Digital photography', 'Mintleaf', 1095727840, 18093]]
    assert article_length(28000, PHOTOGRAPHY.copy()) == expected

    # Advanced search option 2, function #3
    expected = [['Digital photography', 'Mintleaf', 1095727840, 18093]]
    assert article_count(2, PHOTOGRAPHY.copy()) == expected

    # Advanced search option 3, function #4
    expected = ''
    assert random_article(4, PHOTOGRAPHY.copy()) == expected

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

    # Advanced search option 5, function #6
    expected = [['Digital photography', 'Mintleaf']]
    assert title_author(PHOTOGRAPHY.copy()) == expected

    # Advanced search option 6, function #7
    expected = [['Digital photography', 'Mintleaf', 1095727840, 18093],
                ['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]]
    assert multiple_keywords('dog', PHOTOGRAPHY.copy()) == expected
Example #5
0
def test_unit_test_volleyball():
    volleyball_search_results = [
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)'
    ]

    # Basic search, function #1
    assert search('volleyball') == volleyball_search_results

    # Advanced search option 1, function #2
    expected = ['USC Trojans volleyball', 'Mets de Guaynabo (volleyball)']
    assert title_length(50, volleyball_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(
        1, volleyball_search_results.copy()) == ['USC Trojans volleyball']

    # Advanced search option 3, function #4
    assert random_article(
        1, volleyball_search_results.copy()) == 'Mets de Guaynabo (volleyball)'

    # Advanced search option 4, function #5
    assert favorite_article('volleyball in the valley',
                            volleyball_search_results.copy()) == False

    # Advanced search option 5, function #6
    expected = [
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)',
        'Spain national beach soccer team', 'Will Johnson (soccer)',
        'Steven Cohen (soccer)', 'Craig Martin (soccer)',
        "United States men's national soccer team 2009 results",
        'China national soccer team', "Wake Forest Demon Deacons men's soccer"
    ]
    assert multiple_keywords('soccer',
                             volleyball_search_results.copy()) == expected
Example #6
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
Example #7
0
def test_unit_tests3():
    empty_string_search_results = []

    # Basic search, function #1
    assert search('') == empty_string_search_results

    # Advanced search option 1, function #2
    expected = []
    assert title_length(3, empty_string_search_results.copy()) == expected
    assert title_length(0, empty_string_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(0, empty_string_search_results.copy()) == []
    assert article_count(50, empty_string_search_results.copy()) == []
    assert article_count(1, empty_string_search_results.copy()) == []

    # Advanced search option 3, function #4
    assert random_article(2, empty_string_search_results.copy()) == ''
    assert random_article(0, empty_string_search_results.copy()) == ''

    # Advanced search option 4, function #5
    assert favorite_article('Time travel',
                            empty_string_search_results.copy()) == False
    assert favorite_article('', empty_string_search_results.copy()) == False

    # Advanced search option 5, function #6
    expected = [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        '2009 Louisiana Tech Bulldogs football team',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Georgia Bulldogs football under Robert Winston', 'Landseer (dog)'
    ]
    assert multiple_keywords('dog',
                             empty_string_search_results.copy()) == expected

    expected = []
    assert multiple_keywords('Aayush',
                             empty_string_search_results.copy()) == expected
Example #8
0
def test_example_unit_tests():
    # Storing into a variable so don't need to copy and paste long list every time
    # If you want to store search results into a variable like this, make sure you pass a copy of it when
    # calling a function, otherwise the original list (ie the one stored in your variable) is going to be
    # mutated. To make a copy, you may use the .copy() function for the variable holding your search result.
    dog_search_results = [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        '2009 Louisiana Tech Bulldogs football team',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Georgia Bulldogs football under Robert Winston', 'Landseer (dog)'
    ]

    # Example tests, these do not count as your tests

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

    # Advanced search option 1, function #2
    expected = [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Landseer (dog)'
    ]
    assert title_length(25, dog_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(3, dog_search_results.copy()) == [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid'
    ]

    # Advanced search option 3, function #4
    assert random_article(3, dog_search_results.copy()) == 'Black dog (ghost)'

    # Advanced search option 4, function #5
    assert favorite_article('Guide dog', dog_search_results.copy()) == True

    # Advanced search option 5, function #6
    expected = [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        '2009 Louisiana Tech Bulldogs football team',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Georgia Bulldogs football under Robert Winston', 'Landseer (dog)',
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)'
    ]
    assert multiple_keywords('volleyball',
                             dog_search_results.copy()) == expected
Example #9
0
def test_unit_tests4():
    caty_search_results = []

    # Basic search, function #1
    assert search('caty') == caty_search_results

    # Advanced search option 1, function #2
    expected = []
    assert title_length(5, caty_search_results.copy()) == expected
    assert title_length(30, caty_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(1, caty_search_results.copy()) == []
    assert article_count(0, caty_search_results.copy()) == []

    # Advanced search option 3, function #4
    assert random_article(0, caty_search_results.copy()) == ''
    assert random_article(6, caty_search_results.copy()) == ''

    # Advanced search option 4, function #5
    assert favorite_article('Google', caty_search_results.copy()) == False
    assert favorite_article('', caty_search_results.copy()) == False

    # Advanced search option 5, function #6
    expected = [
        'C Sharp (programming language)', 'Reflection-oriented programming',
        'B (programming language)', 'Python (programming language)',
        'Lua (programming language)',
        'Comparison of programming languages (basic instructions)',
        'Ruby (programming language)', 'Semaphore (programming)'
    ]
    assert multiple_keywords('programming',
                             caty_search_results.copy()) == expected

    expected = []
    assert multiple_keywords('coin', caty_search_results.copy()) == expected
def test_unit_search_school():
    # Basic search, function #1
    assert search('school') == SCHOOL

    # Advanced search option 1, function #2
    expected = [['Edogawa, Tokyo', 'Ciphers', 1222607041, 4526],
                ['Fisk University', 'NerdyScienceDude', 1263393671, 16246],
                [
                    'Alex Turner (musician)', 'CambridgeBayWeather',
                    1187010135, 9718
                ]]
    assert article_length(17000, SCHOOL.copy()) == expected

    # Advanced search option 2, function #3
    expected = [['Edogawa, Tokyo', 'Ciphers', 1222607041, 4526],
                ['Fisk University', 'NerdyScienceDude', 1263393671, 16246],
                ['Annie (musical)', 'Piano non troppo', 1223619626, 27558]]
    assert article_count(3, SCHOOL.copy()) == expected

    # Advanced search option 3, function #4
    expected = ['Annie (musical)', 'Piano non troppo', 1223619626, 27558]
    assert random_article(2, SCHOOL.copy()) == expected

    # Advanced search option 4, function #5
    #assert favorite_author('Ciphers', SCHOOL.copy()) == True

    # Advanced search option 5, function #6
    expected = [['Edogawa, Tokyo', 'Ciphers'],
                ['Fisk University', 'NerdyScienceDude'],
                ['Annie (musical)', 'Piano non troppo'],
                ['Alex Turner (musician)', 'CambridgeBayWeather']]
    assert title_author(SCHOOL.copy()) == expected

    # Advanced search option 6, function #7
    expected = [['Edogawa, Tokyo', 'Ciphers', 1222607041, 4526],
                ['Fisk University', 'NerdyScienceDude', 1263393671, 16246],
                ['Annie (musical)', 'Piano non troppo', 1223619626, 27558],
                [
                    'Alex Turner (musician)', 'CambridgeBayWeather',
                    1187010135, 9718
                ], ['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', SCHOOL.copy()) == expected
Example #11
0
def test_unit_test_programming():
    programming_search_results = [
        'C Sharp (programming language)', 'Reflection-oriented programming',
        'B (programming language)', 'Python (programming language)',
        'Lua (programming language)',
        'Comparison of programming languages (basic instructions)',
        'Ruby (programming language)', 'Semaphore (programming)'
    ]

    # Basic search, function #1
    assert search('programming') == programming_search_results

    # Advanced search option 1, function #2
    expected = [
        'C Sharp (programming language)', 'B (programming language)',
        'Python (programming language)', 'Lua (programming language)',
        'Ruby (programming language)', 'Semaphore (programming)'
    ]
    assert title_length(30, programming_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(6, programming_search_results.copy()) == [
        'C Sharp (programming language)', 'Reflection-oriented programming',
        'B (programming language)', 'Python (programming language)',
        'Lua (programming language)',
        'Comparison of programming languages (basic instructions)'
    ]

    # Advanced search option 3, function #4
    assert random_article(
        6, programming_search_results.copy()) == 'Ruby (programming language)'

    # Advanced search option 4, function #5
    assert favorite_article('programming for dummies',
                            programming_search_results.copy()) == False

    # Advanced search option 5, function #6
    expected = [
        'C Sharp (programming language)', 'Reflection-oriented programming',
        'B (programming language)', 'Python (programming language)',
        'Lua (programming language)',
        'Comparison of programming languages (basic instructions)',
        'Ruby (programming language)', 'Semaphore (programming)',
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)'
    ]
    assert multiple_keywords('volleyball',
                             programming_search_results.copy()) == expected
def test_unit_search_soccer():
    # Basic search, function #1
    assert search('soccer') == SOCCER

    # Advanced search option 1, function #2
    expected = [[
        'Spain national beach soccer team', 'Pegship', 1233458894, 1526
    ]]
    assert article_length(2000, SOCCER.copy()) == expected

    # Advanced search option 2, function #3
    expected = [[
        'Spain national beach soccer team', 'Pegship', 1233458894, 1526
    ]]
    assert article_count(1, SOCCER.copy()) == expected

    # Advanced search option 3, function #4
    expected = ['Will Johnson (soccer)', 'Mayumashu', 1218489712, 3562]
    assert random_article(1, SOCCER.copy()) == expected

    # Advanced search option 4, function #5
    #assert favorite_author('Ben Afleck', SOCCER.copy()) == False

    # Advanced search option 5, function #6
    expected = [['Spain national beach soccer team', 'Pegship'],
                ['Will Johnson (soccer)', 'Mayumashu'],
                ['Steven Cohen (soccer)', 'Scouselad10']]
    assert title_author(SOCCER.copy()) == expected

    # Advanced search option 6, function #7
    expected = [
        ['Spain national beach soccer team', 'Pegship', 1233458894, 1526],
        ['Will Johnson (soccer)', 'Mayumashu', 1218489712, 3562],
        ['Steven Cohen (soccer)', 'Scouselad10', 1237669593, 2117],
        ['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', SOCCER.copy()) == expected
Example #13
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
Example #14
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 #15
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_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 #20
0
def test_example_unit_tests():
    # Storing into a variable so don't need to copy and paste long list every time
    # If you want to store search results into a variable like this, make sure you pass a copy of it when
    # calling a function, otherwise the original list (ie the one stored in your variable) is going to be
    # mutated. To make a copy, you may use the .copy() function for the variable holding your search result.
    dog_search_results = [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        '2009 Louisiana Tech Bulldogs football team',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Georgia Bulldogs football under Robert Winston', 'Landseer (dog)'
    ]

    # Example tests, these do not count as your tests

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

    photography_search_results = [
        'Digital photography', 'Wildlife photography'
    ]
    assert search('photography') == photography_search_results

    volleyball_search_results = [
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)'
    ]
    assert search('volleyball') == volleyball_search_results

    blue_search_results = []
    assert search('blue') == blue_search_results

    # Advanced search option 1, function #2
    expected = [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Landseer (dog)'
    ]
    assert title_length(25, 'dog') == expected

    fifteen_expected = [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Dalmatian (dog)', 'Guide dog',
        'Endoglin', 'Sun dog', 'The Mandogs', 'Landseer (dog)'
    ]
    assert title_length(15, 'dog') == fifteen_expected

    twenty_expected = ['Digital photography', 'Wildlife photography']
    assert title_length(20, 'photography') == twenty_expected

    zero_expected = []
    assert title_length(0, 'volleyball') == zero_expected

    # Advanced search option 2, function #3
    assert article_count(3, 'dog') == [
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid'
    ]

    one_expected = ['USC Trojans volleyball']
    assert article_count(1, 'volleyball') == one_expected

    three_expected = [
        'List of Canadian musicians', 'French pop music', 'Noise (music)'
    ]
    assert article_count(3, 'music') == three_expected

    four_expected = [
        'C Sharp (programming language)', 'Reflection-oriented programming',
        'B (programming language)', 'Python (programming language)'
    ]
    assert article_count(4, 'programming') == four_expected

    # Advanced search option 3, function #4
    assert random_article(3, 'dog') == ['Black dog (ghost)']

    assert random_article(1, 'music') == ['French pop music']
    assert random_article(3,
                          'programming') == ['Python (programming language)']
    assert random_article(0, 'volleyball') == ['USC Trojans volleyball']

    # Advanced search option 4, function #5
    assert favorite_article('Guide dog', 'dog') == True

    assert favorite_article('black', 'dog') == False
    assert favorite_article('Edogawa, Tokyo', 'dog') == True
    assert favorite_article('Digital photography', 'photography') == True

    # Advanced search option 5, function #6
    expected = [[
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        '2009 Louisiana Tech Bulldogs football team',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Georgia Bulldogs football under Robert Winston', 'Landseer (dog)'
    ], ['USC Trojans volleyball', 'Mets de Guaynabo (volleyball)']]
    assert multiple_keywords('volleyball', 'dog') == expected

    soccer_programming_expected = [
        [
            'Spain national beach soccer team', 'Will Johnson (soccer)',
            'Steven Cohen (soccer)', 'Craig Martin (soccer)',
            "United States men's national soccer team 2009 results",
            'China national soccer team',
            "Wake Forest Demon Deacons men's soccer"
        ],
        [
            'C Sharp (programming language)',
            'Reflection-oriented programming', 'B (programming language)',
            'Python (programming language)', 'Lua (programming language)',
            'Comparison of programming languages (basic instructions)',
            'Ruby (programming language)', 'Semaphore (programming)'
        ]
    ]
    assert multiple_keywords('programming',
                             'soccer') == soccer_programming_expected

    photography_dog_expected = [[
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        '2009 Louisiana Tech Bulldogs football team',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Georgia Bulldogs football under Robert Winston', 'Landseer (dog)'
    ], ['Digital photography', 'Wildlife photography']]
    assert multiple_keywords('photography', 'dog') == photography_dog_expected

    music_volleyball_expected = [
        ['USC Trojans volleyball', 'Mets de Guaynabo (volleyball)'],
        [
            'List of Canadian musicians', 'French pop music', 'Noise (music)',
            '1922 in music', '1986 in music', '2009 in music', 'Rock music',
            'Lights (musician)', 'List of soul musicians', 'Aube (musician)',
            'List of overtone musicians', 'Tim Arnold (musician)',
            'Peter Brown (music industry)', 'Old-time music', 'Arabic music',
            'List of Saturday Night Live musical sketches',
            'Joe Becker (musician)', 'Aco (musician)',
            'Geoff Smith (British 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)',
            'Annie (musical)', 'Alex Turner (musician)',
            'List of gospel musicians', 'Tom Hooper (musician)',
            'Indian classical music', '1996 in music',
            'Joseph Williams (musician)',
            'The Hunchback of Notre Dame (musical)',
            'English folk music (1500–1899)', 'David Levi (musician)',
            'George Crum (musician)', 'Traditional Thai musical instruments',
            'Charles McPherson (musician)', 'Les Cousins (music club)',
            'Paul Carr (musician)', '2006 in music', 'Sean Delaney (musician)',
            'Tony Kaye (musician)', 'Danja (musician)', 'Texture (music)',
            'Register (music)', '2007 in music', '2008 in music'
        ]
    ]
    assert multiple_keywords('music',
                             'volleyball') == music_volleyball_expected
Example #21
0
def test_unit_tests1():
    volleyball_search_results = [
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)'
    ]

    # Basic search, function #1
    assert search('volleyball') == volleyball_search_results

    # Advanced search option 1, function #2
    expected = ['USC Trojans volleyball', 'Mets de Guaynabo (volleyball)']
    assert title_length(30, volleyball_search_results.copy()) == expected

    expected = []
    assert title_length(5, volleyball_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(
        1, volleyball_search_results.copy()) == ['USC Trojans volleyball']
    assert article_count(0, volleyball_search_results.copy()) == []

    # Advanced search option 3, function #4
    assert random_article(
        1, volleyball_search_results.copy()) == 'Mets de Guaynabo (volleyball)'
    assert random_article(
        0, volleyball_search_results.copy()) == 'USC Trojans volleyball'

    # Advanced search option 4, function #5
    assert favorite_article('Guide dog',
                            volleyball_search_results.copy()) == False
    assert favorite_article('USC Trojans volleyball',
                            volleyball_search_results.copy()) == True

    # Advanced search option 5, function #6
    expected = [
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)',
        'List of Canadian musicians', 'French pop music', 'Noise (music)',
        '1922 in music', '1986 in music', '2009 in music', 'Rock music',
        'Lights (musician)', 'List of soul musicians', 'Aube (musician)',
        'List of overtone musicians', 'Tim Arnold (musician)',
        'Peter Brown (music industry)', 'Old-time music', 'Arabic music',
        'List of Saturday Night Live musical sketches',
        'Joe Becker (musician)', 'Aco (musician)',
        'Geoff Smith (British 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)', 'Annie (musical)',
        'Alex Turner (musician)', 'List of gospel musicians',
        'Tom Hooper (musician)', 'Indian classical music', '1996 in music',
        'Joseph Williams (musician)', 'The Hunchback of Notre Dame (musical)',
        'English folk music (1500–1899)', 'David Levi (musician)',
        'George Crum (musician)', 'Traditional Thai musical instruments',
        'Charles McPherson (musician)', 'Les Cousins (music club)',
        'Paul Carr (musician)', '2006 in music', 'Sean Delaney (musician)',
        'Tony Kaye (musician)', 'Danja (musician)', 'Texture (music)',
        'Register (music)', '2007 in music', '2008 in music'
    ]
    assert multiple_keywords('music',
                             volleyball_search_results.copy()) == expected

    expected = [
        'USC Trojans volleyball', 'Mets de Guaynabo (volleyball)',
        'Edogawa, Tokyo', 'Kevin Cadogan', 'Endogenous cannabinoid',
        'Black dog (ghost)', '2007 Bulldogs RLFC season',
        'Mexican dog-faced bat', 'Dalmatian (dog)', 'Guide dog',
        '2009 Louisiana Tech Bulldogs football team',
        'Georgia Bulldogs football', 'Endoglin', 'Sun dog', 'The Mandogs',
        'Georgia Bulldogs football under Robert Winston', 'Landseer (dog)'
    ]
    assert multiple_keywords('dog',
                             volleyball_search_results.copy()) == expected
Example #22
0
def test_unit_test_music():
    music_search_results = [
        'List of Canadian musicians', 'French pop music', 'Noise (music)',
        '1922 in music', '1986 in music', '2009 in music', 'Rock music',
        'Lights (musician)', 'List of soul musicians', 'Aube (musician)',
        'List of overtone musicians', 'Tim Arnold (musician)',
        'Peter Brown (music industry)', 'Old-time music', 'Arabic music',
        'List of Saturday Night Live musical sketches',
        'Joe Becker (musician)', 'Aco (musician)',
        'Geoff Smith (British 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)', 'Annie (musical)',
        'Alex Turner (musician)', 'List of gospel musicians',
        'Tom Hooper (musician)', 'Indian classical music', '1996 in music',
        'Joseph Williams (musician)', 'The Hunchback of Notre Dame (musical)',
        'English folk music (1500–1899)', 'David Levi (musician)',
        'George Crum (musician)', 'Traditional Thai musical instruments',
        'Charles McPherson (musician)', 'Les Cousins (music club)',
        'Paul Carr (musician)', '2006 in music', 'Sean Delaney (musician)',
        'Tony Kaye (musician)', 'Danja (musician)', 'Texture (music)',
        'Register (music)', '2007 in music', '2008 in music'
    ]

    # Basic search, function #1
    assert search('music') == music_search_results

    # Advanced search option 1, function #2
    expected = [
        'Noise (music)', '1922 in music', '1986 in music', '2009 in music',
        'Rock music', 'Old-time music', 'Arabic music', 'Aco (musician)',
        '1936 in music', '1996 in music', '2006 in music', '2007 in music',
        '2008 in music'
    ]
    assert title_length(14, music_search_results.copy()) == expected

    # Advanced search option 2, function #3
    assert article_count(15, music_search_results.copy()) == [
        'List of Canadian musicians', 'French pop music', 'Noise (music)',
        '1922 in music', '1986 in music', '2009 in music', 'Rock music',
        'Lights (musician)', 'List of soul musicians', 'Aube (musician)',
        'List of overtone musicians', 'Tim Arnold (musician)',
        'Peter Brown (music industry)', 'Old-time music', 'Arabic music'
    ]

    # Advanced search option 3, function #4
    assert random_article(13, music_search_results.copy()) == 'Old-time music'

    # Advanced search option 4, function #5
    assert favorite_article('Rock music', music_search_results.copy()) == True

    # Advanced search option 5, function #6
    expected = [
        'List of Canadian musicians', 'French pop music', 'Noise (music)',
        '1922 in music', '1986 in music', '2009 in music', 'Rock music',
        'Lights (musician)', 'List of soul musicians', 'Aube (musician)',
        'List of overtone musicians', 'Tim Arnold (musician)',
        'Peter Brown (music industry)', 'Old-time music', 'Arabic music',
        'List of Saturday Night Live musical sketches',
        'Joe Becker (musician)', 'Aco (musician)',
        'Geoff Smith (British 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)', 'Annie (musical)',
        'Alex Turner (musician)', 'List of gospel musicians',
        'Tom Hooper (musician)', 'Indian classical music', '1996 in music',
        'Joseph Williams (musician)', 'The Hunchback of Notre Dame (musical)',
        'English folk music (1500–1899)', 'David Levi (musician)',
        'George Crum (musician)', 'Traditional Thai musical instruments',
        'Charles McPherson (musician)', 'Les Cousins (music club)',
        'Paul Carr (musician)', '2006 in music', 'Sean Delaney (musician)',
        'Tony Kaye (musician)', 'Danja (musician)', 'Texture (music)',
        'Register (music)', '2007 in music', '2008 in music',
        'Digital photography', 'Wildlife photography'
    ]
    assert multiple_keywords('photography',
                             music_search_results.copy()) == expected
Example #23
0
def test_multiple_keywords():
    assert multiple_keywords('photo', 'dance') == [['Digital photography', 'Mintleaf', 1095727840, 18093], ['List of Canadian musicians', 'Bearcat', 1181623340, 21023], ['2009 in music', 'SE KinG', 1235133583, 69451], ['Old-time music', 'Badagnani', 1124771619, 12755], ['1936 in music', 'JohnRogers', 1243745950, 23417], ['Indian classical music', 'Davydog', 1222543238, 9503]]
    assert multiple_keywords('school', ' ') == [['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(' ', ' ') == []
def test_unit_search_music():
    # Basic search, function #1
    assert search('music') == MUSIC

    # Advanced search option 1, function #2
    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],
        ['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
        ], ['Tony Kaye (musician)', 'Bondegezou', 1141489894, 8419],
        ['Texture (music)', 'J Lorraine', 1161070178, 3626]
    ]
    assert article_length(28000, MUSIC.copy()) == expected

    # Advanced search option 2, function #3
    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]]
    assert article_count(10, MUSIC.copy()) == expected

    # Advanced search option 3, function #4
    expected = ['1986 in music', 'Michael', 1048918054, 6632]
    assert random_article(4, MUSIC.copy()) == expected

    # Advanced search option 4, function #5
    #assert favorite_author('Jafeluv', MUSIC.copy()) == True

    # Advanced search option 5, function #6
    expected = [
        ['List of Canadian musicians', 'Bearcat'],
        ['French pop music', 'Brandon'], ['Noise (music)', 'Epbr123'],
        ['1922 in music', 'Jafeluv'], ['1986 in music', 'Michael'],
        ['Kevin Cadogan', 'Renesis'], ['2009 in music', 'SE KinG'],
        ['Rock music', 'Sabrebd'], ['Lights (musician)', 'Espo3699'],
        ['Tim Arnold (musician)', 'Sohohobo'], ['Old-time music', 'Badagnani'],
        ['Arabic music', 'Badagnani'], ['Joe Becker (musician)', 'Gary King'],
        ['Richard Wright (musician)', 'Bdubiscool'],
        ['Voice classification in non-classical music', 'Iridescent'],
        ['1936 in music', 'JohnRogers'],
        ['1962 in country music', 'Briguy52748'],
        ['List of dystopian music, TV programs, and games', 'Notinasnaid'],
        ['Steve Perry (musician)', 'Woohookitty'],
        ['David Gray (musician)', 'RattleandHum'],
        ['Alex Turner (musician)', 'CambridgeBayWeather'],
        ['List of gospel musicians', 'Absolon'],
        ['Indian classical music', 'Davydog'], ['1996 in music', 'Kharker'],
        ['Traditional Thai musical instruments', 'Badagnani'],
        ['2006 in music', 'Suduser85'], ['Tony Kaye (musician)', 'Bondegezou'],
        ['Texture (music)', 'J Lorraine'], ['2007 in music', 'Squilly'],
        ['2008 in music', 'Ba11innnn']
    ]
    assert title_author(MUSIC.copy()) == expected

    # Advanced search option 6, function #7
    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],
        ['Time travel', 'Thug outlaw69', 1140826049, 35170]
    ]
    assert multiple_keywords('travel', MUSIC.copy()) == expected
Example #25
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
Example #26
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'
    ]