Beispiel #1
0
    def test_startups(self):

        #Test normal startup, should work
        self.cUtil.setUp()
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))

        #Test empty startup without DB version should work
        self.cUtil.setUpEmpty()
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))
    
        #Test empty startup with several different valid versions should work
        self.cUtil.setUpEmpty(db_version=3)
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))
        self.cUtil.setUpEmpty(db_version=4)
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))

        #Startup with version that is too high should fail
        self.cUtil.setUpEmpty(db_version=2525)

        catalog = None
        with self.assertRaises(IOError) as e:
            catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertEqual(str(e.exception),
            'Incompatible DB versions.  Expecting DB V4, found DV V2525. You are probably running an old version of the service.  Start up failed.');
Beispiel #2
0
 def setUpClass(cls):
     print('++++++++++++ RUNNING secure_config_params.py +++++++++++')
     cls.cUtil = CatalogTestUtil(
         '.')  # TODO: pass in test directory from outside
     cls.cUtil.setUp()
     cls.catalog = Catalog(cls.cUtil.getCatalogConfig())
     print('ready')
Beispiel #3
0
 def setUpClass(cls):
     print('++++++++++++ RUNNING admin_methods_test.py +++++++++++')
     cls.cUtil = CatalogTestUtil(
         '.')  # TODO: pass in test directory from outside
     cls.cUtil.setUp()
     cls.catalog = Catalog(cls.cUtil.getCatalogConfig())
     print('ready')
Beispiel #4
0
    def setUpClass(cls):

        print('++++++++++++ RUNNING core_registration_test.py +++++++++++')

        # hack for testing!! remove when docker and NMS components can be tested
        from biokbase.catalog.registrar import Registrar
        Registrar._TEST_WITHOUT_DOCKER = True

        cls.cUtil = CatalogTestUtil(
            '.')  # TODO: pass in test directory from outside
        cls.cUtil.setUp()
        cls.catalog = Catalog(cls.cUtil.getCatalogConfig())
        # approve developers we will use
        cls.catalog.approve_developer(cls.cUtil.admin_ctx(),
                                      cls.cUtil.admin_ctx()['user_id'])
        cls.catalog.approve_developer(cls.cUtil.admin_ctx(),
                                      cls.cUtil.user_ctx()['user_id'])

        cls.nms = NarrativeMethodStore(cls.cUtil.getCatalogConfig()['nms-url'])
Beispiel #5
0
    def test_startups(self):
        # Test normal startup, should work
        self.cUtil.setUp()
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))

        # Test empty startup without DB version should work
        self.cUtil.setUpEmpty()
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))

        # Test empty startup with several different valid versions should work
        self.cUtil.setUpEmpty(db_version=3)
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))
        self.cUtil.setUpEmpty(db_version=4)
        catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertTrue(semantic_version.validate(catalog.version(self.cUtil.anonymous_ctx())[0]))

        # Startup with version that is too high should fail
        self.cUtil.setUpEmpty(db_version=2525)

        catalog = None
        with self.assertRaises(IOError) as e:
            catalog = Catalog(self.cUtil.getCatalogConfig())
        self.assertEqual(str(e.exception),
                         'Incompatible DB versions.  Expecting DB V4, found DV V2525. You are '
                         'probably running an old version of the service.  Start up failed.')
Beispiel #6
0
 def setUpClass(cls):
     print('++++++++++++ RUNNING basic_catalog_test.py +++++++++++')
     cls.cUtil = CatalogTestUtil(
         '.')  # TODO: pass in test directory from outside
     cls.cUtil.setUp()
     cls.catalog = Catalog(cls.cUtil.getCatalogConfig())
Beispiel #7
0
def get_config():
    if not get_config_file():
        return None
    retconfig = {}
    config = ConfigParser()
    config.read(get_config_file())
    for nameval in config.items(get_service_name() or 'Catalog'):
        retconfig[nameval[0]] = nameval[1]
    return retconfig


config = get_config()

from biokbase.catalog.Impl import Catalog  # noqa @IgnorePep8
impl_Catalog = Catalog(config)


class JSONObjectEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, set):
            return list(obj)
        if isinstance(obj, frozenset):
            return list(obj)
        if hasattr(obj, 'toJSONable'):
            return obj.toJSONable()
        return json.JSONEncoder.default(self, obj)


class JSONRPCServiceCustom(JSONRPCService):
    def call(self, ctx, jsondata):