def test_capitalize_roman_numeral_suffixes(self): self.assertEqual('Ken Cuccinelli, II', str(PoliticianNameCleaver('KEN CUCCINELLI II').parse())) self.assertEqual('Ken Cuccinelli, II', str(PoliticianNameCleaver('CUCCINELLI II, KEN').parse())) self.assertEqual('Ken T. Cuccinelli, II', str(PoliticianNameCleaver('CUCCINELLI II, KEN T').parse())) self.assertEqual('Ken T. Cuccinelli, II', str(PoliticianNameCleaver('CUCCINELLI, KEN T II').parse())) self.assertEqual('Ken Cuccinelli, IV', str(PoliticianNameCleaver('CUCCINELLI IV, KEN').parse())) self.assertEqual('Ken Cuccinelli, IX', str(PoliticianNameCleaver('CUCCINELLI IX, KEN').parse()))
def test_case_converts_in_non_mixed_case_names_only(self): self.assertEqual('Antonio dAlesio', str(PoliticianNameCleaver('Antonio dAlesio').parse()))
def test_handles_empty_names(self): self.assertEqual('', str(PoliticianNameCleaver('').parse()))
def test_running_mates_with_metadata(self): self.assertEqual('Ted Strickland & Lee Fischer (D-OH)', str(PoliticianNameCleaver('STRICKLAND, TED & FISCHER, LEE').parse().plus_metadata('D', 'OH')))
def test_edgar_de_lisle_ross(self): name = PoliticianNameCleaver('Edgar de L\'Isle Ross (R)').parse() self.assertEqual('Edgar', name.first) self.assertEqual('de L\'Isle', name.middle) self.assertEqual('Ross', name.last) self.assertEqual(None, name.suffix)
def test_doesnt_misinterpret_roman_numeral_characters_in_last_name_as_suffix(self): self.assertEqual('Vickers', PoliticianNameCleaver('Audrey C Vickers').parse().last)
def test_name_with_two_part_last_name(self): self.assertEqual('La Mere', PoliticianNameCleaver('Albert J La Mere').parse().last) self.assertEqual('Di Souza', PoliticianNameCleaver('Dinesh Di Souza').parse().last)
def test_we_dont_need_no_steeenking_nicknames(self): self.assertEqual('Robert M. McDonnell', str(PoliticianNameCleaver('McDonnell, Robert M (Bob)').parse())) self.assertEqual('John J. Duncan, Jr.', str(PoliticianNameCleaver('John J (Jimmy) Duncan Jr (R)').parse())) self.assertEqual('Christopher Bond', str(PoliticianNameCleaver('Christopher "Kit" Bond').parse())) self.assertEqual('"Kit"', IndividualNameCleaver('Christopher "Kit" Bond').parse().nick)
def test_politician(self): self.assertEqual(u'Tobias F\u00fcnke'.encode('utf-8'), str(PoliticianNameCleaver(u'F\u00fcnke, Tobias').parse()))
def test_last_first(self): self.assertEqual('Albert Gore', str(PoliticianNameCleaver('Gore, Albert').parse()))
def test_not_everything_is_a_scot(self): self.assertEqual('Adam Mack', str(PoliticianNameCleaver('ADAM MACK').parse())) self.assertEqual('Don Womackey', str(PoliticianNameCleaver('DON WOMACKEY').parse()))
def test_first_last_mixed_case_with_party(self): self.assertEqual('Nancy Pelosi', str(PoliticianNameCleaver('Nancy Pelosi (D)').parse()))
def test_last_first_mixed_case_scot_with_party(self): self.assertEqual('Emory MacDonald', str(PoliticianNameCleaver('MacDonald, Emory (R)').parse()))
def test_upper_case_scot_with_party(self): self.assertEqual('Emory MacDonald', str(PoliticianNameCleaver('MACDONALD, EMORY (R)').parse()))
def test_alternate_punctuation(self): self.assertEqual('Charles W. Boustany, Jr.', str(PoliticianNameCleaver('Charles W. Boustany Jr.').parse()))
def test_standardize_running_mate_names(self): self.assertEqual('John Kasich & Mary Taylor', str(PoliticianNameCleaver('Kasich, John & Taylor, Mary').parse()))
def test_standardize_running_mate_names_with_slash(self): self.assertEqual('Mitt Romney & Paul D. Ryan', str(PoliticianNameCleaver('ROMNEY, MITT / RYAN, PAUL D.').parse()))
def test_politician_plus_metadata(self): self.assertEqual(u'Tobias F\u00fcnke (D-CA)'.encode('utf-8'), str(PoliticianNameCleaver(u'F\u00fcnke, Tobias').parse().plus_metadata('D', 'CA')))
def test_politician_running_mates(self): self.assertEqual(u'Tobias F\u00fcnke & Lindsay F\u00fcnke'.encode('utf-8'), str(PoliticianNameCleaver(u'F\u00fcnke, Tobias & F\u00fcnke, Lindsay').parse()))
def test_pile_it_on(self): self.assertEqual('Milton Elmer McCullough, Jr.', str(PoliticianNameCleaver('Milton Elmer "Mac" McCullough, Jr (3)').parse()))
def test_deals_with_last_names_that_look_like_two_part_but_are_not(self): name = PoliticianNameCleaver('Quoc Van (D)').parse() self.assertEqual('Quoc', name.first) self.assertEqual('Van', name.last)
def test_running_mates_with_metadata(self): self.assertEqual(u'Ted Strickland & Le\u00e9 Fischer (D-OH)'.encode('utf-8'), str(PoliticianNameCleaver(u'STRICKLAND, TED & FISCHER, LE\u00c9').parse().plus_metadata('D', 'OH')))
def test_multiple_middle_names(self): self.assertEqual('Swift Eagle', PoliticianNameCleaver('Alexander Swift Eagle Justice').parse().middle)
def test_unparseable_politician_name(self): with self.assertRaises(UnparseableNameException): PoliticianNameCleaver("mr & mrs").parse()
def test_with_metadata(self): self.assertEqual('Charles Schumer (D-NY)', str(PoliticianNameCleaver('Charles Schumer').parse().plus_metadata('D', 'NY'))) self.assertEqual('Barack Obama (D)', str(PoliticianNameCleaver('Barack Obama').parse().plus_metadata('D', ''))) self.assertEqual('Charles Schumer (NY)', str(PoliticianNameCleaver('Charles Schumer').parse().plus_metadata('', 'NY'))) self.assertEqual('Jerry Leon Carroll', str(PoliticianNameCleaver('Jerry Leon Carroll').parse().plus_metadata('', ''))) # only this one guy is missing both at the moment
def test_pile_it_on_two(self): self.assertEqual('William Steve Southerland, II', str(PoliticianNameCleaver('William Steve Southerland II (R)').parse()))
def test_names_with_weird_parenthetical_stuff(self): self.assertEqual('Lynn Swann', str(PoliticianNameCleaver('SWANN, LYNN (COMMITTEE 1)').parse()))
def test_pile_it_on_three(self): self.assertEqual('Edward Thomas O\'Donnell, Jr.', str(PoliticianNameCleaver('Edward Thomas O\'Donnell, Jr (D)').parse()))
def test_capitalize_irish_names(self): self.assertEqual('Sean O\'Leary', str(PoliticianNameCleaver('SEAN O\'LEARY').parse()))
def test_alternate_running_mates_format(self): self.assertEqual('Obama/Biden 2012', str(PoliticianNameCleaver('2012, Obama/Biden').parse()))