def test_add_biography(self): # make a new biography source = Source(id=u'bioport_test') self.repo.add_source(source) bio = Biography(id=u'test_bio.xml', source_id=source.id) # XXX Do we need this? bio.from_args( url_biografie='http://ladida/didum', naam_publisher='nogeensiets', url_publisher='http://pbulihser_url', naam='Tiedel Doodle Dum', local_id='123', ) # save it self._save_biography(bio) assert bio.get_bioport_id() self.assertEqual(bio.repository, self.repo)
def test_save_biography(self): source = Source(id='bioport_test') self.repo.add_source(source) bio = Biography(id='test_bio.xml', source_id=source.id) name = 'Name1' # XXX Do we need this? bio.from_args( url_biografie='http://ladida/didum', naam_publisher='nogeensiets', url_publisher='http://pbulihser_url', naam=name, local_id='123', ) self.assertEqual(len(bio.get_idnos()), 1, bio.to_string()) self._save_biography(bio) # we now have two idnos: the local "id", and the "bioport_id" # assert 0, bio.xpath('person/idno') self.assertEqual(len(bio.get_idnos(type=None)), 2, bio.to_string()) self.assertEqual(self.repo.get_biography(bio.id).naam().volledige_naam(), name) name = 'Name2' bio.set_value('namen', [name]) self._save_biography(bio) biography_from_repo = list(self.repo.get_biographies(local_id=bio.id))[0] self.assertEqual(biography_from_repo.naam().volledige_naam(), name) biography_record = list(self.repo.db._get_biography_query(local_id=bio.id))[0] self.assertEqual(biography_record.url_biography, bio.get_value('url_biography')) self.assertEqual(len(bio.get_idnos(type=None)), 2, bio.to_string())