def test_kb_attribute_update(self):
     """bibknowledge - attribute modifications persist in database"""
     # NB: Tested here because with the exception of get_kb_description,
     #     these are exported by module bibknowledge. This mostly is
     #     exercising bibknowledge_dblayer, though.
     dyn_kb_oldname = self.dyn_kbname
     dyn_kb_newname = self._name_a_db()
     junk_desc = self._randomstring()
     dyn_kb_id = get_kb_id(dyn_kb_oldname)
     # we created it so we know it has no desc
     self.assertEqual('', get_kb_description(dyn_kb_oldname))
     # now check that we can rename it
     update_kb_attributes(dyn_kb_oldname, dyn_kb_newname)
     self.assertEqual(None, get_kb_id(dyn_kb_oldname))
     self.assertEqual(dyn_kb_id, get_kb_id(dyn_kb_newname))
     # now check that we can tag it with a description
     update_kb_attributes(dyn_kb_newname, dyn_kb_newname, junk_desc)
     self.assertEqual(junk_desc, get_kb_description(dyn_kb_newname))
     update_kb_attributes(dyn_kb_newname, dyn_kb_oldname)
 def test_kb_attribute_update(self):
     """bibknowledge - attribute modifications persist in database"""
     # NB: Tested here because with the exception of get_kb_description,
     #     these are exported by module bibknowledge. This mostly is
     #     exercising bibknowledge_dblayer, though.
     dyn_kb_oldname = self.dyn_kbname
     dyn_kb_newname = self._name_a_db()
     junk_desc      = self._randomstring()
     dyn_kb_id      = get_kb_id(dyn_kb_oldname)
     # we created it so we know it has no desc
     self.assertEqual('', get_kb_description(dyn_kb_oldname))
     # now check that we can rename it
     update_kb_attributes(dyn_kb_oldname, dyn_kb_newname)
     self.assertEqual(None, get_kb_id(dyn_kb_oldname))
     self.assertEqual(dyn_kb_id, get_kb_id(dyn_kb_newname))
     # now check that we can tag it with a description
     update_kb_attributes(dyn_kb_newname, dyn_kb_newname, junk_desc)
     self.assertEqual(junk_desc, get_kb_description(dyn_kb_newname))
     update_kb_attributes(dyn_kb_newname, dyn_kb_oldname)
Exemplo n.º 3
0
def perform_request_knowledge_base_show_attributes(kb_id, ln=CFG_SITE_LANG, sortby="to"):
    """
    Show the attributes of a knowledge base

    @param ln language
    @param kb a knowledge base id
    @param sortby the sorting criteria ('from' or 'to')
    @return the content of the given knowledge base
    """
    name = bibknowledge_dblayer.get_kb_name(kb_id)
    description = bibknowledge_dblayer.get_kb_description(name)
    kb_type = bibknowledge_dblayer.get_kb_type(name)
    return bibknowledge_templates.tmpl_admin_kb_show_attributes(ln, kb_id, name, description, sortby, kb_type)
Exemplo n.º 4
0
def perform_request_knowledge_base_show_attributes(kb_id,
                                                   ln=CFG_SITE_LANG,
                                                   sortby="to"):
    """
    Show the attributes of a knowledge base

    @param ln language
    @param kb a knowledge base id
    @param sortby the sorting criteria ('from' or 'to')
    @return the content of the given knowledge base
    """
    name = bibknowledge_dblayer.get_kb_name(kb_id)
    description = bibknowledge_dblayer.get_kb_description(name)
    kb_type = bibknowledge_dblayer.get_kb_type(name)
    return bibknowledge_templates.tmpl_admin_kb_show_attributes(
        ln, kb_id, name, description, sortby, kb_type)