def setUpClass(cls):
     token = os.environ.get('KB_AUTH_TOKEN', None)
     config_file = os.environ.get('KB_DEPLOYMENT_CONFIG', None)
     cls.cfg = {}
     config = ConfigParser()
     config.read(config_file)
     for nameval in config.items('OntologyAPI'):
         cls.cfg[nameval[0]] = nameval[1]
     # Getting username from Auth profile for token
     authServiceUrl = cls.cfg['auth-service-url']
     auth_client = _KBaseAuth(authServiceUrl)
     user_id = auth_client.get_user(token)
     # WARNING: don't call any logging methods on the context object,
     # it'll result in a NoneType error
     cls.ctx = MethodContext(None)
     cls.ctx.update({
         'token':
         token,
         'user_id':
         user_id,
         'provenance': [{
             'service': 'OntologyAPI',
             'method': 'please_never_use_it_in_production',
             'method_params': []
         }],
         'authenticated':
         1
     })
     cls.wsURL = cls.cfg['workspace-url']
     cls.wsClient = Workspace(cls.wsURL)
     cls.serviceImpl = OntologyAPI(cls.cfg)
     cls.scratch = cls.cfg['scratch']
     #cls.callback_url = os.environ['SDK_CALLBACK_URL']
     suffix = int(time.time() * 1000)
     cls.wsName = "test_OntologyAPI_" + str(suffix)
     ret = cls.wsClient.create_workspace({'workspace': cls.wsName})  # noqa
Ejemplo n.º 2
0
 def __init__(self):
     submod = get_service_name() or 'OntologyAPI'
     self.userlog = log.log(submod,
                            ip_address=True,
                            authuser=True,
                            module=True,
                            method=True,
                            call_id=True,
                            changecallback=self.logcallback,
                            config=get_config_file())
     self.serverlog = log.log(submod,
                              ip_address=True,
                              authuser=True,
                              module=True,
                              method=True,
                              call_id=True,
                              logfile=self.userlog.get_log_file())
     self.serverlog.set_log_level(6)
     self.rpc_service = JSONRPCServiceCustom()
     self.method_authentication = dict()
     self.rpc_service.add(impl_OntologyAPI.get_descendants,
                          name='OntologyAPI.get_descendants',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_descendants'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_ancestors,
                          name='OntologyAPI.get_ancestors',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_ancestors'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_children,
                          name='OntologyAPI.get_children',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_children'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_parents,
                          name='OntologyAPI.get_parents',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_parents'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_related,
                          name='OntologyAPI.get_related',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_related'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_siblings,
                          name='OntologyAPI.get_siblings',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_siblings'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_terms,
                          name='OntologyAPI.get_terms',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_terms'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_hierarchical_ancestors,
                          name='OntologyAPI.get_hierarchical_ancestors',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_hierarchical_ancestors'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_hierarchical_children,
                          name='OntologyAPI.get_hierarchical_children',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_hierarchical_children'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_hierarchical_descendants,
                          name='OntologyAPI.get_hierarchical_descendants',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_hierarchical_descendants'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_hierarchical_parents,
                          name='OntologyAPI.get_hierarchical_parents',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_hierarchical_parents'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_associated_ws_genomes,
                          name='OntologyAPI.get_associated_ws_genomes',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_associated_ws_genomes'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_associated_ws_features,
                          name='OntologyAPI.get_associated_ws_features',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_associated_ws_features'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_terms_from_ws_feature,
                          name='OntologyAPI.get_terms_from_ws_feature',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_terms_from_ws_feature'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_terms_from_ws_object,
                          name='OntologyAPI.get_terms_from_ws_object',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_terms_from_ws_object'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.get_associated_samples,
                          name='OntologyAPI.get_associated_samples',
                          types=[dict])
     self.method_authentication[
         'OntologyAPI.get_associated_samples'] = 'optional'  # noqa
     self.rpc_service.add(impl_OntologyAPI.status,
                          name='OntologyAPI.status',
                          types=[dict])
     authurl = config.get(AUTH) if config else None
     self.auth_client = _KBaseAuth(authurl)