Exemple #1
0
def test_example_keyword_to_titles_tests():
    ''' Tests for keyword_to_titles(), function #2. '''
    # Function #2
    assert keyword_to_titles(METADATA) == KEYWORD_TO_TITLES

    # Create fake metadata to test
    fake_metadata = [['an article title', 'andrea', 1234567890, 103, ['some', 'words', 'that', 'make', 'up', 'sentence']],
                     ['another article title', 'helloworld', 987123456, 8029, ['more', 'words', 'could', 'make', 'sentences']]]

    # Expected value of keyword_to_titles with fake_metadata
    expected = {'some': ['an article title'], 'words': ['an article title', 'another article title'], 'that': ['an article title'], 'make': ['an article title', 'another article title'], 'up': ['an article title'], 'sentence': ['an article title'], 'more': ['another article title'], 'could': ['another article title'], 'sentences': ['another article title']}

    assert keyword_to_titles(deepcopy(fake_metadata)) == expected
Exemple #2
0
def test_keyword_to_titles_test2():
    ''' Tests for keyword_to_titles(), function #2. '''
    # Function #2
    assert keyword_to_titles(METADATA) == KEYWORD_TO_TITLES

    # Create fake metadata to test
    fake_metadata = [['pen', 'william', 234567890, 343, ['more', 'give', 'her', 'make', 'take', 'chill']],
                     ['paper', 'smith', 3333423456, 19029, ['more', 'go', 'might', 'give', 'her']]]

    # Expected value of keyword_to_titles with fake_metadata
    expected = {'more': ['pen', 'paper'], 'give': ['pen', 'paper'], 'her': ['pen', 'paper'], 'make': ['pen'], 'take': ['pen'], 'chill': ['pen'], 'go': ['paper'], 'might': ['paper']}

    assert keyword_to_titles(deepcopy(fake_metadata)) == expected
Exemple #3
0
def test_keyword_to_titles_test3():
    ''' Tests for keyword_to_titles(), function #2. '''
    # Function #2
    assert keyword_to_titles(METADATA) == KEYWORD_TO_TITLES

    # Create fake metadata to test
    fake_metadata = [['tea', 'aayush', 4367890, 2343, ['yes', 'no', 'there', 'make', 'move', 'mountain']],
                     ['candy', 'kumar', 553423456, 889029, ['more', 'go', 'yes', 'there', 'her']]]

    # Expected value of keyword_to_titles with fake_metadata
    expected = {'yes': ['tea', 'candy'], 'no': ['tea'], 'there': ['tea', 'candy'], 'make': ['tea'], 'move': ['tea'], 'mountain': ['tea'], 'more': ['candy'], 'go': ['candy'], 'her': ['candy']}

    assert keyword_to_titles(deepcopy(fake_metadata)) == expected
Exemple #4
0
def test_keyword_to_titles_test1():
    ''' Tests for keyword_to_titles(), function #2. '''
    # Function #2
    assert keyword_to_titles(METADATA) == KEYWORD_TO_TITLES

    # Create fake metadata to test
    fake_metadata = [['car', 'aayush', 4567890, 223, ['go', 'words', 'her', 'make', 'so', 'sentence']],
                     ['bike', 'helloworld', 23423456, 22029, ['more', 'go', 'so', 'make', 'her']]]

    # Expected value of keyword_to_titles with fake_metadata
    expected = {'go': ['car', 'bike'], 'words': ['car'], 'her': ['car', 'bike'], 'make': ['car', 'bike'], 'so': ['car', 'bike'], 'sentence': ['car'], 'more': ['bike']}

    assert keyword_to_titles(deepcopy(fake_metadata)) == expected
def test_keyword_to_titles_food():
    ''' Tests for keyword_to_titles(), function #2. '''
    # Function #2
    assert keyword_to_titles(METADATA) == KEYWORD_TO_TITLES

    # Create fake metadata to test
    food_metadata = [['chips', 'lays', 4563211234, 3245, ['snacks', 'food', 'lays', 'dish', 'fried', 'yummy']],
                     ['chicken dinners in 10', 'young mom', 943543215, 7654, ['food', 'chicken', 'easy', 'yummy', 'family']]]

    # Expected value of keyword_to_titles with boyband_metadata
    expected = {'snacks': ['chips'], 'food': ['chips', 'chicken dinners in 10'], 'lays': ['chips'], 'dish': ['chips'], 'fried' : ['chips'], 'yummy': ['chips', 'chicken dinners in 10'], 'chicken': ['chicken dinners in 10'], 'easy': ['chicken dinners in 10'], 'family': ['chicken dinners in 10']}
    
    assert keyword_to_titles(deepcopy(food_metadata)) == expected
