def save_keys_to_kb(kb_name, list_of_keys, value): """Add all the keys in the KB with the same value.""" if check_keys(kb_name, list_of_keys): old_value = get_value(kb_name, list_of_keys) # Adds any possible new identifier to the KB for key in list_of_keys: add_kb_mapping(kb_name, key, old_value) else: for key in list_of_keys: add_kb_mapping(kb_name, key, value)
def test_add_get_remove(self): """bibknowledge - test creating a kb, adding a mapping, removing it, removing kb""" from invenio_knowledge.api import add_kb, get_kb_name, \ kb_mapping_exists, remove_kb_mapping, delete_kb, kb_exists, \ add_kb_mapping new_kb_id = add_kb() new_name = get_kb_name(new_kb_id) add_kb_mapping(new_name, "foobar", "barfoo") fbexists = kb_mapping_exists(new_name, "foobar") self.assertEqual(True, fbexists) remove_kb_mapping(new_name, "foobar") fbexists = kb_mapping_exists(new_name, "foobar") self.assertEqual(False, fbexists) delete_kb(new_name) still_there = kb_exists(new_name) self.assertEqual(False, still_there)