def test_cdxserver_config(): config = yaml.load(yaml_config) cdxserver = create_cdx_server(config.get('test_1')) assert(isinstance(cdxserver, CDXServer)) sources = cdxserver.sources assert len(sources) == 5 assert type(sources[0]) == CDXFile assert sources[0].filename.endswith('example.cdx') # remote source with no remote processing assert type(sources[1]) == RemoteCDXSource assert sources[1].remote_url == 'http://cdxserver.example.com/cdx' assert sources[1].remote_processing == False # remote cdx server with processing assert type(sources[2]) == RemoteCDXSource assert sources[2].remote_url == 'http://cdxserver.example.com/cdx' assert sources[2].remote_processing == True # redis source assert type(sources[3]) == RedisCDXSource assert sources[3].redis_url == 'redis://redis.example.com:6379/0' assert type(sources[4]) == ZipNumCluster assert sources[4].summary.endswith('zipnum-sample.idx') assert sources[4].loc_resolver.loc_filename.endswith('zipnum-sample.loc')
def test_single_cdx(): config = yaml.load(yaml_config) cdxserver = create_cdx_server(config.get('test_5')) assert(isinstance(cdxserver, CDXServer)) sources = cdxserver.sources assert len(sources) == 1 assert type(sources[0]) == CDXFile assert sources[0].filename.endswith('example.cdx')
def assert_remote_cdxserver(config_name): config = yaml.load(yaml_config) cdxserver = create_cdx_server(config.get(config_name)) assert(isinstance(cdxserver, RemoteCDXServer)) source = cdxserver.source # remote cdx server with remote processing assert type(source) == RemoteCDXSource assert source.remote_url == 'http://cdxserver.example.com/cdx' assert source.remote_processing == True
def init_from_config(config, ds_rules_file=DEFAULT_RULES_FILE, html_view=None, server_cls=None): perms_policy = None if hasattr(config, 'get'): perms_policy = config.get('perms_policy') server_cls = config.get('server_cls', server_cls) cdx_server = create_cdx_server(config, ds_rules_file, server_cls) return QueryHandler(cdx_server, html_view, perms_policy)
def test_invalid_config(): config = yaml.load(yaml_config) cdxserver = create_cdx_server(config.get('test_6')) assert(isinstance(cdxserver, CDXServer)) sources = cdxserver.sources assert len(sources) == 0