def test_keyword_to_titles_cartoon():
    ''' Tests for keyword_to_titles(), function #2. '''
    # Function #2
    assert keyword_to_titles(METADATA) == KEYWORD_TO_TITLES

    # Create fake metadata to test
    cartoon_metadata = [['chowder', 'cartoon network', 45678904321, 1200, ['cartoon', 'kids', 'shows', 'entertainment', 'food', 'funny']],
                     ['loud house', 'nickelodeon', 9432176483, 800, ['kids', 'cartoon', 'entertainment', 'funny', 'family']]]

    # Expected value of keyword_to_titles with food_metadata
    expected = {'cartoon': ['chowder', 'loud house'], 'kids': ['chowder', 'loud house'], 'shows': ['chowder'], 'entertainment': ['chowder', 'loud house'], 'food': ['chowder'], 'funny': ['chowder', 'loud house'], 'family': ['loud house']}
    
    assert keyword_to_titles(deepcopy(cartoon_metadata)) == expected
def test_keyword_to_titles_boyband():
    ''' Tests for keyword_to_titles(), function #2. '''
    # Function #2
    assert keyword_to_titles(METADATA) == KEYWORD_TO_TITLES

    # Create fake metadata to test
    boyband_metadata = [['boyband crazy', 'sza', 1234567890, 9000, ['boy', 'band', 'sing', 'dance', 'cute', 'love']],
                     ['surfaces', 'surface_lover123', 9877485456, 80009, ['new', 'band', 'singers', 'tour', 'dance']]]

    # Expected value of keyword_to_titles with cartoon_metadata
    expected = {'boy': ['boyband crazy'], 'band': ['boyband crazy', 'surfaces'], 'sing': ['boyband crazy'], 'dance': ['boyband crazy', 'surfaces'], 'cute': ['boyband crazy'], 'love': ['boyband crazy'], 'new': ['surfaces'], 'singers': ['surfaces'], 'tour': ['surfaces']}

    assert keyword_to_titles(deepcopy(boyband_metadata)) == expected
Exemple #8
0
def test_keyword_to_titles():
    metadatax = [[
        'Afro Music', 'Burnaboy', 212323224, 2879,
        ['ye', 'big', 'man', 'bad', 'good']
    ],
                 [
                     'endSARS', 'Falz', 346870702, 900,
                     ['bad', 'government', 'Nigeria', 'Good']
                 ]]
    metadataxx = [[
        'Epic Race', 'Bolt', 347979034, 3500,
        ['run', 'sweat', 'wake', 'jump', 'race']
    ], ['Marathon', 'Anderson Cooper', 34598347, 2500, ['Run', 'run', 'Walk']],
                  [
                      'Football', 'Ronaldo', 348607070, 7500,
                      ['ball', 'GOAT', 'sweat', 'run']
                  ]]
    metadataxxx = [[
        'Good Government', 'Dele', 567884583, 15000,
        ['peace', 'corruption', 'health']
    ],
                   [
                       'Nigeria Independence', 'Obasanjo', 234676879, 20000,
                       ['1960', 'britian', 'politician', 'nigerian', 'peace']
                   ]]

    # 1
    expected = {
        'ye': ['Afro Music'],
        'big': ['Afro Music'],
        'man': ['Afro Music'],
        'bad': ['Afro Music', 'endSARS'],
        'good': ['Afro Music'],
        'government': ['endSARS'],
        'Nigeria': ['endSARS'],
        'Good': ['endSARS']
    }
    assert keyword_to_titles(deepcopy(metadatax)) == expected

    expected = {
        'run': ['Epic Race', 'Marathon', 'Football'],
        'sweat': ['Epic Race', 'Football'],
        'wake': ['Epic Race'],
        'jump': ['Epic Race'],
        'race': ['Epic Race'],
        'Run': ['Marathon'],
        'Walk': ['Marathon'],
        'ball': ['Football'],
        'GOAT': ['Football']
    }
    assert keyword_to_titles(deepcopy(metadataxx)) == expected
    # 3
    expected = {
        'peace': ['Good Government', 'Nigeria Independence'],
        'corruption': ['Good Government'],
        'health': ['Good Government'],
        '1960': ['Nigeria Independence'],
        'britian': ['Nigeria Independence'],
        'politician': ['Nigeria Independence'],
        'nigerian': ['Nigeria Independence']
    }
    assert keyword_to_titles(deepcopy(metadataxxx)) == expected