def test_get_biblio_to_update(self): first_biblio = { "journal": "Space", "title": "A real title" } other_biblio = { "journal": "Earth", "title": "A different title" } aop_biblio = { "journal": "Nature", "title": "AOP" } response = item_module.get_biblio_to_update({}, first_biblio) assert_equals(response, first_biblio) response = item_module.get_biblio_to_update(first_biblio, other_biblio) assert_equals(response, None) response = item_module.get_biblio_to_update(aop_biblio, other_biblio) assert_equals(response, other_biblio)
def update_item_with_new_biblio(cls, new_biblio_dict, item_doc): # return None if no changes # don't change if biblio already there response = item_module.get_biblio_to_update(item_doc["biblio"], new_biblio_dict) if response: item_doc["biblio"] = response item_obj = item_module.add_biblio_to_item_object(new_biblio_dict, item_doc) else: item_doc = None return(item_doc)
def update_item_with_new_biblio(cls, new_biblio_dict, item_doc): # return None if no changes # don't change if biblio already there response = item_module.get_biblio_to_update(item_doc["biblio"], new_biblio_dict) if response: item_doc["biblio"] = response item_obj = item_module.add_biblio_to_item_object( new_biblio_dict, item_doc) else: item_doc = None return (item_doc)