1import re 2 3 4def test_person_headshot_should_be_an_image_link(ia): 5 person = ia.get_person('0000206', info=['biography']) # Keanu Reeves 6 assert re.match(r'^https?://.*\.jpg$', person['headshot']) 7 8 9def test_person_full_size_headshot_should_be_an_image_link(ia): 10 person = ia.get_person('0000206', info=['biography']) # Keanu Reeves 11 assert re.match(r'^https?://.*\.jpg$', person['full-size headshot']) 12 13 14def test_person_headshot_if_none_should_be_excluded(ia): 15 person = ia.get_person('0330139', info=['biography']) # Deni Gordon 16 assert 'headshot' not in person 17 18 19def test_person_bio_is_present(ia): 20 person = ia.get_person('0000206', info=['biography']) # Keanu Reeves 21 assert 'mini biography' in person 22 23 24def test_person_birth_date_should_be_in_ymd_format(ia): 25 person = ia.get_person('0000001', info=['biography']) # Fred Astaire 26 assert person.get('birth date') == '1899-05-10' 27 28 29def test_person_birth_date_without_month_and_date_should_be_in_y00_format(ia): 30 person = ia.get_person('0565883', info=['biography']) # Belinda McClory 31 assert person.get('birth date') == '1968-00-00' 32 33 34def test_person_birth_date_without_itemprop_should_be_in_ymd_format(ia): 35 person = ia.get_person('0000007', info=['biography']) # Humphrey Bogart 36 assert person.get('birth date') == '1899-12-25' 37 38 39def test_person_birth_notes_should_contain_birth_place(ia): 40 person = ia.get_person('0000001', info=['biography']) # Fred Astaire 41 assert person.get('birth notes') == 'Omaha, Nebraska, USA' 42 43 44def test_person_death_date_should_be_in_ymd_format(ia): 45 person = ia.get_person('0000001', info=['biography']) # Fred Astaire 46 assert person.get('death date') == '1987-06-22' 47 48 49def test_person_death_date_without_itemprop_should_be_in_ymd_format(ia): 50 person = ia.get_person('0000007', info=['biography']) # Humphrey Bogart 51 assert person.get('death date') == '1957-01-14' 52 53 54def test_person_death_date_if_none_should_be_excluded(ia): 55 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 56 assert 'death date' not in person 57 58 59def test_person_death_notes_should_contain_death_place_and_reason(ia): 60 person = ia.get_person('0000001', info=['biography']) # Fred Astaire 61 assert person['death notes'] == 'in Los Angeles, California, USA (pneumonia)' 62 63 64def test_person_death_notes_if_none_should_be_excluded(ia): 65 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 66 assert 'death notes' not in person 67 68 69def test_person_birth_name_should_be_normalized(ia): 70 data = ia.get_person('0000210', info=['biography']) # Julia Roberts 71 assert data.get('birth name') == 'Julia Fiona Roberts' 72 73 74def test_person_nicknames_if_single_should_be_a_list_of_names(ia): 75 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 76 assert person.get('nick names') == ['Jules'] 77 78 79def test_person_nicknames_if_multiple_should_be_a_list_of_names(ia): 80 person = ia.get_person('0000206', info=['biography']) # Keanu Reeves 81 assert person.get('nick names') == ['The Wall', 'The One'] 82 83 84def test_person_height_should_be_in_inches_and_meters(ia): 85 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 86 assert person.get('height') == '5\' 8" (1.73 m)' 87 88 89def test_person_height_if_none_should_be_excluded(ia): 90 person = ia.get_person('0617588', info=['biography']) # Georges Melies 91 assert 'height' not in person 92 93 94def test_person_spouse_should_be_a_list(ia): 95 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 96 spouses = person.get('spouse', []) 97 assert len(spouses) == 2 98 99 100def test_person_trade_mark_should_be_a_list(ia): 101 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 102 trade_mark = person.get('trade mark', []) 103 assert len(trade_mark) == 3 104 105 106def test_person_trivia_should_be_a_list(ia): 107 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 108 trivia = person.get('trivia', []) 109 assert len(trivia) > 90 110 111 112def test_person_quotes_should_be_a_list(ia): 113 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 114 quotes = person.get('quotes', []) 115 assert len(quotes) > 30 116 117 118def test_person_salary_history_should_be_a_list(ia): 119 person = ia.get_person('0000210', info=['biography']) # Julia Roberts 120 salary = person.get('salary history', []) 121 assert len(salary) > 25 122