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
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
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
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
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
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_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_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
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
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