def merge_bioport_biographies(self):
        """merge the bioport biographies of this person

        if the bios are not mergeable (they may have different data), don't change anything
        otherwise, add the merged biography, and remove all the old ones
        """
        bios = self.get_biographies(source_id="bioport")
        if not bios:
            return
        elif not isinstance(bios, type([])):
            return bios
        elif len(bios) < 2:
            return bios
        merged_bio = BiographyMerger.merge_biographies(bios)
        for bio in bios:
            self.repository.delete_biography(bio)
        self.add_biography(merged_bio)
        return merged_bio
    def test_sanity(self):
        bio1 = self._create_biography(naam='Mercier', birth_date='2000-01-01')
        bio2 = self._create_biography(naam='Mercier', death_date='2001-01-01')

        m_bio = BiographyMerger.merge_biographies(bio1, bio2)
        self.assertEqual(m_bio.get_value('name'), bio1.get_value('name'))
        self.assertEqual(m_bio.get_value('birth_date'), '2000-01-01')
        self.assertEqual(m_bio.get_value('death_date'), '2001-01-01')
        self.assertEqual(len(m_bio.get_names()), 1)
        bio3 = self._create_biography(naam='Camier')
        bio3.set_category([1, 2])
        bio3.add_or_update_event(type='birth', when='2000-01-01', place='Dublin')

        m_bio = BiographyMerger.merge_biographies(m_bio, bio3)
        self.assertEqual(len(m_bio.get_states(type='category')), 2)

        bio4 = self._create_biography(naam='Camier')
        bio4.set_category([2, 3])
        bio4.add_or_update_event(type='birth', notBefore='1900-01-01', text="I'm glad to see you back. I thought you were gone forever")

        m_bio = BiographyMerger.merge_biographies(bio3, bio4)

        # the merged biography should have 3 categories (1,2 from bio3, and 3, 4 from bio4
        self.assertEqual(len(m_bio.get_states(type='category')), 3)

        event_birth = m_bio.get_event(type='birth')
        self.assertEqual(event_birth.get('when'), '2000-01-01')

        # bio5 has a different birth date from bio3, and so should not be mergable
        bio5 = self._create_biography(naam='Camier')
        bio5.set_category([2, 3])
        bio5.add_or_update_event(type='birth', when='1900-01-01')
        m_bio = BiographyMerger.merge_biographies(bio3, bio5)
#        self.assertEqual(m_bio, [bio3, bio5])

        bio6 = self._create_biography(naam='Camier')
        bio6.add_or_update_event(type='birth', when='1900')
        m_bio = BiographyMerger.merge_biographies(bio6, bio5)
        self.assertEqual(m_bio.get_value('birth_date'), '1900-01-01')

        bio5.add_figure(uri='http://1.com', text='2')
        bio6.add_figure(uri='http://3.com', text='4')
        m_bio = BiographyMerger.merge_biographies(bio6, bio5)
        self.assertTrue(m_bio is not None)
        self.assertEqual(set(m_bio.get_figures_data()), set([('http://3.com', '4'), ('http://1.com', '2')]))