def test_chantal_nijkerken_de_haan(self): wikidata_id = 'Q19830701' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) self.assertEqual(forename, 'Chantal') self.assertEqual(surname, 'Nijkerken-de Haan')
def get_or_create_person(wikidata_id, fullname='', wikidata_item=None, add_initials=False): persons = Person.objects.filter(wikidata_id=wikidata_id) if not wikidata_item: wikidata_item = wikidata.WikidataItem(wikidata_id) if persons.exists(): person = persons[0] else: if not fullname: fullname = wikidata_item.get_label(language='nl') forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) person = Person.objects.create(forename=forename, surname=surname, surname_prefix=surname_prefix, wikidata_id=wikidata_id) person.update_info(language='nl', wikidata_item=wikidata_item) person.save() if add_initials and person.parlement_and_politiek_id: person.initials = scraper.persons.get_initials( person.parlement_and_politiek_id) person.save() assert person.wikidata_id == wikidata_id party_members = PartyMember.objects.filter(person=person) if not party_members.exists(): create_party_members_for_person(person) return person
def test_chantal_nijkerken_de_haan(self): wikidata_id = 'Q19830701' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Chantal') self.assertEqual(surname, 'Nijkerken-de Haan')
def test_leendert_de_lange(self): wikidata_id = 'Q19839084' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) self.assertEqual(forename, 'Leendert') self.assertEqual(surname_prefix, 'de') self.assertEqual(surname, 'Lange')
def test_sjoerd_sjoerdsma(self): wikidata_id = 'Q516335' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) self.assertEqual(forename, 'Sjoerd') self.assertEqual(surname, 'Sjoerdsma') self.assertEqual(surname_prefix, '')
def test_sybrand_van_haersma_buma(self): wikidata_id = 'Q377266' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) self.assertEqual(forename, 'Sybrand') self.assertEqual(surname, 'Haersma Buma') self.assertEqual(surname_prefix, 'van')
def test_jan_kees_de_jager(self): wikidata_id = 'Q1666631' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) self.assertEqual(forename, 'Jan Kees') self.assertEqual(surname, 'Jager') self.assertEqual(surname_prefix, 'de')
def test_jan_peter_balkenende(self): wikidata_id = 'Q133386' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) self.assertEqual(forename, 'Jan Peter') self.assertEqual(surname, 'Balkenende') self.assertEqual(surname_prefix, '')
def test_fatma_koser_kaya(self): wikidata_id = 'Q467610' # Fatma Koşer Kaya wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) self.assertEqual(forename, 'Fatma') self.assertEqual(surname, 'Koşer Kaya') self.assertEqual(surname_prefix, '')
def test_sjoerd_sjoerdsma(self): wikidata_id = 'Q516335' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Sjoerd') self.assertEqual(surname, 'Sjoerdsma') self.assertEqual(surname_prefix, '')
def test_jan_kees_de_jager(self): wikidata_id = 'Q1666631' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Jan Kees') self.assertEqual(surname, 'Jager') self.assertEqual(surname_prefix, 'de')
def test_jan_peter_balkenende(self): wikidata_id = 'Q133386' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Jan Peter') self.assertEqual(surname, 'Balkenende') self.assertEqual(surname_prefix, '')
def test_fatma_koser_kaya(self): wikidata_id = 'Q467610' # Fatma Koşer Kaya wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Fatma') self.assertEqual(surname, 'Koşer Kaya') self.assertEqual(surname_prefix, '')
def test_sybrand_van_haersma_buma(self): wikidata_id = 'Q377266' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Sybrand') self.assertEqual(surname, 'Haersma Buma') self.assertEqual(surname_prefix, 'van')
def test_leendert_de_lange(self): wikidata_id = 'Q19839084' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Leendert') self.assertEqual(surname_prefix, 'de') self.assertEqual(surname, 'Lange')
def test_melanie_schultz_van_hagen(self): wikidata_id = 'Q435886' wikidata_item = wikidata.WikidataItem(wikidata_id) fullname = wikidata_item.get_label() forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) self.assertEqual(forename, 'Melanie') self.assertEqual(surname_prefix, '') self.assertEqual(surname, 'Schultz van Haegen')
def create_person(wikidata_id, fullname, wikidata_item, add_initials): if not fullname: fullname = wikidata_item.get_label(language='nl') forename, surname, surname_prefix = Person.get_name_parts(fullname, wikidata_item) person = Person.objects.create( forename=forename, surname=surname, surname_prefix=surname_prefix, wikidata_id=wikidata_id ) person.update_info(language='nl', wikidata_item=wikidata_item) person.save() if add_initials and person.parlement_and_politiek_id: person.initials = scraper.persons.get_initials(person.parlement_and_politiek_id) person.save() assert person.wikidata_id == wikidata_id return person
def create_person(wikidata_id, fullname, wikidata_item, add_initials): if not fullname: fullname = wikidata_item.get_label(language='nl') forename, surname, surname_prefix = Person.get_name_parts( fullname, wikidata_item) person = Person.objects.create(forename=forename, surname=surname, surname_prefix=surname_prefix, wikidata_id=wikidata_id) person.update_info(language='nl', wikidata_item=wikidata_item) person.save() if add_initials and person.parlement_and_politiek_id: person.initials = scraper.persons.get_initials( person.parlement_and_politiek_id) person.save() add_tk_person_id(person) assert person.wikidata_id == wikidata_id return person